Solved

why my  first session ejb can not deplay?

Posted on 2004-09-14
14
733 Views
Last Modified: 2012-05-05
CartBean .java
/*
 *
 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the proprietary information of Sun Microsystems, Inc.
 * Use is subject to license terms.
 *
 */
package com.beltino;

import java.util.*;
import javax.ejb.*;

public class CartBean implements SessionBean {

   String customerName;
   String customerId;
   Vector contents;

   public void ejbCreate(String person) throws CreateException {

      if (person == null) {
        throw new CreateException("Null person not allowed.");
      }
      else {
         customerName = person;
      }

      customerId = "0";
      contents = new Vector();
   }

   public void ejbCreate(String person, String id) throws CreateException {

      if (person == null) {
        throw new CreateException("Null person not allowed.");
      }
      else {
         customerName = person;
      }

      IdVerifier idChecker = new IdVerifier();
      if (idChecker.validate(id)) {
         customerId = id;
      }
      else {
         throw new CreateException("Invalid id: " + id);
      }

      contents = new Vector();
   }

   public void addBook(String title) {

      contents.addElement(title);
   }

   public void removeBook(String title) throws BookException {

      boolean result = contents.removeElement(title);
      if (result == false) {
         throw new BookException(title + " not in cart.");
      }
   }

   public Vector getContents() {
      return contents;
   }

   public CartBean() {}
   public void ejbRemove() {}
   public void ejbActivate() {}
   public void ejbPassivate() {}
   public void setSessionContext(SessionContext sc) {}

}

Cart.java:

package com.beltino;

import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import java.util.Vector;

public interface Cart
    extends EJBObject {

  public void addBook(String title) throws RemoteException;

  public void removeBook(String title) throws BookException, RemoteException;

  public Vector getContents() throws RemoteException;
}


CartHome .java:

package com.beltino;

import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;

public interface CartHome extends EJBHome {

  public Cart create(String person) throws CreateException, RemoteException;

  public Cart create(String person, String id) throws CreateException,
      RemoteException;
}


ejb.jar:

<?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>
  <display-name>Tre</display-name>
  <enterprise-beans>
    <session>
      <display-name>Cart</display-name>
      <ejb-name>Cart</ejb-name>
      <home>com.beltino.CartHome</home>
      <remote>com.beltino.Cart</remote>
      <ejb-class>com.beltino.CartBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
    </session>
  </enterprise-beans>
  <assembly-descriptor>
    <container-transaction>
      <method>
        <ejb-name>Cart</ejb-name>
        <method-name>*</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
  </assembly-descriptor>
</ejb-jar>


error:
14:01:56,953 ERROR [MainDeployer] could not create deployment: file:/G:/jboss/se
rver/default/deploy/Tre.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans faile
d, see above for error messages.
        at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:553)
        at org.jboss.deployment.MainDeployer.create(MainDeployer.java:817)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:673)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:637)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
er.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:230)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
        at $Proxy7.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
tScanner.java:304)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
canner.java:478)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
doScan(AbstractDeploymentScanner.java:201)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
loop(AbstractDeploymentScanner.java:212)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
run(AbstractDeploymentScanner.java:191)

i use jboss4.0.1 win2000 and jbuilderx
0
Comment
Question by:hgbdelphi
  • 8
  • 6
14 Comments
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
> see above for error messages.

What error messages are above that stack trace in the log?
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
What class does "BookException" extend?
0
 

Author Comment

by:hgbdelphi
Comment Utility
hi TimYates,thanks.

/*
 *
 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 *
 */

public class BookException extends Exception {

    public BookException() {
    }

    public BookException(String msg) {
        super(msg);
    }
}
0
 

Author Comment

by:hgbdelphi
Comment Utility
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>Cart</ejb-name>
      <jndi-name>Cart</jndi-name>
    </session>
  </enterprise-beans>
</jboss>
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
What verifier warnings are in your server.log?

It should be giving you verifier warnings (as it says it does)
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
And I'm not 100% sure, but I *think* BookException should extend RemoteException...
0
 

Author Comment

by:hgbdelphi
Comment Utility
sorry,when i change BookException extends RemoteException the error is either:

16:32:13,843 ERROR [MainDeployer] could not create deployment: file:/G:/jboss/se
rver/default/deploy/Tre.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans faile
d, see above for error messages.
        at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:553)
        at org.jboss.deployment.MainDeployer.create(MainDeployer.java:817)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:673)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:637)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
er.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:230)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
        at $Proxy7.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
tScanner.java:304)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
canner.java:460)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
doScan(AbstractDeploymentScanner.java:201)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
loop(AbstractDeploymentScanner.java:212)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
run(AbstractDeploymentScanner.java:191)














0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 35

Expert Comment

by:TimYates
Comment Utility
16:32:13,843 ERROR [MainDeployer] could not create deployment: file:/G:/jboss/se
rver/default/deploy/Tre.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans faile
d, see above for error messages.

Again, what are the error messages above that it is talking about.  

The Stacktrace is not useful, it just shows that it failed.  

The reason WHY it failed is earlier in the log file.
0
 

Author Comment

by:hgbdelphi
Comment Utility
hi,TimYates
 in server.log,the warn is:
Bean   : Cart
Section: 7.10.6
Warning: A stateless session bean must define exactly one create() method with no arguments.

2004-09-15 17:05:39,734 ERROR [org.jboss.deployment.MainDeployer] could not create deployment: file:/G:/jboss/server/default/deploy/Tre.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
      at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:553)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:817)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:673)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:637)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:230)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy7.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:304)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:478)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:212)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:191)


but when i change my code add ejbCreate(),like this(add):
CartBean.java, i add this method  
 public void ejbCreate() throws CreateException {
  }
CartHome.java, i add this method:
  public Cart create() throws CreateException, RemoteException;

but the error is either like above.
0
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
Comment Utility
Ok:

Cart.java------------------------------------------

package com.beltino;

import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import java.util.Vector;

public interface Cart extends EJBObject
{
  public void addBook(String title) throws RemoteException;
  public void removeBook(String title) throws BookException, RemoteException;
  public Vector getContents() throws RemoteException;
}

CartHome.java------------------------------------

package com.beltino;

import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;

public interface CartHome extends EJBHome
{
  public Cart create(String person) throws CreateException, RemoteException;
  public Cart create(String person, String id) throws CreateException, RemoteException;
}

CartBean.java--------------------------------------

package com.beltino;

import java.util.*;
import javax.ejb.*;

public class CartBean implements SessionBean
{
   String customerName;
   String customerId;
   Vector contents;

   public void ejbCreate(String person) throws CreateException
   {
      ejbCreate( person, null ) ;
   }

   public void ejbCreate(String person, String id) throws CreateException
   {
      if (person == null) {
        throw new CreateException("Null person not allowed.");
      }
      else {
         customerName = person;
      }
      if( id != null )
      {
          IdVerifier idChecker = new IdVerifier();
          if (idChecker.validate(id)) {
             customerId = id;
          }
          else {
             throw new CreateException("Invalid id: " + id);
          }
      }
      contents = new Vector();
   }

   public void addBook(String title) {
      contents.addElement(title);
   }

   public void removeBook(String title) throws BookException {
      boolean result = contents.removeElement(title);
      if (result == false) {
         throw new BookException(title + " not in cart.");
      }
   }

   public Vector getContents() {
      return contents;
   }

   public void ejbRemove() {}
   public void ejbActivate() {}
   public void ejbPassivate() {}
   public void setSessionContext(SessionContext sc) {}
}

ejb.jar-----------------------------------------------

<?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>
  <display-name>Tre</display-name>
  <enterprise-beans>
    <session>
      <display-name>Cart</display-name>
      <ejb-name>Cart</ejb-name>
      <home>com.beltino.CartHome</home>
      <remote>com.beltino.Cart</remote>
      <ejb-class>com.beltino.CartBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Container</transaction-type>
    </session>
  </enterprise-beans>
  <assembly-descriptor>
    <container-transaction>
      <method>
        <ejb-name>Cart</ejb-name>
        <method-name>*</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
  </assembly-descriptor>
</ejb-jar>
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
It looks like your Cart EJB is a Stateful bean, but you declared it as Stateless in the ejb.jar

So the only real change I made was to change line 12 in ejb.jar

:-)
0
 

Author Comment

by:hgbdelphi
Comment Utility
ha,
 TimYates thans for tell you how to debug with server.log file,now i saw because my ejb is Stateless,so it can only hava a crate() method with no argument,if i want another create() method ,i should use Stateful ejb,so i changed it ,and it can deplayed!

   Best Regard for You!
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
So it is fixed?

Yay!

Glad I could help :-)

PS:  Stateful session beans can be a bit of a resource/performance hog, so I always try to use Stateless ones wherever possible

Good luck!!

Tim
0
 

Author Comment

by:hgbdelphi
Comment Utility
thanks very much!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now