JavaEE 6: javax.naming.NameAlreadyBoundException: Use rebind to override

前端 未结 5 1786
再見小時候
再見小時候 2020-12-17 17:39

I have a business interface being implemented by two EJBs.

UserManagementService

@Remote
public interface UserManagementService {
          


        
相关标签:
5条回答
  • 2020-12-17 17:53

    By default GlassFish Server specific default JNDI names are applied automatically for backward compatibility. So com.transbinary.imdb.service.UserManagementService is the the default JNDI name for both the implementations of UserManagementService interface. Which was why I was gettting javax.naming.NameAlreadyBoundException exception.

    But because the EJB 3.1 specification defines portable EJB JNDI names, there is less need for GlassFish Server specific JNDI names.

    To disable GlassFish Server specific JNDI names for an EJB module, set the value of disable-nonportable-jndi-names element to true. The default is false.

    It solved the problem.

    Resource: http://wikis.oracle.com/display/GlassFish/Developer+Handoff+to+QA+for+EJB-8+%28Option+to+disable+GlassFish-specific+JNDI%29

    0 讨论(0)
  • 2020-12-17 17:58

    GlassFish restart. (It worked for me.)

    0 讨论(0)
  • 2020-12-17 17:59

    In my case, i was using JBoss5.1GA and i had two EJBs implementing a common local Business Interface...

    I Follow the idea suggested by @Christo Smal, and it work for me.... Another Observation: I was deploying an ear which contains the two EJBs at two differents EJB jars; e.g:

       Ear File:
       * Jar File1: Containing EJB1
       * Jar File2: Containing EJB2
       * lib/dummy.jar: Library containing the Business Local interface
    
    0 讨论(0)
  • 2020-12-17 18:08

    I got this same exception. In my case I changed my code from
    @Stateless(mappedName = "whatever")
    to instead be
    @Stateless(name = "whatever")
    and it solved my issue

    0 讨论(0)
  • 2020-12-17 18:10

    Make use of rebind instead of bind and it should work

    0 讨论(0)
提交回复
热议问题