Solved

why my  first session ejb can not deplay?

Posted on 2004-09-14
14
743 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
ID: 12062079
> see above for error messages.

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

Expert Comment

by:TimYates
ID: 12062083
What class does "BookException" extend?
0
 

Author Comment

by:hgbdelphi
ID: 12062185
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:hgbdelphi
ID: 12062199
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
ID: 12062233
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
ID: 12062246
And I'm not 100% sure, but I *think* BookException should extend RemoteException...
0
 

Author Comment

by:hgbdelphi
ID: 12062384
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
 
LVL 35

Expert Comment

by:TimYates
ID: 12062414
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
ID: 12062652
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
ID: 12062804
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
ID: 12062808
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
ID: 12062871
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
ID: 12062882
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
ID: 12062898
thanks very much!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
best tutorial on log4j and logging for servlets/jsp codes 1 65
sortaSum challenge java 17 174
Using Tomcat as raspberry pi java app server 13 192
tomcat startup error 5 106
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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