How to specify a different jndi-name than the default for an EJB in JBoss 4.2.2.GA?

試著忘記壹切 提交于 2019-12-22 09:24:53

问题


By default it seems the jndi name of a bean is based on the ear in which it is contained. An EJB named MyBean my-app.ear will have the name "my-app/MyBean/local".

How can I change that behavior declaratively? I want the jndi name to be "something-else/MyBean/local". It has to be declarative rather than with an annotation b/c I can't modify the source of MyBean.java; I only have the jar, which I am packaging into an ear for deployment.


回答1:


You can provide this in jboss.xml

http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/jboss_deployment_descriptor.html

jndi-name element is what you want.

Example:

<jboss>
   <enterprise-beans>
      <service>
         <ejb-class>org.jboss.ejb3.test.service.ServiceSix</ejb-class>
         <local>org.jboss.ejb3.test.service.ServiceSixLocal</local>
         <remote>org.jboss.ejb3.test.service.ServiceSixRemote</remote>
         <management>org.jboss.ejb3.test.service.ServiceSixManagement</management>
         <jndi-name>serviceSix/remote</jndi-name>
         <local-jndi-name>serviceSix/local</local-jndi-name>
      </service>
   </enterprise-beans>
</jboss>



回答2:


I'm not au fait with EJB3 (it's too little too late as far as I'm concerned), but with EJB2 you can do this by modifyig the jboss.xml descriptor that goes inside the EJB JAR's META-INF. Specifically, you modify the element of the EJB definition.

If this doesn't apply to EJB3 (and I realise that EJB3 is descriptor-lite), my apologies, please don't down-vote me :)



来源:https://stackoverflow.com/questions/1008198/how-to-specify-a-different-jndi-name-than-the-default-for-an-ejb-in-jboss-4-2-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!