EJB Standalone Client Remote Lookup Problem
denramos Feb 14, 2011 12:56 AMAfter spending countless hours searching for a solution I've given up and decided I'll need some help.
I deployed my EJB .jar file in the /farm folder (for clustering) and the clustering works fine for the multiple nodes.
However I run into some problems when testing a node using a standalone test client.
The EJB is located in a remote server (server A) and the client jar file is located in another machine. I execute the client jar file via the command line using java -jar client.jar. However it throws me the following exception.
Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference cannot be cast to <Remote Bean Client>
I've added jbossall-client.jar to my classpath (I've added this in the MANIFEST.MF file of the client.jar file). I haven't been using a legacy version of JBoss, consistently using JBoss 6.
My guess is I haven't packaged my client jar correctly. Currently I have the following in there:
> package1: client + beanRemoteInterface
> META-INF/MANIFEST.MF
The contents of the Client is as follows:
public class Client { public static void main(String[] args) { InitialContext context; Properties properties = new Properties(); properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); properties.put("java.naming.provider.url", "jnp://(ipaddress):1099"); try { context = new InitialContext(properties); BeanRemote remoteBean = (BeanRemote)context.lookup("BeanRemote/remote"); catch (NamingException e){ System.out.println("testing here"); e.printStackTrace(); throw new RuntimeException(e); }
My EJB jar looks like this: (one package)
> Bean
> EntityBean
> BeanLocal
> BeanRemote
Am I suppose to include the remote bean interface with the client jar? I did some research and some people claim it's a class loader issue loading two instances of the same BeanRemote interface. Anyone got any suggestions? I'm really looking to just get a very simple standalone client to test clustering functions.
Thanks in advance!