-
1. Re: EJB call from 4.2.3 to 5.1.0?
auth.gabor Nov 1, 2010 2:13 PM (in response to auth.gabor)Hm... any idea?
-
2. Re: EJB call from 4.2.3 to 5.1.0?
wdfink Nov 1, 2010 4:26 PM (in response to auth.gabor)I have a lot of problems to call SLSB's between JBoss 4.x and JBoss5.x.
You might add jbossall-client.jar add to your JB4.x application and use a loader-repository to separate the class loading.
But we decide due to transaction problems to use one server.
Our application is EJB2.x (JBoss4) and EJB3 in JBoss5.
-
3. Re: EJB call from 4.2.3 to 5.1.0?
f_marchioni Nov 2, 2010 3:44 AM (in response to auth.gabor)Have a look at this, from Carlo's blog :http://wolf-71.blogspot.com/2010/02/et-phone-home.html
Hope it helps,
Francesco
-
4. Re: EJB call from 4.2.3 to 5.1.0?
auth.gabor Nov 2, 2010 7:15 AM (in response to f_marchioni)I've tried it, but:
java.lang.ClassCastException: $Proxy139 cannot be cast to hu.package.ServiceRemoteInterface
The code was:
URL[] urls = new URL[2];
urls[0] = Thread.currentThread().getContextClassLoader().getResource("lib/ServiceRemote-interfaces.jar");
urls[1] = new URL("file:///opt/jboss-5.1.0.GA/client/jbossall-client.jar");URLClassLoader urlCl = new URLClassLoader(urls, null);
ClassLoader cl = new AluniteClassLoader(urlCl, ClassLoader.getSystemClassLoader());
ClassLoader previous = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
try
{
String providerUrl = "remote_ip:1099";
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
properties.put(Context.PROVIDER_URL, providerUrl);
InitialContext ic = new InitialContext(properties);ServiceRemoteInterface service = (ServiceRemoteInterface) ic.lookup(className);
} finally
{
Thread.currentThread().setContextClassLoader(previous);
}But... Wolf has called JBoss 4 from JBoss 5, I've tried to call JBoss 5 from JBoss 4...
-
5. Re: EJB call from 4.2.3 to 5.1.0?
auth.gabor Nov 2, 2010 7:16 AM (in response to wdfink)I've tried a 'loader-repository', but it not works...
-
6. Re: EJB call from 4.2.3 to 5.1.0?
wolfc Nov 2, 2010 3:37 PM (in response to auth.gabor)It can not be cast because if you're calling from within AS your interface is not on the system class loader.
Maybe:
ClassLoader previous = Thread.currentThread().getContextClassLoader();
ClassLoader cl = new AluniteClassLoader(urlCl, previous);
Would do the trick. Only put the jbossall-client.jar URL into the urlCl (isolated class loader). I believe Alunite will then pick your interface from the deployed class loader.
At the end of the day it's all a bit tricky and you won't get transaction or security propegation.
-
7. Re: EJB call from 4.2.3 to 5.1.0?
auth.gabor Nov 3, 2010 6:54 AM (in response to wolfc)It works, thank you very much!