All, I created a simple web app that demonstrates the exact problem I am having. I posted it up on github.
https://github.com/SoluteInc/JettyWebSocketTest The following steps (give or take), should reproduce the problem. This assumes you have Java 1.7 and Maven 3.x installed. 1. git close https://github.com/SoluteInc/JettyWebSocketTest.git 2. cd JettyWebSocketTest 3. mvn jetty:run 4. Open your browser to http://localhost:8080/test/ 5. Click the Servlet Test link… It will work. 6. Click the Web Socket link…. The exception will be thrown. ~Michael From: <MacFadden>, Michael MacFadden <[email protected]<mailto:[email protected]>> Reply-To: JETTY user mailing list <[email protected]<mailto:[email protected]>> Date: Sunday, August 24, 2014 at 10:14 PM To: JETTY user mailing list <[email protected]<mailto:[email protected]>> Subject: Re: [jetty-users] Jetty WebSockets ClassLoading Issue I should add that if this very same code is also called from a servlet there is no exception. Essentially the code can be called through long-polling (AJAX/CometD). This is in the same web app and jar files. When called through the servlet everything works fine. When called from the web socket, I get the exception. ~Michael From: <MacFadden>, Michael MacFadden <[email protected]<mailto:[email protected]>> Reply-To: JETTY user mailing list <[email protected]<mailto:[email protected]>> Date: Sunday, August 24, 2014 at 8:52 PM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: [jetty-users] Jetty WebSockets ClassLoading Issue Hello, I have an issue using Jetty and WebSockets related to class loading. I have a class set up as a web service endpoint using java annotations. In the onOpen() method. I create an instance of the MyClient class. The MyClient class uses the Apache Commons Lang EventListenerSupport which requires passing an interface class object in. The interface is “MyInterface”. When constructing the MyClient object, I get an exception saying the class can’t be loaded because it is not visible from the class loader. The MyClient and the MyInterace classes are both public, both in the same package, and both in the same jar file. I am very confused as to why the class loader can find the MyClient class but not the MyInterface class. The Commons Lang jar file is also in the WEB-INF/lib directory as well. I have listed the classes and the exception I am getting. Any ideas on what the problem might be, or how to debug it would be helpful. ## My Client Class package com.example; publicclass MyClient { private EventListenerSupport<MyInterface> listeners; public MyClient() { this.listeners = EventListenerSupport.create(MyInterface.class); } } ## MyInterface package com.example; publicinterface MyInterface { void onClientConnected(); } java.lang.IllegalArgumentException: interface com.example.MyInterface is not visible from class loader at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:616) at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:592) at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:244) at java.lang.reflect.WeakCache.get(WeakCache.java:141) at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:455) at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:738) at org.apache.commons.lang3.event.EventListenerSupport.createProxy(EventListenerSupport.java:277) at org.apache.commons.lang3.event.EventListenerSupport.initializeTransientFields(EventListenerSupport.java:268) at org.apache.commons.lang3.event.EventListenerSupport.<init>(EventListenerSupport.java:144) at org.apache.commons.lang3.event.EventListenerSupport.<init>(EventListenerSupport.java:122) at org.apache.commons.lang3.event.EventListenerSupport.create(EventListenerSupport.java:106) at com.example.MyClient.<init>(ClientProxy.java:55) at com.example.WebSocketSessionManager.onOpen(WebSocketSessionManager.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:71) at org.eclipse.jetty.websocket.jsr356.annotations.OnOpenCallable.call(OnOpenCallable.java:54) at org.eclipse.jetty.websocket.jsr356.annotations.JsrEvents.callOpen(JsrEvents.java:162) at org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver.onConnect(JsrAnnotatedEventDriver.java:185) at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.openSession(AbstractEventDriver.java:220) at org.eclipse.jetty.websocket.jsr356.endpoints.AbstractJsrEventDriver.openSession(AbstractJsrEventDriver.java:104) at org.eclipse.jetty.websocket.common.WebSocketSession.open(WebSocketSession.java:406) at org.eclipse.jetty.websocket.server.WebSocketServerConnection.onOpen(WebSocketServerConnection.java:63) at org.eclipse.jetty.server.HttpConnection.completed(HttpConnection.java:339) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:420) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:606) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:535) at java.lang.Thread.run(Thread.java:745) Michael S. MacFadden Technical Director and Chief Engineer SOLUTE, Inc. 4250 Pacific Highway, Suite 211 San Diego, CA 92110 Office: (619) 758-9900 Cell: (585) 259-0529 [email protected]<mailto:[email protected]> www.solute.us<http://www.solute.us/> CONFIDENTIALITY NOTICE: This e-mail and any attachments are intended solely for the use of the individual or entity to whom it is addressed. It may contain information that is privileged, confidential and exempt, or protected from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any review, use, disclosure, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately and destroy all copies and attachments
_______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
