4 Replies Latest reply on Aug 15, 2003 10:02 AM by simon555

    problem deploy .jar

    simon555 Newbie

      hi,
      I deployed an .jar on JBoss.When I was starting the server.disply following error:
      22:51:55,456 WARN [verifier] EJB spec violation:
      Bean : SquenceSessionBean
      Section: 22.2
      Warning: The Bean Provider must specify the fully-qualified name of the Java class that implements the enterprise bean's business methods in the <ejb-class> element.
      Info : Class not found: parts.ejb.SquenceSessionBean

      22:51:55,507 ERROR [MainDeployer] could not create deployment: file:/G:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/SequenceBean.jar
      org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
      at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:487)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:784)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:639)

      It hint "Class not found: parts.ejb.SquenceSessionBean"
      But there is the SquenceSessionBean.class in my "bin" folder.
      My ejb.xml descriptor fragment:
      <display-name>SquenceSession Bean</display-name>

      <ejb-name>SquenceSessionBean</ejb-name>

      parts.partsInterface.SquenceSessionBeanHome
      parts.partsInterface.SquenceSessionBean
      <local-home>parts.partsInterface.SquenceSessionBeanLocalHome</local-home>
      parts.partsInterface.SquenceSessionBeanLocal
      <ejb-class>parts.ejb.SquenceSessionBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      What reason that is?

        • 1. Re: problem deploy .jar
          Adrian Brock Master

          Classes are not loaded from the bin folder.
          Put it in a jar in server/default/lib

          Regards,
          Adrian

          • 2. Re: problem deploy .jar
            simon555 Newbie

            Thanks for your help.I write a CMP of EntityEJB using Eclipse,I want to test it by jUnit,but I don't know how to do.Do you tell me about?
            Thanks.

            • 3. Re: problem deploy .jar
              Adrian Brock Master

              Please start a new thread for new questions.

              Regards,
              Adrian

              • 4. Re: problem deploy .jar
                simon555 Newbie

                The following is my EJB's source codepackage


                parts.ejb;


                //import javax.ejb.EJBException;
                import javax.ejb.EntityBean;
                import javax.ejb.EntityContext;


                /**
                * @author BEE MICROSYSTEMS
                *
                * @ejb.bean name = "SequenceBean"
                * description = "generation of sequence"
                * display-name = "Sequence Bean"
                * type = "CMP"
                * reentrant = "false"
                * transaction-type = "Container"
                * cmp-version = "2.x"
                * view-type = "local"
                * local-jndi-name = "SequenceBeanHomeLocal"
                *
                * primkey-field = "name"
                *
                *
                *@ejb.env-entry description = "the number of retriev every times"
                * name = "blockSize"
                * type = "java.lang.Integer"
                * value = "10"
                *
                *@ejb.resource-ref res-ref-name = "jdbc/SequencePool"
                * res-type = "javax.sql.DataSource"
                * res-auth = "Container"
                *
                * @jboss.resource-ref res-ref-name = "jdbc/SequencePool"
                *
                * jndi-name = "java:/FirebirdDS"
                *
                *
                *
                *@jboss.persistence create-table = "true"
                * datasource = "java:/FirebirdDS"
                *
                * table-name = "sequence_generate"
                * remove-table = "true"
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                */
                public abstract class SequenceBean implements EntityBean {



                private EntityContext ctx;
                // private String name;
                //private int index;
                /**
                *
                */
                public SequenceBean() {
                super();

                }


                public void ejbActivate(){


                }
                /**
                * Deafault create method
                * @return
                * @ejb.create-method
                */
                public String ejbCreate(String name){
                this.setName(name);
                this.setIndex(0);
                return null;


                }
                /**
                *
                * @ejb.persistent-field
                *
                * @jboss.jdbc-type type = "VARCHAR"
                * @jboss.sql-type type = "varchar(32)"
                * @jboss.column-name name = "squ_name"
                *
                *
                *
                *
                * */
                public abstract String getName();
                public abstract void setName(String name);

                /**
                * @ejb.persistent-field
                *
                * @jboss.jdbc-type type = "INTEGER"
                * @jboss.sql-type type = "INTEGER(8)"
                * @jboss.column-name name = "squ_index"
                *
                * */
                public abstract int getIndex();
                public abstract void setIndex(int index);

                /**
                * @param
                * @return
                * @ejb.interface-method view-type = "local"
                * */
                public int getValueAfterIncrementingBy(int blockSize)
                {
                this.setIndex(this.getIndex()+ blockSize);
                return this.getIndex();
                }


                public void ejbLoad(){

                }


                public void ejbPassivate(){

                }


                public void ejbRemove(){

                }


                public void ejbStore(){

                }


                public void setEntityContext(EntityContext context){
                ctx = context;
                }


                public void unsetEntityContext(){


                }

                }


                The following is my testing code
                package parts.tests;

                import javax.naming.InitialContext;
                import javax.naming.NamingException;

                import junit.swingui.TestRunner;
                //import junit.textui.*;
                import junit.framework.TestCase;
                //import junit.framework.*;
                //import java.util.Hashtable;;

                import parts.partsInterface.*;

                /**
                * @author wangjh1
                *
                * To change the template for this generated type comment go to
                * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
                */
                public class SequenceBeanTest extends TestCase {

                private SequenceBeanLocal sequenceLocal;

                private static SequenceBeanTest ts = new SequenceBeanTest();

                //private HashMap evn = new HashMap();

                public void getConnection(String name)
                {
                getInfo("Running" + this.toString());

                //Hashtable evn = new Hashtable();

                //Adding the initial context to the hashtabel
                try
                {
                getInfo("Create an Initial context");
                InitialContext ic = new InitialContext();
                getInfo("Look for the EJB" + "SequenceBean");
                SequenceBeanLocalHome localHomeInterface = (SequenceBeanLocalHome)ic.lookup("SequenceBeanHomeLocal");
                getInfo("Create a new EJB instance");
                sequenceLocal = localHomeInterface.create(name);

                }
                catch(NamingException e)
                {
                getInfo(e.toString());
                //fail();
                }
                catch(Exception e)
                {
                getInfo("create exception");
                getInfo(e.toString());
                fail();
                }
                }

                public void setUp() throws Exception
                {
                //String name = "orderTest";
                getConnection("orderTest");
                }

                public void testGetValueAfterIncrementingBy()
                {
                try
                {int result = sequenceLocal.getValueAfterIncrementingBy(10);

                getInfo("-----------------------------");
                getInfo("Success without exception");
                assertEquals(10,result);
                }
                catch(Exception e)
                {
                // fail("Fail" + e);
                System.out.println("error" + e);
                }
                }

                public void getInfo(boolean msgObj)
                {
                System.out.println(msgObj);
                }

                public void getInfo(String msg)
                {
                System.out.println(msg);
                }

                public static void main(String args[])
                {
                if(args.length > 0)
                {
                if(args[0].equals("SWING"))
                {
                TestRunner.run(ts.getClass());
                }
                else
                {
                junit.textui.TestRunner.run(ts.getClass());
                }
                }
                else
                {
                //formatting the output
                System.out.println("--------------");
                String className = ts.getClass().getName();
                className = className.substring(className.lastIndexOf(".") + 1);
                System.out.println("Test report of:" + className);
                System.out.println("--------------------------");
                TestRunner.run(ts.getClass());
                }
                }

                }


                My testing approach is:

                1.package the SequenceBean.class into SequenceBean.jar.
                2.put SequenceBean.jar into server\default\lib
                3.start the server
                4.run jUnit with Eclipse

                Result of executed is below:

                RunningtestGetValueAfterIncrementingBy(parts.tests.SequenceBeanTest)
                Create an Initial context
                Look for the EJBSequenceBean
                javax.naming.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
                errorjava.lang.NullPointerException

                When I stoped the server,rerun the JUnit,result is the seem with above

                My motive is want to test the EJB whether access data from database correct.but it seems like I make a mistake.

                What is the correct approach?

                Thanks.