[JBoss-user] [EJB/JBoss] - Re: ClassCastException on PortableRemoteObject.narrow()

2005-12-02 Thread PitPalme
Hi, thanks for replying.

JBoss versions I've tested with:

4.0.1sp1
4.0.3sp1

About the client: one is a Servlet, the other one a MDB.

The MDB is the main client, the servlet I've just create to continue testing at 
home, where I can't make use of the MDB, as I can't send a message to it (it's 
not a JMS message it works on).

I've meanwhile found 
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=64201
and therein 
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases
and
http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

So I guess the Servlet will not work at any time, which is something I could 
live with (at least I wouldn't know why I'd really *need* the Servlet being 
able to load the business object in a different ear). But not being able to get 
the RemoteObject from a different EAR when calling from the MDB is a show 
stopper for me, because it would require me to shut down MDB-service every time 
one of the many enterprise applications that should be accessed through the MDB 
deploys an update :-/

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

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


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [EJB/JBoss] - ClassCastException on PortableRemoteObject.narrow()

2005-12-01 Thread PitPalme
Hello,

I've got a ClassCastException problem when trying to get the correct object 
instance using InitialContext.lookup() and PortableRemoteObject.narrow().

The situation is me having two applications, one carrying the SessionBean(s), 
the other one a central MessageDrivenBean. While the business objects 
repesented by the SessionBean-application might be updated from time to time 
the MDB-application should be more or less "final". I therefore decided to 
split them into the two applications, especially as further applications which 
should be accessed through the MDB might follow, and I don't want to and can't 
redeploy *all* Beans whenever a little thing in one business SessionBean 
changes.

I therefore do a 


  | Object objRef;
  | InitialContext ctx = new InitialContext();
  | objRef = ctx.lookup("ejb/MyBean");
  | 

and get a "$ProxyXX" object back which is implementing correct remote Home 
interface 'MyBeanHome' (I played a little with reflections to gather 
information about Interfaces and methods).

Now if I'm trying 


  | MyBeanHome tmp;
  | tmp = (MyBeanHome) PortableRemoteObject.narrow(objRef, MyBeanHome.class);
  | 

I get a ClassCastException; even wth


  | Object tmp;
  | tmp = PortableRemoteObject.narrow(objRef, MyBeanHome.class);
  | 

Using


  | Obj tmp;
  | tmp = objRef.getClass().getMethod("create", null).invoke(objRef, null);
  | 

'tmp' contains an object implementing Interface 'MyBean', which indicates 
'objRef' in fact contains an object implementing 'MyBeanHome' and it's 
'create()' knows what to do.

Sadly I can't cast this 'tmp' to 'MyBean' for invoking my 'dispose(...)' method 
on it. I get a ClassCastException then as well.


  | String tmp2;
  | tmp2 = tmp.getClass().getMethod("dispose", new Class[] {...}).invoke(tmp, 
new Object[] {...});
  | 

Gives me the correct result in 'tmp2', but I can't believe using reflections 
all the way along is the way to go; I'd expect 'PortableRemoteObject.narrow()' 
and having correctly typed object instances to be the intended solution.

Can anybody help me on this issue and tell my why my $ProxyXX-objects don't 
"cooperate" and behave as I'd expect them to do?

Thanks in advance,
Peter

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

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


---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user