-
1. Re: Cannot use JNDI lookup in Arquillian
aslak Dec 14, 2011 8:37 AM (in response to canhhiep)try using @EJB.mappedName=
-
2. Re: Cannot use JNDI lookup in Arquillian
canhhiep Dec 14, 2011 10:36 PM (in response to aslak)Thanks Aslak for your answer but it seems not working. I am using @EJB(mappedName="MyManagerBean") and add @Stateless(mappedName="MyManagerBean") in MyManagerBean class but it does not work.
I also try to get that object by using JNDI name like:
Context ic = getContext();
obj = ic.lookup("java:global/earName/jarName/beanName");
//.........
Below is getContext() method:
Context getContext() throws NamingException {
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.as.naming.InitialContextFactory");
return new InitialContext(ht);
}but the exception is thrown. Could you please give me some idea to fix it?
Thanks
-
3. Re: Cannot use JNDI lookup in Arquillian
aslak Dec 15, 2011 11:12 AM (in response to canhhiep)When you run the test, in eht ejboss as 7 console output you should see where the EJB is bound.. Does it not work to put on of those jndi names in EJB.mappedName ?
-
4. Re: Cannot use JNDI lookup in Arquillian
canhhiep Dec 15, 2011 11:39 AM (in response to aslak)Yes, Aslak. I try to use these JNDI names:
java:global/projectname/aa-api/MyBean!com.projectname.aa.api.MyInterface
java:app/aa-api/MyBean!com.projectname.aa.api.MyInterface
java:module/MyBean!com.projectname.aa.api.MyInterface
java:global/projectname/aa-api/MyInterface
java:app/aa-api/MyInterface
java:module/MyInterface
But all of them do not work (MyBean still null). I am wondering that I am using the right annotation for deployment method or not. Currently I am using :
@Deployment(testable=false)
public static EnterpriseArchive createDeployment() {...}
I think I should change testable to true instead of false, right?. But when I change it to true. The exception is thrown (after both arquillian-service and my ear was deployed successful) . Below is the exception:
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 69.044 sec <<< FAILURE!
23:36:14,275 INFO [org.jboss.as.osgi] (MSC service thread 1-2) JBAS011922: Unregister module: Module "deployment.arquillian-service:main" f
rom Service Module Loader
23:36:14,277 ERROR [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-2) Cannot find bundle associated with module: dep
loyment.arquillian-service:main
23:36:14,279 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) Stopped deployment arquillian-service in 5ms
23:36:14,289 INFO [org.jboss.as.server.controller] (pool-1-thread-1) Undeployed "arquillian-service"
Results :
Tests in error:
.....
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
Please let my know you idea on that.
Thanks
-
5. Re: Cannot use JNDI lookup in Arquillian
aslak Dec 15, 2011 11:58 AM (in response to canhhiep)testable=false means you will executing on the client side and all your EJBs need to be Remoteable to be reached.
The exception your seeing is most likely related to this, or atleast you can try the same solution: http://community.jboss.org/message/623963