Reddy Nabat

Greenhorn
+ Follow
since Mar 08, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Reddy Nabat

I bought a Sun Certification voucher last year and completely forgot about it before I realized on July 25th that it was expiring on July 31st. I didn't have an option but to take the exam. I have been working in Java/JavaEE for a few years now and I have worked on several large scale projects in the recent past. Even though my intent was to appear for the SCEA, I though it would be safe to go with SCJP with last minute preparation. With a busy 9 to 9 job I got about 2 hours a day for 3 days. I quickly skimmed through the Two minutes drills at the end of each chapter of the SCJP study guide by Kathy Sierra and Bert Bates and took the exam today. Got 71%.. I don't know how important the percentage is but I think the exam thoroughly tests your knowledge of basics. Most of the sections where I didn't score were questions that required memorization like methods in a StringBuilder. Good luck to everyone who is planning on taking the exam.
15 years ago
anyone plzz help me. I am almost getting fired... plzzzzzzz
HI,
I am trying to write a basic session bean for my application and I am getting a create error. Can anyone plzz help me outt...


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"));

}
}

I am getting an error at create 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}
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
Thanks for the reply. I think I am going to give up this EJB bull shit.. and go with regular beans and jsp...
VIK
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.
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.