Re: [JBoss-user] illegalArgumentException while removing the entity bean
Title: Message Hi Saroj, I am again here with the same problem. I replied late because of some other office tasks. I have tried the changes that u have mentioned but no luck, I got the same reply from jboss :(. There is another message in this thread from Ooi Leng Chai [EMAIL PROTECTED]. probably u have gone through his mail. So what should I try next. I gona try jboss 3.1. But I want 2.4.6 as our application is working smoothly over 2.4.6 except this remove problem. waiting for your reply. Thanks again, Nayyer Kamran - Original Message - From: Saroj Kumar To: [EMAIL PROTECTED] Sent: Monday, August 19, 2002 11:04 AM Subject: RE: [JBoss-user] illegalArgumentException while removing the entity bean Hi Kamran, I would like to point out something regarding use of remove() method on EJBHome/EJBObject. EJBObject : No need to use Handle here. I think that you are not using this method. It seems that you are calling EJBHome.remove(); EJBHomeObject: There are 2 ways to remove. 1) Use PK . home.remove(pk) - I generally use this or EJBObject.remove() 2)home.remove(handle) Observation: Mostly It looks fine to me except one small suggestion. Suggestion: Instead of using this for EQUALS check , try the following : EXISTING CODE ** public boolean equals(Object obj) { if (this.getClass().equals(obj.getClass())) { ApplicationPK that = (ApplicationPK) obj; return this.appID.intValue() == that.appID.intValue(); } return false; } SUGGESTED CODE *** public boolean equals(Object obj){boolean retVal = false; if ( obj instanceof ApplicationPK ){ApplicationPK pk = (AddressPK) obj; retVal = this.appID.intValue() == pk.appID.intValue();}return retVal;} EXISTINGCODE ** public ApplicationPK() { appID = new Integer(0); } SUGGESTED CODE ** public ApplicationPK() { } I think this should solve the problem. -Saroj PS. wasout on the weekend. That caused the late reply.
RE: [JBoss-user] illegalArgumentException while removing the entity bean
Title: Message Hi Kamran, I would like to point out something regarding use of remove() method on EJBHome/EJBObject. EJBObject : No need to use Handle here. I think that you are not using this method. It seems that you are calling EJBHome.remove(); EJBHomeObject: There are 2 ways to remove. 1) Use PK . home.remove(pk) - I generally use this or EJBObject.remove() 2)home.remove(handle) Observation: Mostly It looks fine to me except one small suggestion. Suggestion: Instead of using this for EQUALS check , try the following : EXISTING CODE ** public boolean equals(Object obj) { if (this.getClass().equals(obj.getClass())) { ApplicationPK that = (ApplicationPK) obj; return this.appID.intValue() == that.appID.intValue(); } return false; } SUGGESTED CODE *** public boolean equals(Object obj){boolean retVal = false; if ( obj instanceof ApplicationPK ){ApplicationPK pk = (AddressPK) obj; retVal = this.appID.intValue() == pk.appID.intValue();}return retVal;} EXISTINGCODE ** public ApplicationPK() { appID = new Integer(0); } SUGGESTED CODE ** public ApplicationPK() { } I think this should solve the problem. -Saroj PS. wasout on the weekend. That caused the late reply. -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Nayyer KamranSent: Saturday, August 17, 2002 1:11 PMTo: [EMAIL PROTECTED]Subject: Re: [JBoss-user] illegalArgumentException while removing the entity bean Thanks for your reply the Jboss version I am using is 2.4.6 the tomcat 4.0.3, jdk is 1.4. I am attaching the code of the home, remote, bean and primary key classes, deployment descriptor and pasting it in mail too the exception is also there at the bottom as u can see in client code I first find the remote obj through fBPK then access the bean remote method so far so good then I call remove over remote booom here is the exception occures that I pasted in the bottom. I have also added the table script so now I think every thing is here to check it out. I am waiting for thesolution, specilly from u Saroj. Nayyer Kamran Saroj Thanks for compliments it also meansu love hockey. CREATE TABLE [dbo].[Application] ( [AppID] [int] NOT NULL , [AppDesc] [char] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] primary key class public class ApplicationPK implements Serializable { public Integer appID; public ApplicationPK() { appID = new Integer(0); } public ApplicationPK(Integer appID) { this.appID = appID; } public boolean equals(Object obj) { if (this.getClass().equals(obj.getClass())) { ApplicationPK that = (ApplicationPK) obj; return this.appID.intValue() == that.appID.intValue(); } return false; } public int hashCode() { return appID.intValue(); } public String toString(){ return appID.toString(); }} Home Interface public interface ApplicationHome extends EJBHome { public Application create(Integer appID, String appDesc) throws RemoteException, CreateException; public Application create(Integer appID) throws RemoteException, CreateException; public Application findByPrimaryKey(ApplicationPK primaryKey) throws RemoteException, FinderException; public Collection findAll() throws RemoteException, FinderException;} Remote Interface public interface Application extends EJBObject { public Integer getAppID() throws RemoteException; public String getAppDesc() throws RemoteException; public void setAppDesc(String appDesc) throws RemoteException;} Bean Class public class ApplicationBean implements EntityBean { EntityContext entityContext; public Integer appID; public String appDesc; public ApplicationPK ejbCreate(Integer appID, String appDesc) throws CreateException { this.appID = appID; this.appDesc = appDesc; return null; } public ApplicationPK ejbCreate(Integer appID) throws CreateException { return ejbCreate(appID, null); } public void ejbPostCreate(Integer appID, String appDesc) throws CreateException { } public void ejbPostCreate(Integer appID) throws CreateException { ejbPostCreate(appID, null); } public void ejbLoad() { } public void ejbStore() { } public void ejbRemove(){ System.out.println("here to remove comp"); } public void ejbActivate() { } public void ejbPassivate() { } public void setEntityContext(EntityContext entityContext) { this.entityContext = entityContext; } public void unsetEntityContext() { entityContext = null; } public Integer getAppID() { return appID; } public String getAppDesc() { return appDesc; } public void setAppDesc(String appDesc) { this.appDesc = appDesc; }} ejbjar.xml ?xml version="1.0" encoding="UTF-8"?!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd"ejb-jar enterpri
Re: [JBoss-user] illegalArgumentException while removing the entity bean
sc/field-name column-nameAppDesc/column-name /cmp-field finder namefindAll/name query/query order/order /finder table-nameApplication/table-name /entity /enterprise-beans/jaws Test client jsp (just put code snipet in jsp client will be there u may need to add some more debug messages) Object obj = cont.lookup("TempComp"); ApplicationHome home = (ApplicationHome)PortableRemoteObject.narrow(obj,ApplicationHome.class); if(request.getParameter("opt").equals("1")){ home.create(new Integer(15),"My Application Comp"); } else if(request.getParameter("opt").equals("0")){ Application app = home.findByPrimaryKey(new ApplicationPK(new Integer(15))); out.println(((ApplicationPK)app.getPrimaryKey()).toString()); out.println(app.getAppDesc()); System.out.println("removing from home"); home.remove(app.getHandle()); } else if(request.getParameter("opt").equals("2")){ Application app = home.findByPrimaryKey(new ApplicationPK(new Integer(2))); out.println(app.getAppDesc()); } } catch(NamingException ex){ System.out.println("tmperror"+ex.toString()+ex.getMessage()+ex.getCause()); ex.printStackTrace();} catch(RemoveException ex){ System.out.println("tmperror"+ex.toString()+ex.getMessage()+ex.getCause()); ex.printStackTrace();} catch(RemoteException ex){ System.out.println("tmperror"+ex.toString()+ex.getMessage()+ex.getCause()); ex.printStackTrace();} catch(CreateException ex){ System.out.println("tmperror"+ex.toString()+ex.getMessage()+ex.getCause()); ex.printStackTrace();} - Original Message - From: Saroj Kumar To: [EMAIL PROTECTED] Sent: Friday, August 16, 2002 4:38 PM Subject: RE: [JBoss-user] illegalArgumentException while removing the entity bean Hi Kamran, There may be a problem with PK Class. post ur code. -Saroj P.S.: Kamran, ur namereminds me of Kamran Ashraf, Great Pak Hockey Player. -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Nayyer KamranSent: Friday, August 16, 2002 5:56 PMTo: [EMAIL PROTECTED]Subject: [JBoss-user] illegalArgumentException while removing the entity bean Dear Fellows, I have an entity bean and its primary key is java.lang.Integer I created a record through it, it works fine. Then I tried to remove it by calling findByPrimaryKey(java.lang.Integer) it works fine. but when I made my own class asprimarykey class(in new entity bean over the same table) and then Problem arises when I tried to remove the entity bean it throws IllegalArgumentException. The problem most probably in jaws but what should i do to remove it. The exception stacktrace is given below. Any help will be appreciated. it too urgent. javax.transaction.TransactionRolledbackException: Load failed; nested exception is: java.lang.IllegalArgumentException; nested exception is: java.rmi.ServerException: Load failed; nested exception is: java.lang.IllegalArgumentException at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:188) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170) at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:436) at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:506) at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335) at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133) at $Proxy185.remove(Unknown Source) at org.apache.jsp.testtmp$jsp._jspService(testtmp$jsp.java:90) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.Con
RE: [JBoss-user] illegalArgumentException while removing the entity bean
Title: Message Hi Kamran, There may be a problem with PK Class. post ur code. -Saroj P.S.: Kamran, ur namereminds me of Kamran Ashraf, Great Pak Hockey Player. -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Nayyer KamranSent: Friday, August 16, 2002 5:56 PMTo: [EMAIL PROTECTED]Subject: [JBoss-user] illegalArgumentException while removing the entity bean Dear Fellows, I have an entity bean and its primary key is java.lang.Integer I created a record through it, it works fine. Then I tried to remove it by calling findByPrimaryKey(java.lang.Integer) it works fine. but when I made my own class asprimarykey class(in new entity bean over the same table) and then Problem arises when I tried to remove the entity bean it throws IllegalArgumentException. The problem most probably in jaws but what should i do to remove it. The exception stacktrace is given below. Any help will be appreciated. it too urgent. javax.transaction.TransactionRolledbackException: Load failed; nested exception is: java.lang.IllegalArgumentException; nested exception is: java.rmi.ServerException: Load failed; nested exception is: java.lang.IllegalArgumentException at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:188) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170) at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:436) at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:506) at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335) at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133) at $Proxy185.remove(Unknown Source) at org.apache.jsp.testtmp$jsp._jspService(testtmp$jsp.java:90) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107) at java.lang.Thread.run(Thread.java:536) Caused by: java.rmi.ServerException: Load failed;