Glassfish infinite loop when lookup MailResource combined with module-name

318 views Asked by At

Glassfish runs into an infinite loop when lookup Mail Resource. The error occurs only when defining a custom <module-name> in the ejb.jar.xml.

Exception:

at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:90) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:180) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) at javax.naming.InitialContext.lookup(InitialContext.java:392) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:90) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:180) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) at javax.naming.InitialContext.lookup(InitialContext.java:392) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:90)

Here's my configuration:

glassfish-resources.xml

<mail-resource enabled="true" host="${mail.host}"
    jndi-name="mail/MailSession" object-type="user"
    store-protocol="imap" store-protocol-class="com.sun.mail.imap.IMAPStore"
    transport-protocol="smtp" transport-protocol-class="com.sun.mail.smtp.SMTPTransport"
    user="[email protected]" from="[email protected]">
    <property name="mail-smtp-auth" value="true"/>
    <property name="mail-smtp-password" value="${password}" />
</mail-resource>

Injection in EMailService.java

...
@Resource(name = "java:module/mail/MailSession")
private Session mySession;
...

ejb.jar.xml

<module-name>backend</module-name>

Of course, all the upper mentioned Files reside in the same module => backend.

Using detailed logging of the JNDI-Internals I could drill down the issue to the follwing point:

WORKING SCENARIO (No module-name): With NO special module-name the module-name will be the file name withour file extension, e.g. backend-1.1.1-SNAPSHOT. This will lead to the following lookup scenario, finally resloving the MailResource:

.SerialContext;MethodName=lookup;|SerialContext ==> lookup( java:module/mail/MailSession)|#] .SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:module/mail/MailSession|#] .JavaURLContext;MethodName=lookup;|In javaURLContext.lookup, name = java:module/mail/MailSession serialcontext...null|#] .SerialContext;MethodName=lookup;|SerialContext ==> lookup( java:global/portal-1.1.1/backend-1.1.1-SNAPSHOT/mail/MailSession)|#] .SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:global/portal-1.1.1/backend-1.1.1-SNAPSHOT/mail/MailSession|#] .SerialContextProviderImpl;MethodName=lookup;| SerialContextProviderImpl :: lookup java:global/portal-1.1.1/backend-1.1.1-SNAPSHOT/mail/MailSession|#] .GlassfishNamingManagerImpl;MethodName=lookup;|serialcontext in GlassfishNamingManager..null|#] .GlassfishNamingManagerImpl;MethodName=lookup;|GlassfishNamingManager : looking up name : java:module/mail/MailSession|#] .GlassfishNamingManagerImpl;MethodName=bindToNamespace;|naming.bind Binding name:java:module/mail/MailSession|#]

ERROR SCENARIO (Custom module-name): Adding a custom module-name like shown in the upper mentioned ejb.jar.xml will faIl with the infinite loop of lookups.

The related lookup logging looks like:

FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:module/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.JavaURLContext;MethodName=lookup;|In javaURLContext.lookup, name = java:module/mail/MailSession serialcontext...null|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup( java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession)|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContextProviderImpl;MethodName=lookup;| SerialContextProviderImpl :: lookup java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl;MethodName=lookup;|serialcontext in GlassfishNamingManager..null|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl;MethodName=lookup;|GlassfishNamingManager : looking up name : java:module/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup( java:module/mail/MailSession)|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:module/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.JavaURLContext;MethodName=lookup;|In javaURLContext.lookup, name = java:module/mail/MailSession serialcontext...null|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup( java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession)|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContextProviderImpl;MethodName=lookup;| SerialContextProviderImpl :: lookup java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl;MethodName=lookup;|serialcontext in GlassfishNamingManager..null|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl;MethodName=lookup;|GlassfishNamingManager : looking up name : java:module/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup( java:module/mail/MailSession)|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:module/mail/MailSession|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.JavaURLContext;MethodName=lookup;|In javaURLContext.lookup, name = java:module/mail/MailSession serialcontext...null|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup( java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession)|#] FINE|glassfish3.1.1|com.sun.enterprise.naming|_ThreadID=23;_ThreadName=Thread-2;ClassName=com.sun.enterprise.naming.impl.SerialContext;MethodName=lookup;|SerialContext ==> lookup relative name : java:global/private-ear-1.2.0-SNAPSHOT/backend/mail/MailSession|#]

Checking the glassfish resources manually from asadmin fetches the following entries:

private-ear-1.2.0-SNAPSHOT  <ear, web, ejb>
    private-frontend-1.2.0-SNAPSHOT.war  <WebModule>
    backend-1.2.0-SNAPSHOT.jar           <EJBModule>
        java:module/mail/MailSession <MailResource>

If there's an expert out there, please give me a hint on that.

0

There are 0 answers