This page contains an archived post to the Jini Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Jini & servlets
Posted by Antonio on October 08, 2001 at 8:05 AM
First: sorry for my english. I have a problem. I'm using servlets with Tomcat 3.2.3. I have a servlet which uses Jini to get a service in my network, well, I perform lookup in the init() method and the service (m_servlet.Service) is recovered but when I cast it to the service interface (m_servlet.ServiceInterface) the result is an exception: java.lang.ClassCastException: m_servlet.Service at m_servlet.LookUpServlet.init(LookUpServlet.java:93) at javax.servlet.GenericServlet.init(GenericServlet.java:258) at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317) at org.apache.tomcat.core.Handler.init(Handler.java:215) at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296) at org.apache.tomcat.core.Handler.service(Handler.java:254) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372 ) at org.apache.tomcat.core.ContextManager.internalService(ContextManager. java:797) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743 ) at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processCon nection(Ajp12ConnectionHandler.java:166) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java: 416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java :498) at java.lang.Thread.run(Thread.java:484) I think that it is caused by the different classloaders used by the container, in fact I have printed these classloaders: this.getClass().getClassLoader() ---> AdaptiveClassLoader( ) this.getServletContext().getClass().getClassLoader() ---> sun.misc.Launcher$AppClassLoader@1c5c1 Thread.currentThread().getContextClassLoader() ---> sun.misc.Launcher$AppClassLoader@1c5c1 ClassLoader.getSystemClassLoader().toString() ---> sun.misc.Launcher$AppClassLoader@1c5c1 ServiceInterface.class.getClassLoader() ---> AdaptiveClassLoader( ) net.jini.core.entry.Entry.class.getClassLoader() ---> sun.misc.Launcher$AppClassLoader@1c5c1 But I haven't found a solution which works. Can you help me? Is it possible to reach a solution without configuring cointainer settings and ina cross-container manner? Thanks in advance, Regards, Antonio
Replies:
|