File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes Threadpool RMI jedis integration - Permission issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Threadpool RMI jedis integration - Permission issue" Watch "Threadpool RMI jedis integration - Permission issue" New topic
Author

Threadpool RMI jedis integration - Permission issue

raja peter
Greenhorn

Joined: Sep 16, 2010
Posts: 2
Hi,

I've a Threadpool whose scheduled threads access the redis pool and perform some query with it.

I create the JedisPool instance as static in a class in which ThreadPool is created. I pass the JedisPool instance as a parameter while constructing each task. My constructor will be public TestTask(DataSource ds, JedisPool pool, int xx, int yy). Since the task also requires a mysql connection I pass an instance of mysql connection pool's datasource. All these files are in a "packagen".

My server.policy file is in "/home/raja/parent_to_package/" directory and looks like this,

grant codeBase "file:/home/raja/parent_to_package/" {

permission java.security.AllPermission;

permission java.net.SocketPermission ":","connect,resolve";

};

grant codeBase "file:/home/raja/parent_to_package/packagen/" {

permission java.security.AllPermission;

permission java.net.SocketPermission ":","connect,resolve";

};

I run the program from parent_to_package directory like

java -Djava.rmi.server.codebase=file:/home/raja/parent_to_package/interface.jar -Djava.rmi.server.hostname=192.168.0.1 -Djava.security.policy=/home/raja/parent_to_package/server.policy -Xmx256m -Xms256m packagen.MainClass

Still I get the following exception from the child threads.

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:22) at packagen.TestTask.run(TestTask.java:172) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:573) at java.security.AccessController.doPrivileged(Native Method) at java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:570) at java.lang.Thread.run(Thread.java:619)

Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:6379 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034) at java.net.Socket.connect(Socket.java:513) at java.net.Socket.connect(Socket.java:469) at java.net.Socket.(Socket.java:366) at java.net.Socket.(Socket.java:180) at redis.clients.jedis.Connection.connect(Connection.java:105) at redis.clients.jedis.Jedis.connect(Jedis.java:1657) at redis.clients.jedis.JedisPool$JedisFactory.makeObject(JedisPool.java:63) at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974) at redis.clients.util.Pool.getResource(Pool.java:20) ... 13 more
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threadpool RMI jedis integration - Permission issue