Bug 53339 - ClassNotFoundException when using WebSocketServlet
ClassNotFoundException when using WebSocketServlet
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
PC Windows XP
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2012-05-31 18:20 UTC by ajkrank70
Modified: 2012-06-03 18:51 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description ajkrank70 2012-05-31 18:20:53 UTC
I'm trying to do a JNDI lookup inside the "onOpen" method of my StreamInbound class, but it gives me the exception below.  The code works if I move my JNP JARs to the server lib instead of the webapp lib.  The code also works fine from anywhere else, like in the "doGet" method.

ERROR http-bio-8080-exec-3 Test 
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
	at javax.naming.InitialContext.init(InitialContext.java:223)
	at javax.naming.InitialContext.<init>(InitialContext.java:197)
	at Test$TestStreamInbound.onOpen(Test.java:103)
	at org.apache.catalina.websocket.StreamInbound.onUpgradeComplete(StreamInbound.java:180)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Comment 1 Mark Thomas 2012-05-31 18:22:48 UTC
I suspect we need to set the TCCL correctly for web socket calls.
Comment 2 Mark Thomas 2012-06-03 18:51:09 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.28 onwards.