新的Mongo对象从servlet抛出异常

时间:2011-11-18 17:33:40

标签: java mongodb servlets mlab mongo-java

当我从HttpServlet中创建一个新的Mongo( - location - , - port# - )时,我得到一个AccessControlException。我不知道为什么。如果我从public static void main方法中执行它,它可以正常工作。有谁知道为什么在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)

0 个答案:

没有答案