0

当我从 HttpServlet 内部创建一个新的 Mongo(--location--,--port#--) 时,我得到一个 AccessControlException。我不确定为什么。如果我从公共静态 void 主要方法中执行此操作,则它可以正常工作。有谁知道为什么在 doPost 中实例化对象会引发异常,并且从 psvm 运行它可以使其正常工作。我尝试将代码从 servlet 类中提取出来并将其放入帮助类中……但我仍然得到相同的结果。这是我的代码:

Mongo m = new Mongo("dbh75.mongolab.com",27757);

这是例外

java.security.AccessControlException: access denied (java.net.SocketPermission dbh75.mongolab.com resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:166)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1031)
at java.net.InetAddress.getAllByName0(InetAddress.java:1145)
at java.net.InetAddress.getAllByName(InetAddress.java:1083)
at java.net.InetAddress.getAllByName(InetAddress.java:1019)
at com.mongodb.ServerAddress._getAddress(ServerAddress.java:223)
at com.mongodb.ServerAddress.<init>(ServerAddress.java:75)
at com.mongodb.Mongo.<init>(Mongo.java:137)
at com.ffftimer.helper.MongoHelper.save(MongoHelper.java:30)
at com.ffftimer.services.workoutBucket.doPost(workoutBucket.java:26)
4

0 回答 0