Solved

why my  first session ejb can not deplay?

Posted on 2004-09-14
14
736 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Display the newly inserted values 3 74
difference between member and local variables. 29 126
iterator example remove 8 74
Retrieving file from bytes array in spring mvc 8 59
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

18 Experts available now in Live!

Get 1:1 Help Now