Solved

why my  first session ejb can not deplay?

Posted on 2004-09-14
14
740 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
library class in java 1 92
maven project in eclipse 11 59
Best practices to work on a spring MVC project 1 125
spring example non maven 4 88
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
In this increasingly digital world, security hacks are no longer just a threat, but a reality. As we've witnessed with Target's big identity hack 2013, Heartbleed in 2015, and now Cloudbleed, companies and their leaders need to prepare for the unthi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

832 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