2 Replies Latest reply on Nov 21, 2005 1:53 PM by milantomic

    Beginner

    milantomic

      I have developed my first EJB and when I copy it into JBoss deploy folder I can see that some kind of copy is created in tmp/deploy folder. Since there are no any messages in the WinXP console (CMD line), does this means my EJB was successfuly deployed?

      Also, when I try to find it using:

      Object ref = jndiContext.lookup("java:comp/env/ejb/OsebaRemoteHome");


      I got an exception:

      NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

      Why? :(

        • 1. Re: Beginner
          darranl

          You need to look at the stack trace you are getting a little bit closer, is that message from the lookup or from the new InitialContext()?

          The error you are getting suggests that you have not provided any properties to the initial context constructor or provided a jndi.properties file on the classpath with the JNDI configuration: -

          http://wiki.jboss.org/wiki/Wiki.jsp?page=AccessEJBsRemotely


          This is not releated to your problem but the String being used for the lookup is wrong, you will not need the java:/comp/env stuff. After deploying your bean navigate to http://localhost:8080/jmx-console - find the 'JNDI View' MBean and invoke the list operation. If your bean deployed correctly you should see it in the global namespace, you will also be able to see the name to use for the lookup.

          If your bean is not visible in the global namespace execute the command 'jar -tf jarname.jar' against your jar and post the outut here.

          • 2. Re: Beginner
            milantomic

             

            After deploying your bean navigate to http://localhost:8080/jmx-console - find the 'JNDI View' MBean and invoke the list operation. If your bean deployed correctly you should see it in the global namespace, you will also be able to see the name to use for the lookup.


            No, it is not there. :(

            If your bean is not visible in the global namespace execute the command 'jar -tf jarname.jar' against your jar and post the outut here.


            Here it is:

            META-INF/MANIFEST.MF
            META-INF/ejb-jar.xml
            META-INF/jboss.xml
            abc/MestoBean.class
            abc/MestoRemote.class
            abc/MestoRemoteHome.class
            abc/OsebaBean.class
            abc/OsebaRemote.class
            abc/OsebaRemoteHome.class
            abc/VmesniBean.class
            abc/VmesniRemote.class
            abc/VmesniRemoteHome.class

            I'm also giving ejb-jar.xml:

            <?xml version="1.0"?>
            
            <!DOCTYPE ejb-jar PUBLIC
            "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
            "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
            
            <ejb-jar>
            
             <enterprise-beans>
             <entity>
             <ejb-name>MestoEJB</ejb-name>
             <home>abc.MestoHomeRemote</home>
             <remote>abc.MestoRemote</remote>
             <ejb-class>abc.MestoBean</ejb-class>
             <persistence-type>Container</persistence-type>
             <prim-key-class>java.lang.String</prim-key-class>
             <reentrant>False</reentrant>
             <cmp-version>2.x</cmp-version>
             <abstract-schema-name>mesto</abstract-schema-name>
             <cmp-field><field-name>posta</field-name></cmp-field>
             <cmp-field><field-name>ime</field-name></cmp-field>
             <primkey-field>posta</primkey-field>
             <security-identity><use-caller-identity/></security-identity>
             </entity>
            
             <entity>
             <ejb-name>OsebaEJB</ejb-name>
             <home>abc.OsebaHomeRemote</home>
             <remote>abc.OsebaRemote</remote>
             <ejb-class>abc.OsebaBean</ejb-class>
             <persistence-type>Container</persistence-type>
             <prim-key-class>java.lang.String</prim-key-class>
             <reentrant>False</reentrant>
             <cmp-version>2.x</cmp-version>
             <abstract-schema-name>Oseba</abstract-schema-name>
             <cmp-field><field-name>id</field-name></cmp-field>
             <cmp-field><field-name>ime</field-name></cmp-field>
             <cmp-field><field-name>priimek</field-name></cmp-field>
             <cmp-field><field-name>naslov</field-name></cmp-field>
             <cmp-field><field-name>kraj</field-name></cmp-field>
             <cmp-field><field-name>telefon</field-name></cmp-field>
             <cmp-field><field-name>datumRojstva</field-name></cmp-field>
             <primkey-field>id</primkey-field>
             <security-identity><use-caller-identity/></security-identity>
             </entity>
            
             <session>
             <ejb-name>VmesniEJB</ejb-name>
             <home>abc.VmesniHomeRemote</home>
             <remote>abc.VmesniRemote</remote>
             <ejb-class>abc.VmesniBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
            
             <ejb-ref>
             <ejb-ref-name>ejb/MestoHomeRemote</ejb-ref-name>
             <ejb-ref-type>Entity</ejb-ref-type>
             <home>MestoHomeRemote</home>
             <remote>MestoRemote</remote>
             </ejb-ref>
            
             <ejb-ref>
             <ejb-ref-name>ejb/OsebaHomeRemote</ejb-ref-name>
             <ejb-ref-type>Entity</ejb-ref-type>
             <home>OsebaHomeRemote</home>
             <remote>OsebaRemote</remote>
             </ejb-ref>
            
             <security-identity><use-caller-identity/></security-identity>
            
             </session>
             </enterprise-beans>
            
             <assembly-descriptor>
            
             <security-role>
             <description>
             This role represents everyone who is allowed full access to the beans.
             </description>
             <role-name>everyone</role-name>
             </security-role>
            
             <method-permission>
             <role-name>everyone</role-name>
             <method>
             <ejb-name>OsebaEJB</ejb-name>
             <method-name>*</method-name>
             </method>
             <method>
             <ejb-name>MestoEJB</ejb-name>
             <method-name>*</method-name>
             </method>
             <method>
             <ejb-name>VmesniEJB</ejb-name>
             <method-name>*</method-name>
             </method>
             </method-permission>
            
             <container-transaction>
             <method>
             <ejb-name>OsebaEJB</ejb-name>
             <method-name>*</method-name>
             </method>
             <method>
             <ejb-name>MestoEJB</ejb-name>
             <method-name>*</method-name>
             </method>
             <method>
             <ejb-name>VmesniEJB</ejb-name>
             <method-name>*</method-name>
             </method>
             <trans-attribute>Required</trans-attribute>
             </container-transaction>
            
             </assembly-descriptor>
            
            </ejb-jar>


            and jboss.xml content:

            <?xml version="1.0"?>
            
            <jboss>
             <enterprise-beans>
             <entity>
             <ejb-name>MestoEJB</ejb-name>
             <jndi-name>MestoHomeRemote</jndi-name>
             </entity>
             <entity>
             <ejb-name>OsebaEJB</ejb-name>
             <jndi-name>OsebaHomeRemote</jndi-name>
             </entity>
             <session>
             <ejb-name>VmesniEJB</ejb-name>
             <jndi-name>VmesniHomeRemote</jndi-name>
             <ejb-ref>
             <ejb-ref-name>ejb/MestoHomeRemote</ejb-ref-name>
             <jndi-name>MestoHomeRemote</jndi-name>
             </ejb-ref>
             <ejb-ref>
             <ejb-ref-name>ejb/OsebaHomeRemote</ejb-ref-name>
             <jndi-name>OsebaHomeRemote</jndi-name>
             </ejb-ref>
             </session>
             </enterprise-beans>
            </jboss>


            Thank you in advance! :)