Finding a remote Bean device, getting an EjbNamingContext in JBoss 7.1

I have a Maven project in which I want to try to integrate-test the EAR submodule. In the integration test submodule, I do the following:

Properties env; Context ctx; env = new Properties(); env.setProperty( "java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory"); env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); env.setProperty( "java.naming.provider.url", "remote://localhost:4447"); env.put(Context.SECURITY_PRINCIPAL, "jboss-user"); env.put(Context.SECURITY_CREDENTIALS, "*******"); ctx = new InitialContext( env ); IBMPFacadeRemote bmpFacade = ( IBMPFacadeRemote ) ctx.lookup( "ejb:DeDomain-ejb-1.0-SNAPSHOT/BMPFacade!de.domain.service.IBMPFacadeRemote"); bmpFacade.executeBMPProcess( model1, model2);//model1 & model2 are some entities 

Problem: when mvn integration-test is called, it ends with the following Exception

 java.lang.ClassCastException: org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to de.domain.service.IBMPFacadeRemote 

Can someone help me solve this problem? Are there any opportunities for integration - test it with Local Bean (maven project uses fault tolerant plugin)?

+4
source share
2 answers

Now it’s hard to say what exactly solved the problem, but I will try to mention all the changes made that solved the problem.

  • Added dependencies in pom.xml

     <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-ejb-client-bom</artifactId> <version>7.1.1.Final</version> <type>pom</type> </dependency> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-jms-client-bom</artifactId> <version>7.1.1.Final</version> <type>pom</type> </dependency> 
  • Changed JNDI search as follows (after changing the expanded name of the EAR & EJB projects)

     IBMPFacadeRemote bmpFacade = ( IBMPFacadeRemote ) ctx.lookup( "ejb:DeDomain-ear/DeDomain-ejb//BMPFacadeBean!de.domain.service.IBMPFacadeRemote"); 
  • Got rid of the EJB maven plugin from the EJB project and some other resources like jndi.properties

It may be worth mentioning that the Properties instance remained the same as in the question stated.

0
source

JNDI properties look weird to me. I have always been successful with the following properties for JBoss:

 java.naming.provider.url=jnp://localhost:1099 java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces jnp.socket.Factory=org.jnp.interfaces.TimedSocketFactory 

Maybe you should double check them.

-1
source

All Articles