aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes ejb  create() Error java.lang. IllegalStateEx:   Failed to find method for hash Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb  create() Error java.lang. IllegalStateEx:   Failed to find method for hash " Watch "ejb  create() Error java.lang. IllegalStateEx:   Failed to find method for hash " New topic
Author

ejb create() Error java.lang. IllegalStateEx: Failed to find method for hash

Reddy Nabat
Greenhorn

Joined: Mar 08, 2005
Posts: 8
I am trying to write an ejb for my application and my ejbclient code runs as follows:-

Properties properties = new Properties();
properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
properties.put("java.naming.provider.url", "jnp://localhost:1099");
properties.put("jnp.disableDiscovery", "true");
InitialContext context = new InitialContext(properties);
Object object = context.lookup(TruckInvHome.JNDI_NAME);
TruckInvHome TIH = (TruckInvHome)PortableRemoteObject.narrow(object,TruckInvHome.class);
TruckInv TI = TIH.create();

I am getting an error at this line and the error is as follows:-

Errorjava.lang.IllegalStateException: Failed to find method for hash:-6291078846837982252 available={4121927297169232143=public abstract void javax.ejb.EJBHome.remove(javax.ejb.Handle) throws java.rmi.RemoteException,javax.ejb.RemoveException, -7423251857241384719=public abstract void javax.ejb.EJBHome.remove(java.lang.Object) throws java.rmi.RemoteException,javax.ejb.RemoveException, 7415355246179212884=public abstract boolean javax.ejb.EJBObject.isIdentical(javax.ejb.EJBObject) throws java.rmi.RemoteException, 8981122088959051067=public abstract javax.ejb.HomeHandle javax.ejb.EJBHome.getHomeHandle() throws java.rmi.RemoteException, -1225864925247205563=public abstract void javax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.RemoveException, -883843542736932254=public abstract java.lang.Object javax.ejb.EJBObject.getPrimaryKey() throws java.rmi.RemoteException, 4512095171315154818=public abstract javax.ejb.EJBHome javax.ejb.EJBObject.getEJBHome() throws java.rmi.RemoteException, 4881862667832849002=public abstract dekalb.warehouse.TruckInv dekalb.warehouse.TruckInvHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException, 3781219857755091396=public abstract javax.ejb.EJBMetaData javax.ejb.EJBHome.getEJBMetaData() throws java.rmi.RemoteException, -3260590760910195779=public abstract javax.ejb.Handle javax.ejb.EJBObject.getHandle() throws java.rmi.RemoteException, 8594593460157411074=public abstract javax.ejb.EJBObject javax.ejb.Handle.getEJBObject() throws java.rmi.RemoteException, 5741447652058033148=public abstract java.lang.String dekalb.warehouse.TruckInv.Hello() throws java.rmi.RemoteException}


If anyone knows how to solve it,,, plzzz help me out.. I am desperately trying to solve for the last 2 days...
Thanking you in advance...
VIK.
Raj Puri
Ranch Hand

Joined: Apr 24, 2003
Posts: 189
I feel your pain. As I also pasted similar messages error with CM beans in ejbcreate there was no respone from anyone. I am about to give up this EJB stuff from my project as I realize that CMP does a number of things in background and one really has no clue what it does. The worst is when I migrate from EJB 1.1 to 2.0 .. well I made no changes in code as OC4J will say it is backward compatible but it is not so I get messages like
getprimarykey in EJBCreate see chapter 10.5.4.

We will probably stay with JSP. There are number of things in J2EE tha are at best for course work at school.
Reddy Nabat
Greenhorn

Joined: Mar 08, 2005
Posts: 8
Thanks for the reply. I think I am going to give up this EJB bull shit.. and go with regular beans and jsp...
VIK
Sivakumar Nachimuthu
Ranch Hand

Joined: Aug 10, 2004
Posts: 52
Hi
Do not give up from using EJBs.Can you post ur entity bean java file?

Siva
Reddy Nabat
Greenhorn

Joined: Mar 08, 2005
Posts: 8
here is my session bean class:-


import java.rmi.RemoteException;

import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

import javax.ejb.CreateException;

/**
* XDoclet-based session bean. The class must be declared
* public according to the EJB specification.
*
* To generate the EJB related files to this EJB:
*- Add Standard EJB module to XDoclet project properties
*- Customize XDoclet configuration for your appserver
*- Run XDoclet
*
* Below are the xdoclet-related tags needed for this EJB.
*
* @ejb.bean name="TruckInv"
* display-name="Name for TruckInv"
* description="Description for TruckInv"
* jndi-name="ejb/TruckInv"
* type="Stateless"
* view-type="both"
*/
public class TruckInvBean implements SessionBean {

/** The session context */
private SessionContext context;

public TruckInvBean() {
super();
// TODO Auto-generated constructor stub
}

/**
* Set the associated session context. The container calls this method
* after the instance creation.
*
* The enterprise bean instance should store the reference to the context
* object in an instance variable.
*
* This method is called with no transaction context.
*
* @throws EJBException Thrown if method fails due to system-level error.
*/
public void setSessionContext(SessionContext newContext)
throws EJBException {
context = newContext;
}

public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/**
* An ejbCreate method as required by the EJB specification.
*
* The container calls the instance?s <code>ejbCreate</code> method whose
* signature matches the signature of the <code>create</code> method invoked
* by the client. The input parameters sent from the client are passed to
* the <code>ejbCreate</code> method. Each session bean class must have at
* least one <code>ejbCreate</code> method. The number and signatures
* of a session bean?s <code>create</code> methods are specific to each
* session bean class.
*
* @throws CreateException Thrown if method fails due to system-level error.
*
* @ejb.create-method
*
*/
public void ejbCreate() throws CreateException {
int i=1;
}

/**
* An example business method
*
* @ejb.interface-method view-type = "remote"
*
* @throws EJBException Thrown if method fails due to system-level error.
*/
public String Hello() throws EJBException {
String msg="hello";
return msg;
}

}




Here is the home interface

public interface TruckInvHome
extends javax.ejb.EJBHome
{
public static final String COMP_NAME="java:comp/env/ejb/TruckInv";
public static final String JNDI_NAME="ejb/TruckInv";

public dekalb.warehouse.TruckInv create()
throws javax.ejb.CreateException,java.rmi.RemoteException;

}

here is the remote interface

public interface TruckInv
extends javax.ejb.EJBObject
{
/**
* An example business method
* @throws EJBException Thrown if method fails due to system-level error. */
public java.lang.String Hello( )
throws java.rmi.RemoteException;

}

Here is my struts action class which invokes the bean:-

import javax.naming.*;
import dekalb.warehouse.TruckInv;
import dekalb.warehouse.TruckInvHome;

public class AddTruckInventory extends Action
{
public AddTruckInventory()
{
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws SQLException, Exception
{
try{
Properties properties = new Properties();
properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
properties.put("java.naming.provider.url", "jnp://localhost:1099");
properties.put("jnp.disableDiscovery", "true");
InitialContext context = new InitialContext(properties);
Object object = context.lookup(TruckInvHome.JNDI_NAME);
servlet.log("line 2");
TruckInvHome TIH = (TruckInvHome)PortableRemoteObject.narrow(object,TruckInvHome.class);
servlet.log("line 3");
TruckInv TI = TIH.create();
servlet.log("Line 4");
String msg=TI.Hello();
request.setAttribute("msg", msg);
}
catch (Exception e)
{
servlet.log("Error"+e);
}
servlet.log("In Add Truck Inventory");
return (mapping.findForward("success"));

}
}


It would be great if you can help me out....
VIK
clive jordan
Ranch Hand

Joined: Apr 27, 2005
Posts: 39
Do you have a jboss.xml file instructing jbosss to load the JNDI name ?

Also, I don't tyhink you should be declaring remote exceptions in the bean class. I doubt if it will do any harm though.

Clive
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Royal Bengal Tiger,

There is couple of things that doesn't look right to me:
  • If you intend to use XDoclet for generating EJB artifacts then declare the bean class abstract and let the XDoclet to generate other files.
  • For the same reason remove the remote and home interfaces and let XDoclet generate them.
  • You don't need to provide a constructor.
  • Remove all throws clauses from all callback methods (except ejbCreate which should throw CreateException).


  • The last point might be the root cause of all your problems. On the other hand the first two points will raise the obvious question if you somehow mix the XDoclet artifacts with your own files. In fact do you use XDoclet at all? How do you pack the ejb: jar or ear? Do you get any server errors when you deploy the bean? Usually containers provides you visual tools that can help you to check if the bean was successfully deployed. As for your client if the web server and ejb container are collocated (run within the same jvm) you should skip setting the properties for the initial context, because thne container is already setting them for you.
    Regards.


    I think, therefore I exist -- Rene Descartes
    Sivakumar Nachimuthu
    Ranch Hand

    Joined: Aug 10, 2004
    Posts: 52
    Hi,
    As your struts action classes run in same JVM as the EJBs run, you need only localhome and local object to work with.

    To lookup the EJBs from the same JVM , you can try the following code.


     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: ejb create() Error java.lang. IllegalStateEx: Failed to find method for hash