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.
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)