3 Replies Latest reply on Feb 7, 2005 5:21 AM by juggernaut

    java.lang.classnotfoundexception, please help

    haripriya

      Guys, I really need help with this as i am working on this problem since 2 days, still could not solve thsi problem and I am runnign out of time. It is very frustrating for me. I am using jboss 4.0.1

      I have placed my ejb jar file in web-inf / lib/myejb.jar
      Now, when I try to access it, it is giving me a noclassfoundexception.
      Following is the part of code that is throwing exception. Thanks a ton for your time.


      
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
      'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
      
      <ejb-jar>
       <description>MyApp</description>
       <display-name>MyApp</display-name>
       <enterprise-beans>
       <session>
       <ejb-name>MyApp</ejb-name>
       <home>com.admin.dao.EJBHome</home>
       <remote>com.admin.dao.EJBObject</remote>
       <ejb-class>com.admin.dao.EJBBean</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Bean</transaction-type>
       </session>
       </enterprise-beans>
      </ejb-jar>
      
      jboss.xml://
      
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
      <jboss>
       <enterprise-beans>
       <session>
       <ejb-name>MyApp</ejb-name>
       <jndi-name>MyApp</jndi-name>
       </session>
       </enterprise-beans>
      </jboss>
      
      //ejb client code
      
      try {
       Context ic = new InitialContext();
       Object obj = ic.lookup("MyApp");
      
       home = (EJBHome) PortableRemoteObject.narrow(obj, EJBHome.class);
      
       }catch(Exception ex){
       ex.printStackTrace();
       }
      
      
      


        • 1. Re: java.lang.classnotfoundexception, please help

          What's the exact exception?

          Kalyan

          • 2. Re: java.lang.classnotfoundexception, please help
            haripriya

            Thanks Kalyan for tryign to help me.

            I have been owrking and now I get this exception, ""the Bean Provider must specify the fully-qualified name of the enterprise bean's remote interface"

            This is the structure of the ear file.

            
            /ear
             |----- war
             |-----ejbjar
             |-----/Meta-inf
             |--application.xml
            //jboss.xml
            
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
            <jboss>
             <enterprise-beans>
             <session>
             <ejb-name>MyApp</ejb-name>
             <jndi-name>ejb/MyApp</jndi-name>
             </session>
             </enterprise-beans>
            </jboss>
            
            //web.xml
            
            <ejb-ref>
             <ejb-ref-name>PetronSecurity</ejb-ref-name>
             <ejb-ref-type>Session</ejb-ref-type>
             <home>com.admin.dao.EJBHome</home>
             <remote>com.admin.dao.EJBObject</remote>
             <ejb-link>EJBBean</ejb-link>
             </ejb-ref>
            
            


            • 3. Re: java.lang.classnotfoundexception, please help
              juggernaut

              maybe you should repackage your app in some other way? AFAIK ejbs should be packaged in jar file that contains ejb-jar.xml file, which describes classes and interface used for making calls to ejb.

              I use the following layout:

              app.ear
               |
               +-beans.jar
               | |
               | +-META-INF
               | |
               | +-ejb-jar.xml
               +-app.war
               |
               +-META-INF
               |
               +-application.xml
              
              //ejb-jar.xml
              <?xml version="1.0" encoding="UTF-8"?>
              <!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 >
               <description>[CDATA[No Description.]]</description>
               <display-name>Generated by XDoclet</display-name>
               <enterprise-beans>
               <!-- Session Beans -->
               <session >
               <description>[CDATA[]]</description>
              
               <ejb-name></ejb-name>
              
               <home>...</home>
               <remote>...</remote>
               <local-home>...</local-home>
               <local>...</local>
               <ejb-class>....</ejb-class>
               <session-type>Stateless</session-type>
               <transaction-type>Container</transaction-type>
               </session>
               </enterprise-beans>
              </ejb-jar>
              
              //application.xml
              <application version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
               ....
               <module>
               <web>
               <web-uri>app.war</web-uri>
               <context-root>/app-web</context-root>
               </web>
               </module>
               <module>
               <ejb>beans.jar</ejb>
               </module>
               .....
              </application>
              
              


              and it works quite well for me