Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » jboss eqquinox ejb call failed
jboss eqquinox ejb call failed [message #102279] Sat, 01 December 2007 17:21 Go to next message
Valer Roman is currently offline Valer Roman
Messages: 36
Registered: July 2009
Member
Hi

I have deployed RAP application as a war on Jboss
I want to call EJBs through the local interface which are deployed in
an ear on JBoss.

When trying to get an instance of the EJB I have an ClassCastError

Here is the code I use :

InitialContext ctx = new InitialContext();
Object obj = ctx.lookup("TestLocal");
TestLocalHome home = (TestLocalHome) obj;

and the error :

java.lang.ClassCastException: $Proxy85 cannot be cast to
test.interfaces.TestLocalHome

in the file launch.ini of the war I have :

osgi.parentClassloader=app
osgi.contextClassLoaderParent=ccl

Could someonepoint me what is wrong with my classloaders or what the
problem is ?

Thanks for your help
Val
Re: jboss eqquinox ejb call failed [message #102329 is a reply to message #102279] Sun, 02 December 2007 14:15 Go to previous messageGo to next message
Simon Kaegi is currently offline Simon Kaegi
Messages: 381
Registered: July 2009
Senior Member
Hi Val,

My guess is that you have the wrong context class loader set when you're
creating the InitialContext and that you're not exposing (and importing)
your EJB's interfaces. I answered a similar question in the "Equinox for an
enterprise environment" from Nov. 29. If you need some help here please ask
away as it can be a bit tricky to setup correctly.

-Simon

"Val" <valer.roman@softgress.com> wrote in message
news:fismp3$6pp$1@build.eclipse.org...
> Hi
>
> I have deployed RAP application as a war on Jboss
> I want to call EJBs through the local interface which are deployed in
> an ear on JBoss.
>
> When trying to get an instance of the EJB I have an ClassCastError
>
> Here is the code I use :
>
> InitialContext ctx = new InitialContext();
> Object obj = ctx.lookup("TestLocal");
> TestLocalHome home = (TestLocalHome) obj;
>
> and the error :
>
> java.lang.ClassCastException: $Proxy85 cannot be cast to
> test.interfaces.TestLocalHome
>
> in the file launch.ini of the war I have :
>
> osgi.parentClassloader=app
> osgi.contextClassLoaderParent=ccl
>
> Could someonepoint me what is wrong with my classloaders or what the
> problem is ?
>
> Thanks for your help
> Val
Re: jboss eqquinox ejb call failed [message #102356 is a reply to message #102329] Mon, 03 December 2007 04:15 Go to previous messageGo to next message
Valer Roman is currently offline Valer Roman
Messages: 36
Registered: July 2009
Member
Hi

I was trying to do what u explained in that previous post :)
I ended up by making not working even what it worked :)
Any how, I would need some help if possible on the following points :

1) How to access the BridgeServlet from my RAP application.
BridgetServlet class in in the servletbridge.jar in META-INF/lib
folder's war. The problem is when exporting my plugin not at runtime
cause it does not see this class. I guess I should export servletbridge
as an plugin (or framgment plugin) but I do not know exactly how should
I do it
2) how to I create that fragment plugin which contains my ejb interfaces

The idea is that maybe I need some guiding steps :) to put in practice
all this.

I did mention that my EJB's are in an different ear that has nothing
to do with osgi, is just a usual enterprise application exposing some
ejb's which I can not change
All I want is to access those EJB's from my RAP application.

Cheers,
Val

Simon Kaegi wrote:
> Hi Val,
>
> My guess is that you have the wrong context class loader set when you're
> creating the InitialContext and that you're not exposing (and importing)
> your EJB's interfaces. I answered a similar question in the "Equinox for an
> enterprise environment" from Nov. 29. If you need some help here please ask
> away as it can be a bit tricky to setup correctly.
>
> -Simon
>
> "Val" <valer.roman@softgress.com> wrote in message
> news:fismp3$6pp$1@build.eclipse.org...
>> Hi
>>
>> I have deployed RAP application as a war on Jboss
>> I want to call EJBs through the local interface which are deployed in
>> an ear on JBoss.
>>
>> When trying to get an instance of the EJB I have an ClassCastError
>>
>> Here is the code I use :
>>
>> InitialContext ctx = new InitialContext();
>> Object obj = ctx.lookup("TestLocal");
>> TestLocalHome home = (TestLocalHome) obj;
>>
>> and the error :
>>
>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>> test.interfaces.TestLocalHome
>>
>> in the file launch.ini of the war I have :
>>
>> osgi.parentClassloader=app
>> osgi.contextClassLoaderParent=ccl
>>
>> Could someonepoint me what is wrong with my classloaders or what the
>> problem is ?
>>
>> Thanks for your help
>> Val
>
>
Re: jboss eqquinox ejb call failed [message #102373 is a reply to message #102356] Mon, 03 December 2007 05:23 Go to previous messageGo to next message
Valer Roman is currently offline Valer Roman
Messages: 36
Registered: July 2009
Member
I have added my ejb interfaces in the feature.xml as an fragment plugin
At that moment I got this error when starting jboss :

12:21:49,296 INFO [TomcatDeployer] deploy, ctxPath=/wat,
warUrl=.../deploy/at.wat.war/
12:21:51,218 ERROR [STDERR] java.lang.LinkageError:
org/eclipse/osgi/framework/internal/protocol/jar/Handler
12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
12:21:51,218 ERROR [STDERR] at
java.net.URL.getURLStreamHandler(URL.java:1106)
12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath$3.run(URLClassPath.java:331)
12:21:51,218 ERROR [STDERR] at
java.security.AccessController.doPrivileged(Native Method)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath.getResource(URLClassPath.java:167)
12:21:51,218 ERROR [STDERR] at
java.net.URLClassLoader$1.run(URLClassLoader.java:192)
12:21:51,218 ERROR [STDERR] at
java.security.AccessController.doPrivileged(Native Method)
12:21:51,218 ERROR [STDERR] at
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
12:21:51,218 ERROR [STDERR] at
org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
12:21:51,218 ERROR [STDERR] at
java.lang.ClassLoader.loadClass(ClassLoader.java:251)
12:21:51,218 ERROR [STDERR] at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
12:21:51,218 ERROR [STDERR] at
org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
12:21:51,218 ERROR [STDERR] at
java.net.URL.getURLStreamHandler(URL.java:1106)
12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath$3.run(URLClassPath.java:331)
12:21:51,218 ERROR [STDERR] at
java.security.AccessController.doPrivileged(Native Method)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
12:21:51,218 ERROR [STDERR] at
sun.misc.URLClassPath.getResource(URLClassPath.java:167)
12:21:51,218 ERROR [STDERR] at
java.net.URLClassLoader$1.run(URLClassLoader.java:192)
12:21:51,218 ERROR [STDERR] at
java.security.AccessController.doPrivileged(Native Method)
12:21:51,218 ERROR [STDERR] at
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
12:21:51,218 ERROR [STDERR] at
org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
12:21:51,218 ERROR [STDERR] at
java.lang.ClassLoader.loadClass(ClassLoader.java:251)

It seems very strange :)

Val wrote:
> Hi
>
> I was trying to do what u explained in that previous post :)
> I ended up by making not working even what it worked :)
> Any how, I would need some help if possible on the following points :
>
> 1) How to access the BridgeServlet from my RAP application.
> BridgetServlet class in in the servletbridge.jar in META-INF/lib
> folder's war. The problem is when exporting my plugin not at runtime
> cause it does not see this class. I guess I should export servletbridge
> as an plugin (or framgment plugin) but I do not know exactly how should
> I do it
> 2) how to I create that fragment plugin which contains my ejb interfaces
>
> The idea is that maybe I need some guiding steps :) to put in practice
> all this.
>
> I did mention that my EJB's are in an different ear that has nothing
> to do with osgi, is just a usual enterprise application exposing some
> ejb's which I can not change
> All I want is to access those EJB's from my RAP application.
>
> Cheers,
> Val
>
> Simon Kaegi wrote:
>> Hi Val,
>>
>> My guess is that you have the wrong context class loader set when you're
>> creating the InitialContext and that you're not exposing (and importing)
>> your EJB's interfaces. I answered a similar question in the "Equinox for an
>> enterprise environment" from Nov. 29. If you need some help here please ask
>> away as it can be a bit tricky to setup correctly.
>>
>> -Simon
>>
>> "Val" <valer.roman@softgress.com> wrote in message
>> news:fismp3$6pp$1@build.eclipse.org...
>>> Hi
>>>
>>> I have deployed RAP application as a war on Jboss
>>> I want to call EJBs through the local interface which are deployed in
>>> an ear on JBoss.
>>>
>>> When trying to get an instance of the EJB I have an ClassCastError
>>>
>>> Here is the code I use :
>>>
>>> InitialContext ctx = new InitialContext();
>>> Object obj = ctx.lookup("TestLocal");
>>> TestLocalHome home = (TestLocalHome) obj;
>>>
>>> and the error :
>>>
>>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>>> test.interfaces.TestLocalHome
>>>
>>> in the file launch.ini of the war I have :
>>>
>>> osgi.parentClassloader=app
>>> osgi.contextClassLoaderParent=ccl
>>>
>>> Could someonepoint me what is wrong with my classloaders or what the
>>> problem is ?
>>>
>>> Thanks for your help
>>> Val
>>
Re: jboss eqquinox ejb call failed [message #102402 is a reply to message #102373] Mon, 03 December 2007 09:12 Go to previous messageGo to next message
Valer Roman is currently offline Valer Roman
Messages: 36
Registered: July 2009
Member
Now I'm tryong to call remote the ejb to avoid all that class loading thing

Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
Context ctx = null;
try {
ctx = new InitialContext(props);
} catch (NamingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Object obj = null;
try {
obj = ctx.lookup("Affiliate");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TestHome home = (TestHome) PortableRemoteObject.narrow(obj,
TestHome.class);

but still I have this error when narrowing the object to Test

16:03:31,781 ERROR [[equinoxbridgeservlet]] Servlet.service() for
servlet equinoxbridgeservlet threw exception
java.lang.ClassCastException
at
com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow( PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.j ava:137)

I think it should not matter from where is called the ejb interface if
it's remote. My ejb interfaces are shipped together with the plugin as
an usual jar

Thanks,
Val

Val wrote:
> I have added my ejb interfaces in the feature.xml as an fragment plugin
> At that moment I got this error when starting jboss :
>
> 12:21:49,296 INFO [TomcatDeployer] deploy, ctxPath=/wat,
> warUrl=.../deploy/at.wat.war/
> 12:21:51,218 ERROR [STDERR] java.lang.LinkageError:
> org/eclipse/osgi/framework/internal/protocol/jar/Handler
> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
> 12:21:51,218 ERROR [STDERR] at
> java.net.URL.getURLStreamHandler(URL.java:1106)
> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
> 12:21:51,218 ERROR [STDERR] at
> java.security.AccessController.doPrivileged(Native Method)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
> 12:21:51,218 ERROR [STDERR] at
> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
> 12:21:51,218 ERROR [STDERR] at
> java.security.AccessController.doPrivileged(Native Method)
> 12:21:51,218 ERROR [STDERR] at
> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
> 12:21:51,218 ERROR [STDERR] at
> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> 12:21:51,218 ERROR [STDERR] at
> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
> 12:21:51,218 ERROR [STDERR] at
> java.net.URL.getURLStreamHandler(URL.java:1106)
> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
> 12:21:51,218 ERROR [STDERR] at
> java.security.AccessController.doPrivileged(Native Method)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
> 12:21:51,218 ERROR [STDERR] at
> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
> 12:21:51,218 ERROR [STDERR] at
> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
> 12:21:51,218 ERROR [STDERR] at
> java.security.AccessController.doPrivileged(Native Method)
> 12:21:51,218 ERROR [STDERR] at
> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 12:21:51,218 ERROR [STDERR] at
> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
> 12:21:51,218 ERROR [STDERR] at
> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>
> It seems very strange :)
>
> Val wrote:
>> Hi
>>
>> I was trying to do what u explained in that previous post :)
>> I ended up by making not working even what it worked :)
>> Any how, I would need some help if possible on the following points :
>>
>> 1) How to access the BridgeServlet from my RAP application.
>> BridgetServlet class in in the servletbridge.jar in META-INF/lib
>> folder's war. The problem is when exporting my plugin not at runtime
>> cause it does not see this class. I guess I should export servletbridge
>> as an plugin (or framgment plugin) but I do not know exactly how should
>> I do it
>> 2) how to I create that fragment plugin which contains my ejb interfaces
>>
>> The idea is that maybe I need some guiding steps :) to put in practice
>> all this.
>>
>> I did mention that my EJB's are in an different ear that has nothing
>> to do with osgi, is just a usual enterprise application exposing some
>> ejb's which I can not change
>> All I want is to access those EJB's from my RAP application.
>>
>> Cheers,
>> Val
>>
>> Simon Kaegi wrote:
>>> Hi Val,
>>>
>>> My guess is that you have the wrong context class loader set when you're
>>> creating the InitialContext and that you're not exposing (and importing)
>>> your EJB's interfaces. I answered a similar question in the "Equinox for an
>>> enterprise environment" from Nov. 29. If you need some help here please ask
>>> away as it can be a bit tricky to setup correctly.
>>>
>>> -Simon
>>>
>>> "Val" <valer.roman@softgress.com> wrote in message
>>> news:fismp3$6pp$1@build.eclipse.org...
>>>> Hi
>>>>
>>>> I have deployed RAP application as a war on Jboss
>>>> I want to call EJBs through the local interface which are deployed in
>>>> an ear on JBoss.
>>>>
>>>> When trying to get an instance of the EJB I have an ClassCastError
>>>>
>>>> Here is the code I use :
>>>>
>>>> InitialContext ctx = new InitialContext();
>>>> Object obj = ctx.lookup("TestLocal");
>>>> TestLocalHome home = (TestLocalHome) obj;
>>>>
>>>> and the error :
>>>>
>>>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>>>> test.interfaces.TestLocalHome
>>>>
>>>> in the file launch.ini of the war I have :
>>>>
>>>> osgi.parentClassloader=app
>>>> osgi.contextClassLoaderParent=ccl
>>>>
>>>> Could someonepoint me what is wrong with my classloaders or what the
>>>> problem is ?
>>>>
>>>> Thanks for your help
>>>> Val
Re: jboss eqquinox ejb call failed [message #102441 is a reply to message #102402] Mon, 03 December 2007 14:52 Go to previous messageGo to next message
Simon Kaegi is currently offline Simon Kaegi
Messages: 381
Registered: July 2009
Senior Member
Even though you're using a remote interface you still need to narrow to an
interface that your EJB infrastructure knows about.
Try adding the packages for your EJB intrefaces to extendedFrameworkExports
in web.xml.

In your bundle that's going to use these EJBs import this package as well as
org.eclipse.equinox.servletbridge.

Then I'd try something like the following: (note: purely illustrative as I'm
writing this without an ide)

ClassLoader webappClassLoader = BridgeServlet.class.getClassLoader();
ClassLoader currentCCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(webappClassLoad er);
try {
InitialContext ctx = new InitialContext();
Object obj = ctx.lookup("TestLocal");
TestLocalHome home = (TestLocalHome) obj;
....
} finally {
Thread.currentThread().setContextClassLoader(currentCCL );
}

I would leave both osgi.parentClassloader and osgi.contextClassLoaderParent
to their default value. "app" seems to be the best choice.

-Simon

"Val" <valer.roman@softgress.com> wrote in message
news:fj12sa$39c$1@build.eclipse.org...
> Now I'm tryong to call remote the ejb to avoid all that class loading
> thing
>
> Hashtable props = new Hashtable();
> props.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
> props.put(Context.URL_PKG_PREFIXES,
> "org.jboss.naming:org.jnp.interfaces");
> props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
> Context ctx = null;
> try {
> ctx = new InitialContext(props);
> } catch (NamingException e1) {
> // TODO Auto-generated catch block
> e1.printStackTrace();
> }
> Object obj = null;
> try {
> obj = ctx.lookup("Affiliate");
> } catch (NamingException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> TestHome home = (TestHome) PortableRemoteObject.narrow(obj,
> TestHome.class);
>
> but still I have this error when narrowing the object to Test
>
> 16:03:31,781 ERROR [[equinoxbridgeservlet]] Servlet.service() for
> servlet equinoxbridgeservlet threw exception
> java.lang.ClassCastException
> at
> com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow( PortableRemoteObject.java:229)
> at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.j ava:137)
>
> I think it should not matter from where is called the ejb interface if
> it's remote. My ejb interfaces are shipped together with the plugin as
> an usual jar
>
> Thanks,
> Val
>
> Val wrote:
>> I have added my ejb interfaces in the feature.xml as an fragment plugin
>> At that moment I got this error when starting jboss :
>>
>> 12:21:49,296 INFO [TomcatDeployer] deploy, ctxPath=/wat,
>> warUrl=.../deploy/at.wat.war/
>> 12:21:51,218 ERROR [STDERR] java.lang.LinkageError:
>> org/eclipse/osgi/framework/internal/protocol/jar/Handler
>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>> 12:21:51,218 ERROR [STDERR] at
>> java.net.URL.getURLStreamHandler(URL.java:1106)
>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>> 12:21:51,218 ERROR [STDERR] at
>> java.security.AccessController.doPrivileged(Native Method)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>> 12:21:51,218 ERROR [STDERR] at
>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>> 12:21:51,218 ERROR [STDERR] at
>> java.security.AccessController.doPrivileged(Native Method)
>> 12:21:51,218 ERROR [STDERR] at
>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>> 12:21:51,218 ERROR [STDERR] at
>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>> 12:21:51,218 ERROR [STDERR] at
>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>> 12:21:51,218 ERROR [STDERR] at
>> java.net.URL.getURLStreamHandler(URL.java:1106)
>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>> 12:21:51,218 ERROR [STDERR] at
>> java.security.AccessController.doPrivileged(Native Method)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>> 12:21:51,218 ERROR [STDERR] at
>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>> 12:21:51,218 ERROR [STDERR] at
>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>> 12:21:51,218 ERROR [STDERR] at
>> java.security.AccessController.doPrivileged(Native Method)
>> 12:21:51,218 ERROR [STDERR] at
>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>> 12:21:51,218 ERROR [STDERR] at
>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>> 12:21:51,218 ERROR [STDERR] at
>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>
>> It seems very strange :)
>>
>> Val wrote:
>>> Hi
>>>
>>> I was trying to do what u explained in that previous post :)
>>> I ended up by making not working even what it worked :)
>>> Any how, I would need some help if possible on the following points :
>>>
>>> 1) How to access the BridgeServlet from my RAP application.
>>> BridgetServlet class in in the servletbridge.jar in META-INF/lib
>>> folder's war. The problem is when exporting my plugin not at runtime
>>> cause it does not see this class. I guess I should export servletbridge
>>> as an plugin (or framgment plugin) but I do not know exactly how should
>>> I do it
>>> 2) how to I create that fragment plugin which contains my ejb
>>> interfaces
>>>
>>> The idea is that maybe I need some guiding steps :) to put in practice
>>> all this.
>>>
>>> I did mention that my EJB's are in an different ear that has nothing
>>> to do with osgi, is just a usual enterprise application exposing some
>>> ejb's which I can not change
>>> All I want is to access those EJB's from my RAP application.
>>>
>>> Cheers,
>>> Val
>>>
>>> Simon Kaegi wrote:
>>>> Hi Val,
>>>>
>>>> My guess is that you have the wrong context class loader set when
>>>> you're
>>>> creating the InitialContext and that you're not exposing (and
>>>> importing)
>>>> your EJB's interfaces. I answered a similar question in the "Equinox
>>>> for an
>>>> enterprise environment" from Nov. 29. If you need some help here please
>>>> ask
>>>> away as it can be a bit tricky to setup correctly.
>>>>
>>>> -Simon
>>>>
>>>> "Val" <valer.roman@softgress.com> wrote in message
>>>> news:fismp3$6pp$1@build.eclipse.org...
>>>>> Hi
>>>>>
>>>>> I have deployed RAP application as a war on Jboss
>>>>> I want to call EJBs through the local interface which are deployed in
>>>>> an ear on JBoss.
>>>>>
>>>>> When trying to get an instance of the EJB I have an ClassCastError
>>>>>
>>>>> Here is the code I use :
>>>>>
>>>>> InitialContext ctx = new InitialContext();
>>>>> Object obj = ctx.lookup("TestLocal");
>>>>> TestLocalHome home = (TestLocalHome) obj;
>>>>>
>>>>> and the error :
>>>>>
>>>>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>>>>> test.interfaces.TestLocalHome
>>>>>
>>>>> in the file launch.ini of the war I have :
>>>>>
>>>>> osgi.parentClassloader=app
>>>>> osgi.contextClassLoaderParent=ccl
>>>>>
>>>>> Could someonepoint me what is wrong with my classloaders or what the
>>>>> problem is ?
>>>>>
>>>>> Thanks for your help
>>>>> Val
Re: jboss eqquinox ejb call failed [message #102454 is a reply to message #102441] Mon, 03 December 2007 15:42 Go to previous messageGo to next message
Valer Roman is currently offline Valer Roman
Messages: 36
Registered: July 2009
Member
The one point I do not get now is where to use that
extendedFrameworkExports cause my EJBs are in an ear which is not
running as an osgi application, and I see no reason to set it on the
bundle which only uses the EJB's

Simon Kaegi wrote:
> Even though you're using a remote interface you still need to narrow to an
> interface that your EJB infrastructure knows about.
> Try adding the packages for your EJB intrefaces to extendedFrameworkExports
> in web.xml.
>
> In your bundle that's going to use these EJBs import this package as well as
> org.eclipse.equinox.servletbridge.
>
> Then I'd try something like the following: (note: purely illustrative as I'm
> writing this without an ide)
>
> ClassLoader webappClassLoader = BridgeServlet.class.getClassLoader();
> ClassLoader currentCCL = Thread.currentThread().getContextClassLoader();
> Thread.currentThread().setContextClassLoader(webappClassLoad er);
> try {
> InitialContext ctx = new InitialContext();
> Object obj = ctx.lookup("TestLocal");
> TestLocalHome home = (TestLocalHome) obj;
> ...
> } finally {
> Thread.currentThread().setContextClassLoader(currentCCL );
> }
>
> I would leave both osgi.parentClassloader and osgi.contextClassLoaderParent
> to their default value. "app" seems to be the best choice.
>
> -Simon
>
> "Val" <valer.roman@softgress.com> wrote in message
> news:fj12sa$39c$1@build.eclipse.org...
>> Now I'm tryong to call remote the ejb to avoid all that class loading
>> thing
>>
>> Hashtable props = new Hashtable();
>> props.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>> props.put(Context.URL_PKG_PREFIXES,
>> "org.jboss.naming:org.jnp.interfaces");
>> props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>> Context ctx = null;
>> try {
>> ctx = new InitialContext(props);
>> } catch (NamingException e1) {
>> // TODO Auto-generated catch block
>> e1.printStackTrace();
>> }
>> Object obj = null;
>> try {
>> obj = ctx.lookup("Affiliate");
>> } catch (NamingException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>> TestHome home = (TestHome) PortableRemoteObject.narrow(obj,
>> TestHome.class);
>>
>> but still I have this error when narrowing the object to Test
>>
>> 16:03:31,781 ERROR [[equinoxbridgeservlet]] Servlet.service() for
>> servlet equinoxbridgeservlet threw exception
>> java.lang.ClassCastException
>> at
>> com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow( PortableRemoteObject.java:229)
>> at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.j ava:137)
>>
>> I think it should not matter from where is called the ejb interface if
>> it's remote. My ejb interfaces are shipped together with the plugin as
>> an usual jar
>>
>> Thanks,
>> Val
>>
>> Val wrote:
>>> I have added my ejb interfaces in the feature.xml as an fragment plugin
>>> At that moment I got this error when starting jboss :
>>>
>>> 12:21:49,296 INFO [TomcatDeployer] deploy, ctxPath=/wat,
>>> warUrl=.../deploy/at.wat.war/
>>> 12:21:51,218 ERROR [STDERR] java.lang.LinkageError:
>>> org/eclipse/osgi/framework/internal/protocol/jar/Handler
>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.security.AccessController.doPrivileged(Native Method)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.security.AccessController.doPrivileged(Native Method)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.security.AccessController.doPrivileged(Native Method)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>> 12:21:51,218 ERROR [STDERR] at
>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.security.AccessController.doPrivileged(Native Method)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>> 12:21:51,218 ERROR [STDERR] at
>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>> 12:21:51,218 ERROR [STDERR] at
>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>
>>> It seems very strange :)
>>>
>>> Val wrote:
>>>> Hi
>>>>
>>>> I was trying to do what u explained in that previous post :)
>>>> I ended up by making not working even what it worked :)
>>>> Any how, I would need some help if possible on the following points :
>>>>
>>>> 1) How to access the BridgeServlet from my RAP application.
>>>> BridgetServlet class in in the servletbridge.jar in META-INF/lib
>>>> folder's war. The problem is when exporting my plugin not at runtime
>>>> cause it does not see this class. I guess I should export servletbridge
>>>> as an plugin (or framgment plugin) but I do not know exactly how should
>>>> I do it
>>>> 2) how to I create that fragment plugin which contains my ejb
>>>> interfaces
>>>>
>>>> The idea is that maybe I need some guiding steps :) to put in practice
>>>> all this.
>>>>
>>>> I did mention that my EJB's are in an different ear that has nothing
>>>> to do with osgi, is just a usual enterprise application exposing some
>>>> ejb's which I can not change
>>>> All I want is to access those EJB's from my RAP application.
>>>>
>>>> Cheers,
>>>> Val
>>>>
>>>> Simon Kaegi wrote:
>>>>> Hi Val,
>>>>>
>>>>> My guess is that you have the wrong context class loader set when
>>>>> you're
>>>>> creating the InitialContext and that you're not exposing (and
>>>>> importing)
>>>>> your EJB's interfaces. I answered a similar question in the "Equinox
>>>>> for an
>>>>> enterprise environment" from Nov. 29. If you need some help here please
>>>>> ask
>>>>> away as it can be a bit tricky to setup correctly.
>>>>>
>>>>> -Simon
>>>>>
>>>>> "Val" <valer.roman@softgress.com> wrote in message
>>>>> news:fismp3$6pp$1@build.eclipse.org...
>>>>>> Hi
>>>>>>
>>>>>> I have deployed RAP application as a war on Jboss
>>>>>> I want to call EJBs through the local interface which are deployed in
>>>>>> an ear on JBoss.
>>>>>>
>>>>>> When trying to get an instance of the EJB I have an ClassCastError
>>>>>>
>>>>>> Here is the code I use :
>>>>>>
>>>>>> InitialContext ctx = new InitialContext();
>>>>>> Object obj = ctx.lookup("TestLocal");
>>>>>> TestLocalHome home = (TestLocalHome) obj;
>>>>>>
>>>>>> and the error :
>>>>>>
>>>>>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>>>>>> test.interfaces.TestLocalHome
>>>>>>
>>>>>> in the file launch.ini of the war I have :
>>>>>>
>>>>>> osgi.parentClassloader=app
>>>>>> osgi.contextClassLoaderParent=ccl
>>>>>>
>>>>>> Could someonepoint me what is wrong with my classloaders or what the
>>>>>> problem is ?
>>>>>>
>>>>>> Thanks for your help
>>>>>> Val
>
>
Re: jboss eqquinox ejb call failed [message #102468 is a reply to message #102454] Mon, 03 December 2007 16:16 Go to previous messageGo to next message
Simon Kaegi is currently offline Simon Kaegi
Messages: 381
Registered: July 2009
Senior Member
The OSGi environment is normally isolated from the EAR/WAR class loaders so
without adding extendedFrameworkExports the OSGi environment has no way of
seeing your EJB classes. For the bundle that's using the EJBs it still is
required to import the EJB interfaces because that's what you need in order
to share the same class definition. In other words your bundle does not
implicitly have visibility of the EJB as you control what classes/resources
from the app server you want to make visible

-Simon

"Val" <valer.roman@softgress.com> wrote in message
news:fj1po7$sde$1@build.eclipse.org...
> The one point I do not get now is where to use that
> extendedFrameworkExports cause my EJBs are in an ear which is not
> running as an osgi application, and I see no reason to set it on the
> bundle which only uses the EJB's
>
> Simon Kaegi wrote:
>> Even though you're using a remote interface you still need to narrow to
>> an
>> interface that your EJB infrastructure knows about.
>> Try adding the packages for your EJB intrefaces to
>> extendedFrameworkExports
>> in web.xml.
>>
>> In your bundle that's going to use these EJBs import this package as well
>> as
>> org.eclipse.equinox.servletbridge.
>>
>> Then I'd try something like the following: (note: purely illustrative as
>> I'm
>> writing this without an ide)
>>
>> ClassLoader webappClassLoader = BridgeServlet.class.getClassLoader();
>> ClassLoader currentCCL = Thread.currentThread().getContextClassLoader();
>> Thread.currentThread().setContextClassLoader(webappClassLoad er);
>> try {
>> InitialContext ctx = new InitialContext();
>> Object obj = ctx.lookup("TestLocal");
>> TestLocalHome home = (TestLocalHome) obj;
>> ...
>> } finally {
>> Thread.currentThread().setContextClassLoader(currentCCL );
>> }
>>
>> I would leave both osgi.parentClassloader and
>> osgi.contextClassLoaderParent
>> to their default value. "app" seems to be the best choice.
>>
>> -Simon
>>
>> "Val" <valer.roman@softgress.com> wrote in message
>> news:fj12sa$39c$1@build.eclipse.org...
>>> Now I'm tryong to call remote the ejb to avoid all that class loading
>>> thing
>>>
>>> Hashtable props = new Hashtable();
>>> props.put(Context.INITIAL_CONTEXT_FACTORY,
>>> "org.jnp.interfaces.NamingContextFactory");
>>> props.put(Context.URL_PKG_PREFIXES,
>>> "org.jboss.naming:org.jnp.interfaces");
>>> props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>>> Context ctx = null;
>>> try {
>>> ctx = new InitialContext(props);
>>> } catch (NamingException e1) {
>>> // TODO Auto-generated catch block
>>> e1.printStackTrace();
>>> }
>>> Object obj = null;
>>> try {
>>> obj = ctx.lookup("Affiliate");
>>> } catch (NamingException e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> }
>>> TestHome home = (TestHome) PortableRemoteObject.narrow(obj,
>>> TestHome.class);
>>>
>>> but still I have this error when narrowing the object to Test
>>>
>>> 16:03:31,781 ERROR [[equinoxbridgeservlet]] Servlet.service() for
>>> servlet equinoxbridgeservlet threw exception
>>> java.lang.ClassCastException
>>> at
>>> com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow( PortableRemoteObject.java:229)
>>> at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.j ava:137)
>>>
>>> I think it should not matter from where is called the ejb interface if
>>> it's remote. My ejb interfaces are shipped together with the plugin as
>>> an usual jar
>>>
>>> Thanks,
>>> Val
>>>
>>> Val wrote:
>>>> I have added my ejb interfaces in the feature.xml as an fragment plugin
>>>> At that moment I got this error when starting jboss :
>>>>
>>>> 12:21:49,296 INFO [TomcatDeployer] deploy, ctxPath=/wat,
>>>> warUrl=.../deploy/at.wat.war/
>>>> 12:21:51,218 ERROR [STDERR] java.lang.LinkageError:
>>>> org/eclipse/osgi/framework/internal/protocol/jar/Handler
>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.security.AccessController.doPrivileged(Native Method)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.security.AccessController.doPrivileged(Native Method)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.security.AccessController.doPrivileged(Native Method)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.security.AccessController.doPrivileged(Native Method)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>>> 12:21:51,218 ERROR [STDERR] at
>>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>>
>>>> It seems very strange :)
>>>>
>>>> Val wrote:
>>>>> Hi
>>>>>
>>>>> I was trying to do what u explained in that previous post :)
>>>>> I ended up by making not working even what it worked :)
>>>>> Any how, I would need some help if possible on the following points
>>>>> :
>>>>>
>>>>> 1) How to access the BridgeServlet from my RAP application.
>>>>> BridgetServlet class in in the servletbridge.jar in META-INF/lib
>>>>> folder's war. The problem is when exporting my plugin not at runtime
>>>>> cause it does not see this class. I guess I should export
>>>>> servletbridge
>>>>> as an plugin (or framgment plugin) but I do not know exactly how
>>>>> should
>>>>> I do it
>>>>> 2) how to I create that fragment plugin which contains my ejb
>>>>> interfaces
>>>>>
>>>>> The idea is that maybe I need some guiding steps :) to put in
>>>>> practice
>>>>> all this.
>>>>>
>>>>> I did mention that my EJB's are in an different ear that has nothing
>>>>> to do with osgi, is just a usual enterprise application exposing some
>>>>> ejb's which I can not change
>>>>> All I want is to access those EJB's from my RAP application.
>>>>>
>>>>> Cheers,
>>>>> Val
>>>>>
>>>>> Simon Kaegi wrote:
>>>>>> Hi Val,
>>>>>>
>>>>>> My guess is that you have the wrong context class loader set when
>>>>>> you're
>>>>>> creating the InitialContext and that you're not exposing (and
>>>>>> importing)
>>>>>> your EJB's interfaces. I answered a similar question in the "Equinox
>>>>>> for an
>>>>>> enterprise environment" from Nov. 29. If you need some help here
>>>>>> please
>>>>>> ask
>>>>>> away as it can be a bit tricky to setup correctly.
>>>>>>
>>>>>> -Simon
>>>>>>
>>>>>> "Val" <valer.roman@softgress.com> wrote in message
>>>>>> news:fismp3$6pp$1@build.eclipse.org...
>>>>>>> Hi
>>>>>>>
>>>>>>> I have deployed RAP application as a war on Jboss
>>>>>>> I want to call EJBs through the local interface which are deployed
>>>>>>> in
>>>>>>> an ear on JBoss.
>>>>>>>
>>>>>>> When trying to get an instance of the EJB I have an ClassCastError
>>>>>>>
>>>>>>> Here is the code I use :
>>>>>>>
>>>>>>> InitialContext ctx = new InitialContext();
>>>>>>> Object obj = ctx.lookup("TestLocal");
>>>>>>> TestLocalHome home = (TestLocalHome) obj;
>>>>>>>
>>>>>>> and the error :
>>>>>>>
>>>>>>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>>>>>>> test.interfaces.TestLocalHome
>>>>>>>
>>>>>>> in the file launch.ini of the war I have :
>>>>>>>
>>>>>>> osgi.parentClassloader=app
>>>>>>> osgi.contextClassLoaderParent=ccl
>>>>>>>
>>>>>>> Could someonepoint me what is wrong with my classloaders or what the
>>>>>>> problem is ?
>>>>>>>
>>>>>>> Thanks for your help
>>>>>>> Val
>>
>>
Re: jboss eqquinox ejb call failed [message #102481 is a reply to message #102468] Mon, 03 December 2007 18:05 Go to previous messageGo to next message
Valer Roman is currently offline Valer Roman
Messages: 36
Registered: July 2009
Member
ok i see what extendedFrameworkExports does it exports my ejb interface
classes from the jboss calssloaders to the osgi.
unfortunately I still can not make my thing work I have the same error
as at beginning : $Proxy85 cannot be cast to ...TestHome
Maybe is just my mistake here that I can not get it work, but still if u
thing u need some information from me that could make me advance please
ask me

Thanks,
Val

Simon Kaegi wrote:
> The OSGi environment is normally isolated from the EAR/WAR class loaders so
> without adding extendedFrameworkExports the OSGi environment has no way of
> seeing your EJB classes. For the bundle that's using the EJBs it still is
> required to import the EJB interfaces because that's what you need in order
> to share the same class definition. In other words your bundle does not
> implicitly have visibility of the EJB as you control what classes/resources
> from the app server you want to make visible
>
> -Simon
>
> "Val" <valer.roman@softgress.com> wrote in message
> news:fj1po7$sde$1@build.eclipse.org...
>> The one point I do not get now is where to use that
>> extendedFrameworkExports cause my EJBs are in an ear which is not
>> running as an osgi application, and I see no reason to set it on the
>> bundle which only uses the EJB's
>>
>> Simon Kaegi wrote:
>>> Even though you're using a remote interface you still need to narrow to
>>> an
>>> interface that your EJB infrastructure knows about.
>>> Try adding the packages for your EJB intrefaces to
>>> extendedFrameworkExports
>>> in web.xml.
>>>
>>> In your bundle that's going to use these EJBs import this package as well
>>> as
>>> org.eclipse.equinox.servletbridge.
>>>
>>> Then I'd try something like the following: (note: purely illustrative as
>>> I'm
>>> writing this without an ide)
>>>
>>> ClassLoader webappClassLoader = BridgeServlet.class.getClassLoader();
>>> ClassLoader currentCCL = Thread.currentThread().getContextClassLoader();
>>> Thread.currentThread().setContextClassLoader(webappClassLoad er);
>>> try {
>>> InitialContext ctx = new InitialContext();
>>> Object obj = ctx.lookup("TestLocal");
>>> TestLocalHome home = (TestLocalHome) obj;
>>> ...
>>> } finally {
>>> Thread.currentThread().setContextClassLoader(currentCCL );
>>> }
>>>
>>> I would leave both osgi.parentClassloader and
>>> osgi.contextClassLoaderParent
>>> to their default value. "app" seems to be the best choice.
>>>
>>> -Simon
>>>
>>> "Val" <valer.roman@softgress.com> wrote in message
>>> news:fj12sa$39c$1@build.eclipse.org...
>>>> Now I'm tryong to call remote the ejb to avoid all that class loading
>>>> thing
>>>>
>>>> Hashtable props = new Hashtable();
>>>> props.put(Context.INITIAL_CONTEXT_FACTORY,
>>>> "org.jnp.interfaces.NamingContextFactory");
>>>> props.put(Context.URL_PKG_PREFIXES,
>>>> "org.jboss.naming:org.jnp.interfaces");
>>>> props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>>>> Context ctx = null;
>>>> try {
>>>> ctx = new InitialContext(props);
>>>> } catch (NamingException e1) {
>>>> // TODO Auto-generated catch block
>>>> e1.printStackTrace();
>>>> }
>>>> Object obj = null;
>>>> try {
>>>> obj = ctx.lookup("Affiliate");
>>>> } catch (NamingException e) {
>>>> // TODO Auto-generated catch block
>>>> e.printStackTrace();
>>>> }
>>>> TestHome home = (TestHome) PortableRemoteObject.narrow(obj,
>>>> TestHome.class);
>>>>
>>>> but still I have this error when narrowing the object to Test
>>>>
>>>> 16:03:31,781 ERROR [[equinoxbridgeservlet]] Servlet.service() for
>>>> servlet equinoxbridgeservlet threw exception
>>>> java.lang.ClassCastException
>>>> at
>>>> com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow( PortableRemoteObject.java:229)
>>>> at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.j ava:137)
>>>>
>>>> I think it should not matter from where is called the ejb interface if
>>>> it's remote. My ejb interfaces are shipped together with the plugin as
>>>> an usual jar
>>>>
>>>> Thanks,
>>>> Val
>>>>
>>>> Val wrote:
>>>>> I have added my ejb interfaces in the feature.xml as an fragment plugin
>>>>> At that moment I got this error when starting jboss :
>>>>>
>>>>> 12:21:49,296 INFO [TomcatDeployer] deploy, ctxPath=/wat,
>>>>> warUrl=.../deploy/at.wat.war/
>>>>> 12:21:51,218 ERROR [STDERR] java.lang.LinkageError:
>>>>> org/eclipse/osgi/framework/internal/protocol/jar/Handler
>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>>>
>>>>> It seems very strange :)
>>>>>
>>>>> Val wrote:
>>>>>> Hi
>>>>>>
>>>>>> I was trying to do what u explained in that previous post :)
>>>>>> I ended up by making not working even what it worked :)
>>>>>> Any how, I would need some help if possible on the following points
>>>>>> :
>>>>>>
>>>>>> 1) How to access the BridgeServlet from my RAP application.
>>>>>> BridgetServlet class in in the servletbridge.jar in META-INF/lib
>>>>>> folder's war. The problem is when exporting my plugin not at runtime
>>>>>> cause it does not see this class. I guess I should export
>>>>>> servletbridge
>>>>>> as an plugin (or framgment plugin) but I do not know exactly how
>>>>>> should
>>>>>> I do it
>>>>>> 2) how to I create that fragment plugin which contains my ejb
>>>>>> interfaces
>>>>>>
>>>>>> The idea is that maybe I need some guiding steps :) to put in
>>>>>> practice
>>>>>> all this.
>>>>>>
>>>>>> I did mention that my EJB's are in an different ear that has nothing
>>>>>> to do with osgi, is just a usual enterprise application exposing some
>>>>>> ejb's which I can not change
>>>>>> All I want is to access those EJB's from my RAP application.
>>>>>>
>>>>>> Cheers,
>>>>>> Val
>>>>>>
>>>>>> Simon Kaegi wrote:
>>>>>>> Hi Val,
>>>>>>>
>>>>>>> My guess is that you have the wrong context class loader set when
>>>>>>> you're
>>>>>>> creating the InitialContext and that you're not exposing (and
>>>>>>> importing)
>>>>>>> your EJB's interfaces. I answered a similar question in the "Equinox
>>>>>>> for an
>>>>>>> enterprise environment" from Nov. 29. If you need some help here
>>>>>>> please
>>>>>>> ask
>>>>>>> away as it can be a bit tricky to setup correctly.
>>>>>>>
>>>>>>> -Simon
>>>>>>>
>>>>>>> "Val" <valer.roman@softgress.com> wrote in message
>>>>>>> news:fismp3$6pp$1@build.eclipse.org...
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> I have deployed RAP application as a war on Jboss
>>>>>>>> I want to call EJBs through the local interface which are deployed
>>>>>>>> in
>>>>>>>> an ear on JBoss.
>>>>>>>>
>>>>>>>> When trying to get an instance of the EJB I have an ClassCastError
>>>>>>>>
>>>>>>>> Here is the code I use :
>>>>>>>>
>>>>>>>> InitialContext ctx = new InitialContext();
>>>>>>>> Object obj = ctx.lookup("TestLocal");
>>>>>>>> TestLocalHome home = (TestLocalHome) obj;
>>>>>>>>
>>>>>>>> and the error :
>>>>>>>>
>>>>>>>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>>>>>>>> test.interfaces.TestLocalHome
>>>>>>>>
>>>>>>>> in the file launch.ini of the war I have :
>>>>>>>>
>>>>>>>> osgi.parentClassloader=app
>>>>>>>> osgi.contextClassLoaderParent=ccl
>>>>>>>>
>>>>>>>> Could someonepoint me what is wrong with my classloaders or what the
>>>>>>>> problem is ?
>>>>>>>>
>>>>>>>> Thanks for your help
>>>>>>>> Val
>>>
>
>
Re: jboss eqquinox ejb call failed [message #102494 is a reply to message #102481] Tue, 04 December 2007 11:25 Go to previous message
Valer Roman is currently offline Valer Roman
Messages: 36
Registered: July 2009
Member
I have managed to get it work somehow without using the
extendedFrameworkExports parameter.
I have added some jboss libraries to support EJB remote interface
calling on the client-side (RAP application)
Actually I was rather lucky to find it, I was testing that the call to
ejb on another j2ee server is working and that forced me to add some
missing libraries for the remote calling. When switching back to
localhost I saw that is working also. So this is how I had luck fixing it

Thanks for everything

Val wrote:
> ok i see what extendedFrameworkExports does it exports my ejb interface
> classes from the jboss calssloaders to the osgi.
> unfortunately I still can not make my thing work I have the same error
> as at beginning : $Proxy85 cannot be cast to ...TestHome
> Maybe is just my mistake here that I can not get it work, but still if u
> thing u need some information from me that could make me advance please
> ask me
>
> Thanks,
> Val
>
> Simon Kaegi wrote:
>> The OSGi environment is normally isolated from the EAR/WAR class loaders so
>> without adding extendedFrameworkExports the OSGi environment has no way of
>> seeing your EJB classes. For the bundle that's using the EJBs it still is
>> required to import the EJB interfaces because that's what you need in order
>> to share the same class definition. In other words your bundle does not
>> implicitly have visibility of the EJB as you control what classes/resources
>> from the app server you want to make visible
>>
>> -Simon
>>
>> "Val" <valer.roman@softgress.com> wrote in message
>> news:fj1po7$sde$1@build.eclipse.org...
>>> The one point I do not get now is where to use that
>>> extendedFrameworkExports cause my EJBs are in an ear which is not
>>> running as an osgi application, and I see no reason to set it on the
>>> bundle which only uses the EJB's
>>>
>>> Simon Kaegi wrote:
>>>> Even though you're using a remote interface you still need to narrow to
>>>> an
>>>> interface that your EJB infrastructure knows about.
>>>> Try adding the packages for your EJB intrefaces to
>>>> extendedFrameworkExports
>>>> in web.xml.
>>>>
>>>> In your bundle that's going to use these EJBs import this package as well
>>>> as
>>>> org.eclipse.equinox.servletbridge.
>>>>
>>>> Then I'd try something like the following: (note: purely illustrative as
>>>> I'm
>>>> writing this without an ide)
>>>>
>>>> ClassLoader webappClassLoader = BridgeServlet.class.getClassLoader();
>>>> ClassLoader currentCCL = Thread.currentThread().getContextClassLoader();
>>>> Thread.currentThread().setContextClassLoader(webappClassLoad er);
>>>> try {
>>>> InitialContext ctx = new InitialContext();
>>>> Object obj = ctx.lookup("TestLocal");
>>>> TestLocalHome home = (TestLocalHome) obj;
>>>> ...
>>>> } finally {
>>>> Thread.currentThread().setContextClassLoader(currentCCL );
>>>> }
>>>>
>>>> I would leave both osgi.parentClassloader and
>>>> osgi.contextClassLoaderParent
>>>> to their default value. "app" seems to be the best choice.
>>>>
>>>> -Simon
>>>>
>>>> "Val" <valer.roman@softgress.com> wrote in message
>>>> news:fj12sa$39c$1@build.eclipse.org...
>>>>> Now I'm tryong to call remote the ejb to avoid all that class loading
>>>>> thing
>>>>>
>>>>> Hashtable props = new Hashtable();
>>>>> props.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>> "org.jnp.interfaces.NamingContextFactory");
>>>>> props.put(Context.URL_PKG_PREFIXES,
>>>>> "org.jboss.naming:org.jnp.interfaces");
>>>>> props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>>>>> Context ctx = null;
>>>>> try {
>>>>> ctx = new InitialContext(props);
>>>>> } catch (NamingException e1) {
>>>>> // TODO Auto-generated catch block
>>>>> e1.printStackTrace();
>>>>> }
>>>>> Object obj = null;
>>>>> try {
>>>>> obj = ctx.lookup("Affiliate");
>>>>> } catch (NamingException e) {
>>>>> // TODO Auto-generated catch block
>>>>> e.printStackTrace();
>>>>> }
>>>>> TestHome home = (TestHome) PortableRemoteObject.narrow(obj,
>>>>> TestHome.class);
>>>>>
>>>>> but still I have this error when narrowing the object to Test
>>>>>
>>>>> 16:03:31,781 ERROR [[equinoxbridgeservlet]] Servlet.service() for
>>>>> servlet equinoxbridgeservlet threw exception
>>>>> java.lang.ClassCastException
>>>>> at
>>>>> com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow( PortableRemoteObject.java:229)
>>>>> at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.j ava:137)
>>>>>
>>>>> I think it should not matter from where is called the ejb interface if
>>>>> it's remote. My ejb interfaces are shipped together with the plugin as
>>>>> an usual jar
>>>>>
>>>>> Thanks,
>>>>> Val
>>>>>
>>>>> Val wrote:
>>>>>> I have added my ejb interfaces in the feature.xml as an fragment plugin
>>>>>> At that moment I got this error when starting jboss :
>>>>>>
>>>>>> 12:21:49,296 INFO [TomcatDeployer] deploy, ctxPath=/wat,
>>>>>> warUrl=.../deploy/at.wat.war/
>>>>>> 12:21:51,218 ERROR [STDERR] java.lang.LinkageError:
>>>>>> org/eclipse/osgi/framework/internal/protocol/jar/Handler
>>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>>>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
>>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
>>>>>> 12:21:51,218 ERROR [STDERR] at java.lang.Class.forName(Class.java:169)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.util.SecureAction.forName(SecureA ction.java:335)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.getBuiltIn(StreamHandlerFactory.java:70)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createInternalURLStreamHandler(StreamHandlerFactory.ja va:113)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLStreamHandler(StreamHandlerFactory.java:100)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.net.URL.getURLStreamHandler(URL.java:1106)
>>>>>> 12:21:51,218 ERROR [STDERR] at java.net.URL.<init>(URL.java:393)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:553)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath$3.run(URLClassPath.java:331)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> sun.misc.URLClassPath.getResource(URLClassPath.java:167)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.net.URLClassLoader$1.run(URLClassLoader.java:192)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> org.eclipse.equinox.servletbridge.FrameworkLauncher$ChildFir stURLClassLoader.loadClass(FrameworkLauncher.java:742)
>>>>>> 12:21:51,218 ERROR [STDERR] at
>>>>>> java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>>>>
>>>>>> It seems very strange :)
>>>>>>
>>>>>> Val wrote:
>>>>>>> Hi
>>>>>>>
>>>>>>> I was trying to do what u explained in that previous post :)
>>>>>>> I ended up by making not working even what it worked :)
>>>>>>> Any how, I would need some help if possible on the following points
>>>>>>> :
>>>>>>>
>>>>>>> 1) How to access the BridgeServlet from my RAP application.
>>>>>>> BridgetServlet class in in the servletbridge.jar in META-INF/lib
>>>>>>> folder's war. The problem is when exporting my plugin not at runtime
>>>>>>> cause it does not see this class. I guess I should export
>>>>>>> servletbridge
>>>>>>> as an plugin (or framgment plugin) but I do not know exactly how
>>>>>>> should
>>>>>>> I do it
>>>>>>> 2) how to I create that fragment plugin which contains my ejb
>>>>>>> interfaces
>>>>>>>
>>>>>>> The idea is that maybe I need some guiding steps :) to put in
>>>>>>> practice
>>>>>>> all this.
>>>>>>>
>>>>>>> I did mention that my EJB's are in an different ear that has nothing
>>>>>>> to do with osgi, is just a usual enterprise application exposing some
>>>>>>> ejb's which I can not change
>>>>>>> All I want is to access those EJB's from my RAP application.
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Val
>>>>>>>
>>>>>>> Simon Kaegi wrote:
>>>>>>>> Hi Val,
>>>>>>>>
>>>>>>>> My guess is that you have the wrong context class loader set when
>>>>>>>> you're
>>>>>>>> creating the InitialContext and that you're not exposing (and
>>>>>>>> importing)
>>>>>>>> your EJB's interfaces. I answered a similar question in the "Equinox
>>>>>>>> for an
>>>>>>>> enterprise environment" from Nov. 29. If you need some help here
>>>>>>>> please
>>>>>>>> ask
>>>>>>>> away as it can be a bit tricky to setup correctly.
>>>>>>>>
>>>>>>>> -Simon
>>>>>>>>
>>>>>>>> "Val" <valer.roman@softgress.com> wrote in message
>>>>>>>> news:fismp3$6pp$1@build.eclipse.org...
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> I have deployed RAP application as a war on Jboss
>>>>>>>>> I want to call EJBs through the local interface which are deployed
>>>>>>>>> in
>>>>>>>>> an ear on JBoss.
>>>>>>>>>
>>>>>>>>> When trying to get an instance of the EJB I have an ClassCastError
>>>>>>>>>
>>>>>>>>> Here is the code I use :
>>>>>>>>>
>>>>>>>>> InitialContext ctx = new InitialContext();
>>>>>>>>> Object obj = ctx.lookup("TestLocal");
>>>>>>>>> TestLocalHome home = (TestLocalHome) obj;
>>>>>>>>>
>>>>>>>>> and the error :
>>>>>>>>>
>>>>>>>>> java.lang.ClassCastException: $Proxy85 cannot be cast to
>>>>>>>>> test.interfaces.TestLocalHome
>>>>>>>>>
>>>>>>>>> in the file launch.ini of the war I have :
>>>>>>>>>
>>>>>>>>> osgi.parentClassloader=app
>>>>>>>>> osgi.contextClassLoaderParent=ccl
>>>>>>>>>
>>>>>>>>> Could someonepoint me what is wrong with my classloaders or what the
>>>>>>>>> problem is ?
>>>>>>>>>
>>>>>>>>> Thanks for your help
>>>>>>>>> Val
>>
Previous Topic:Help with a Design Pattern: Service interfaces separation from implementation
Next Topic:OSGi/Equinox on Java ME CLDC 1.1 IMP 1.0
Goto Forum:
  


Current Time: Sat Aug 30 08:36:25 EDT 2014

Powered by FUDForum. Page generated in 0.02162 seconds