I have a Maven project, in which I want to try integration-testing an EAR sub-module.
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
The problem: when calling mvn integration-test it ends up with the following Exception
java.lang.ClassCastException: org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to de.domain.service.IBMPFacadeRemote
Could someone help me to solve this problem? Are there any possibilities to integration-test this using a Local Bean (the maven project uses the failsafe-plugin)?
It is now hard to say what exactly solved the problem, but I will try to mention all made changes that solved the problem.
Added to the pom.xml the dependencies
Changed the JNDI lookup as follows (after changing the deployed name of the EAR&EJB projects)
Got rid of the EJB maven plugin from the EJB Project & of some other resources, like
jndi.propertiesProbably it is worth mentioning, that the
Propertiesinstance remained the same as in the stated in the question.