[jboss-user] [EJB/JBoss] - ClassCastException $Proxy0 from within Java Web Start

kaiho do-not-reply at jboss.com
Wed Nov 22 14:07:12 EST 2006


Hi,

I'm using JBoss 4.0.4 and Java 5 for writing an EJB 3-Client in Eclipse RCP 3.2.1, that is deployed via Java Web Start. I've got two plugins/JARs (1. RCP client/EJB remote interfaces and 2. JBoss/JEE libraries), that are bundled as a feature. When starting the Eclipse product everything is fine. But when the product is run via Web Start, there is a problem. Although the client starts, an exception is thrown when trying to communicate with an EJB. The last line of this code snippet javax.naming.Context c = new javax.naming.InitialContext();
  | Object temp = c.lookup("ArtikelverwaltungBean/remote");
  | avr = (ArtikelverwaltungRemote) temp;
  | //avr = (ArtikelverwaltungRemote) PortableRemoteObject.narrow(temp, ArtikelverwaltungRemote.class);
throws this exception java.lang.ClassCastException: $Proxy0
  | 	at client.editors.HerstellerEditorData.<init>(HerstellerEditorData.java:68)
  | 	at client.editors.HerstellerEditorData.<init>(HerstellerEditorData.java:22)
  | 	at client.actions.HerstellerEditorAction.run(HerstellerEditorAction.java:44)
  | 	at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
  | 	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
  | 	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
  | 	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441)
  | 	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
  | 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
  | 	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3166)
  | 	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2842)
  | 	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
  | 	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
  | 	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
  | 	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
  | 	at de.iwi.wws.client.ercp.main.Application.run(Application.java:24)
  | 	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
  | 	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
  | 	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
  | 	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
  | 	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
  | 	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
  | 	at org.eclipse.core.launcher.WebStartMain.basicRun(WebStartMain.java:59)
  | 	at org.eclipse.core.launcher.Main.run(Main.java:977)
  | 	at org.eclipse.core.launcher.WebStartMain.main(WebStartMain.java:40)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	at com.sun.javaws.Launcher.executeApplication(Launcher.java:1154)
  | 	at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1101)
  | 	at com.sun.javaws.Launcher.continueLaunch(Launcher.java:944)
  | 	at com.sun.javaws.Launcher.handleApplicationDesc(Launcher.java:515)
  | 	at com.sun.javaws.Launcher.handleLaunchFile(Launcher.java:218)
  | 	at com.sun.javaws.Launcher.run(Launcher.java:165)
  | 	at java.lang.Thread.run(Thread.java:595)
and it makes no difference wheter I narrow the returned object or not.

In the JBoss forums can be read that this error (ClassCastException $Proxy0) is most likely a class loading problem. "The cast will only work if you are casting to a class/interface loaded with the same classloader." (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=45871)

I'm not familiar with the interna of Web Start. Does anybody has an idea to overcome this problem? 

By the way, this "trick" does not work: Thread.currentThread().setContextClassLoader(ArtikelverwaltungRemote.class.getClassLoader());

Thank you for your help!
Kai

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3987974#3987974

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3987974



More information about the jboss-user mailing list