-
1. Re: Custom JNDI Names
jaikiran pai Jan 13, 2012 8:35 AM (in response to Sueleyman Vurucu)AS7 doesn't allow binding EJBs to custom JNDI names and it's not planned for 7.1. Having said that I think you should perhaps be able to take advantage of the naming subsystem in JBoss AS7 which allows you to bind custom entries to JNDI. You could probably use the lookup element in that subsystem to create a custom JNDI name which points to the EJB3.1 spec mandated JNDI name. Take a look at the jboss-as-naming_1_1.xsd https://github.com/jbossas/jboss-as/blob/master/build/src/main/resources/docs/schema/jboss-as-naming_1_1.xsd
-
2. Re: Custom JNDI Names
Stephen Coy Jan 13, 2012 8:37 AM (in response to Sueleyman Vurucu)1 of 1 people found this helpfulThis is no longer supported. Please see AS7-3015 for more information
-
3. Re: Custom JNDI Names
Sueleyman Vurucu Jan 15, 2012 11:50 AM (in response to Stephen Coy)He guy thanks you for reply,
so I'm agree wuth the situation that custom JNDI names are not longer support since EJB 3.1 ENC exists. But it was a nice to have feature. Beacause, when I have services in more modules and I can only do a jndi lookuo instead of dependecy injecection then it was helpful. Otherwise I must always know the module name of my service.
-
4. Re: Custom JNDI Names
Carlo de Wolf Jan 16, 2012 3:23 AM (in response to Sueleyman Vurucu)You could always explicitly specify <module-name> in ejb-jar.xml. That way the consuming side always knows where to look.
-
5. Re: Custom JNDI Names
Sueleyman Vurucu Jan 16, 2012 4:06 AM (in response to Carlo de Wolf)Carlo de Wolf schrieb:
You could always explicitly specify <module-name> in ejb-jar.xml. That way the consuming side always knows where to look.
I know. But what is about multimodule ?? Can I set the same name for more modules ?
-
6. Re: Custom JNDI Names
Sueleyman Vurucu Jan 16, 2012 4:47 AM (in response to Sueleyman Vurucu)So I testes the behaviour of the module naming. IT seems that <module-name> has only an effect for the namespace java:app.
java:global/CONTROLLER_TEST_APP/TEST/Lookuptest!com.siemag.lookuptest.Lookuptest java:app/TEST/Lookuptest!com.siemag.lookuptest.Lookuptest java:module/Lookuptest!com.siemag.lookuptest.Lookuptest java:global/CONTROLLER_TEST_APP/TEST/Lookuptest java:app/TEST/Lookuptest java:module/Lookuptest 10:43:08,457 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-12) JNDI bindings for session bean named SingletonTest in deployment unit subdeployment "CONTROLLER_TEST.jar" of deployment "CONTROLLER_TEST_APP.ear" are as follows:
java:global/CONTROLLER_TEST_APP/TEST/SingletonTest!com.siemag.service.iface.SingletonTestLocal java:app/TEST/SingletonTest!com.siemag.service.iface.SingletonTestLocal java:module/SingletonTest!com.siemag.service.iface.SingletonTestLocal java:global/CONTROLLER_TEST_APP/TEST/SingletonTest!com.siemag.service.iface.SingletonTestRemote java:app/TEST/SingletonTest!com.siemag.service.iface.SingletonTestRemote java:module/SingletonTest!com.siemag.service.iface.SingletonTestRemote 10:43:08,457 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-12) MSC00001: Failed to start service jboss.deployment.subunit."CONTROLLER_TEST_APP.ear"."CONTROLLER_TEST.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."CONTROLLER_TEST_APP.ear"."CONTROLLER_TEST.jar".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "CONTROLLER_TEST.jar" of deployment "CONTROLLER_TEST_APP.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.1.0.CR1b.jar:7.1.0.CR1b] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_27] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_27] at java.lang.Thread.run(Thread.java:662) [:1.6.0_27] Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.module.CONTROLLER_TEST_APP.TEST is already registered
at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:226) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:560) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2211) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2211) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.1.GA.jar:1.0.1.GA] at org.jboss.as.ee.naming.ModuleContextProcessor.deploy(ModuleContextProcessor.java:73) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.1.0.CR1b.jar:7.1.0.CR1b] ... 5 more -
7. Re: Custom JNDI Names
Stian Thorgersen Jan 17, 2012 6:47 AM (in response to Sueleyman Vurucu)1 of 1 people found this helpfulYou can use the @EJB annotation to specify additional JNDI names for a bean. The bean below is bound to "java:global/MyBean" as well as the standard portable JNDI names.
package com.example; import javax.ejb.EJB; import javax.ejb.Stateless; @Stateless @EJB(name = "java:global/MyBean", beanInterface = MyBean.class) public class MyBean { }
I've tested this on 7.0.0.Final, 7.0.1.Final, 7.0.2.Final and 7.1.0.CR1b.
-
8. Re: Custom JNDI Names
Sueleyman Vurucu Jan 17, 2012 8:03 AM (in response to Stian Thorgersen)Stian Thorgersen schrieb:
You can use the @EJB annotation to specify additional JNDI names for a bean. The bean below is bound to "java:global/MyBean" as well as the standard portable JNDI names.
package com.example; import javax.ejb.EJB; import javax.ejb.Stateless; @Stateless @EJB(name = "java:global/MyBean", beanInterface = MyBean.class) public class MyBean { }
I've tested this on 7.0.0.Final, 7.0.1.Final, 7.0.2.Final and 7.1.0.CR1b.
That comes near to that what I wan't thanks. But I think that has no efect for remote lookup, I'm right ?
-
9. Re: Custom JNDI Names
Stian Thorgersen Jan 17, 2012 8:14 AM (in response to Sueleyman Vurucu)Haven't tried remote lookup, but I don't see why it shouldn't, just put down the remote interface under beanInterface. I would expect something like the following to work:
package com.example; import javax.ejb.EJB; import javax.ejb.Stateless; @Stateless @EJB(name = "java:global/MyBean", beanInterface = MyRemote.class) public class MyBean implements MyRemote { }
package com.example; import javax.ejb.Remote; @Remote public interface MyRemote { }
-
10. Re: Custom JNDI Names
Sueleyman Vurucu Jan 17, 2012 2:54 PM (in response to Stian Thorgersen)If you look https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI you'll see that the remote invocation in AS 7.1 is completely reeimplemented. I'll test this this week. But I think that won't work.
-
11. Re: Custom JNDI Names
jaikiran pai Jan 17, 2012 9:44 PM (in response to Sueleyman Vurucu)Sueleyman Vurucu wrote:
But I think that won't work.
Yes. From a remote client, you can only use ejb: namespaces.
-
12. Re: Custom JNDI Names
Wolf-Dieter Fink Feb 13, 2012 7:46 AM (in response to Stian Thorgersen)I've added such @EJB annotation to my Bean, using current upstream AS7.1.
I don't see any change in log (show the declared name) during deployment and not able to lookup the bean by this name.
-
13. Re: Custom JNDI Names
Carlo de Wolf Feb 14, 2012 5:35 AM (in response to Wolf-Dieter Fink)It works for me. https://github.com/jbossas/jboss-as/pull/1518
There is nothing in the log though (nor do I expect it), but it might be nice to have that. It would mean that every @EJB is logged.