users@glassfish.java.net

Invocation Exception - Can't lookup the java:comp/env namespace!

From: <glassfish_at_javadesktop.org>
Date: Thu, 21 Jun 2007 08:30:29 PDT

Hi all,

i badly need help with my application and my effort to make it running also on glassfish.

i do this code:

try{
                Context jndi=new InitialContext();
                home=(DicomQueryDealerSLLocalHome)jndi.lookup("java:comp/env/ejb/DicomQueryDealer");
                    jndi.close();
                }catch(NamingException nex){

as usually adviced to lookup from a POJO a stateless session bean version 2.x which is defined in ejb-jar

<session>
            <description>Session Bean ( Stateless )</description>
            <display-name>DicomQueryDealerSL</display-name>
            <ejb-name>DicomQueryDealerSL</ejb-name>....

Moreover, it defined the reference in the first bean that is processed starting the application, a different bean called DpacsBeanManager...from which all the pojo are launched

<session>
            <description>Session Bean ( Stateless )</description>
            <display-name>DpacsBeanManager</display-name>
            <ejb-name>DpacsBeanManager</ejb-name>
            <home>it.units.htl.dpacs.core.ServerRemoteHome</home>
            <remote>it.units.htl.dpacs.core.ServerRemote</remote>
            <ejb-class>it.units.htl.dpacs.core.ServerBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
            <ejb-local-ref>
                ...
            </ejb-local-ref>
            <ejb-local-ref>
                <ejb-ref-name>ejb/DicomStorageDealer</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
                <local-home>it.units.htl.dpacs.dao.DicomStorageDealerSLLocalHome</local-home>
                <local>it.units.htl.dpacs.dao.DicomStorageDealerSLLocal</local>
                <ejb-link>DicomStorageDealerSL</ejb-link>
            </ejb-local-ref>

Now glassfish should define the name "java:comp/env/ejb/DicomQueryDealer" under the scope of DpacsBeanManager and all the pojo that (in this case) are inside the same ejb module (jar) and also in the same EAR.
Even if i try to use sun-ejb-jar to further set parameters, all what i get is:
if i use:

  home=(DicomQueryDealerSLLocalHome)jndi.lookup("java:comp/env/ejb/DicomQueryDealer");

is:

javax.naming.NamingException: invocation exception
        at com.sun.enterprise.naming.NamingManagerImpl.getComponentId(NamingManagerImpl.java:1305)
        at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:800)
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:160)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:313)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at it.units.htl.dpacs.servers.queryRetrieve.FindServer$FindMultiDimseRsp.<init>(FindServer.java:286)
        at it.units.htl.dpacs.servers.queryRetrieve.FindServer.c_find(FindServer.java:226)
        at org.dcm4cheri.net.ActiveAssociationImpl.run(ActiveAssociationImpl.java:225)
        at org.dcm4cheri.util.LF_ThreadPool.join(LF_ThreadPool.java:174)
        at org.dcm4cheri.net.ActiveAssociationImpl.run(ActiveAssociationImpl.java:148)
        at org.dcm4cheri.server.DcmHandlerImpl.handle(DcmHandlerImpl.java:249)
        at org.dcm4cheri.server.ServerImpl.run(ServerImpl.java:263)
        at org.dcm4cheri.util.LF_ThreadPool.join(LF_ThreadPool.java:174)
        at org.dcm4cheri.util.LF_ThreadPool$1.run(LF_ThreadPool.java:221)
        at java.lang.Thread.run(Thread.java:595)
|#]

and if i put away the java comp env prefix...is name not found.

javax.naming.NameNotFoundException: DicomQueryDealer not found
        at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:203)
        at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:175)
        at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:179)
        at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:61)
        at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:98)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:315)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at it.units.htl.dpacs.servers.queryRetrieve.FindServer$FindMultiDimseRsp.<init>(FindServer.java:289)
        at it.units.htl.dpacs.servers.queryRetrieve.FindServer.c_find(FindServer.java:226)
        at org.dcm4cheri.net.ActiveAssociationImpl.run(ActiveAssociationImpl.java:225)
        at org.dcm4cheri.util.LF_ThreadPool.join(LF_ThreadPool.java:174)
        at org.dcm4cheri.net.ActiveAssociationImpl.run(ActiveAssociationImpl.java:148)
        at org.dcm4cheri.server.DcmHandlerImpl.handle(DcmHandlerImpl.java:249)
        at org.dcm4cheri.server.ServerImpl.run(ServerImpl.java:263)
        at org.dcm4cheri.util.LF_ThreadPool.join(LF_ThreadPool.java:174)
        at org.dcm4cheri.server.ServerImpl$1.run(ServerImpl.java:217)
        at java.lang.Thread.run(Thread.java:595)

please give me a hint if you can, i tried all i could think about.

thanks

Marco
[Message sent by forum member 'mbeltrame' (mbeltrame)]

http://forums.java.net/jive/thread.jspa?messageID=223286