[jboss-user] [JNDI and Naming] - Get ejb3 from remote host (jboss 5.1) to jboss 4.x
Michele Furlan
do-not-reply at jboss.com
Mon Jan 16 08:00:28 EST 2012
Michele Furlan [https://community.jboss.org/people/clanfur] created the discussion
"Get ejb3 from remote host (jboss 5.1) to jboss 4.x"
To view the discussion, visit: https://community.jboss.org/message/646964#646964
--------------------------------------------------------------
Hi,
I'm trying to get an ejb3 from a remote host (that uses jboss 5.1) inside jboss 4.x. The code I use is the following:
public void myFunction() {
Properties jndiProps = new Properties();
jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interface");
jndiProps.setProperty(Context.PROVIDER_URL, "jnp://{*host-ip*}:{*host-jndi-port*}");
try {
FooInterface foo = (FooInterface)(new InitialContext(jndiProps)).lookup("{*jndi-name*}");
foo.doSomething();
} catch (Exception e) {
e.printStackTrace();
}
}
But doing that, I get a ClassCastException here "FooInterface foo = (FooInterface)(new InitialContext(jndiProps)).lookup("{*jndi-name*}");":
java.lang.ClassCastException: javax.naming.Reference cannot be cast to my.package.FooInterface
at com.phi.phirxportal.SecondOpinionRequestBean.myFunction(SecondOpinionRequestBean.java:272)
at com.phi.phirxportal.SecondOpinionRequestBean.checkExam(SecondOpinionRequestBean.java:170)
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:597)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
Host ip, jndi name and host jndi port are correct. I can't figure out how to get my FooInterface from a javax.naming.Reference object.
The Reference object toString method returns something like:
Reference Class Name: Proxy for: my.package.FooInterface
Type: ProxyFactoryKey
Content: ProxyFactory/.....
Type: EJB Container Name
Content: jboss.j2ee:ear=xxx.ear,jar=xxx.jar,name=FooBean,service=EJB3
Type: Proxy Factory is Local
Content: false
Type: Remote Business Interface
Content: my.package.FooInterface
Type: Remoting Host URL
Content: socket://hostpcname:3873/?
Is there a way to do that or does it depends on something else (libraries, configuration, jboss version...)?
Thanks in advance.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/646964#646964]
Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120116/94d6cadc/attachment.html
More information about the jboss-user
mailing list