Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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 <macfadden.michael@xxxxxxxxx>
Reply-To: JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Date: Sunday, August 24, 2014 at 8:52 PM
To: "jetty-users@xxxxxxxxxxx" <jetty-users@xxxxxxxxxxx>
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
macfadden.michael@xxxxxxxxx

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


Back to the top