Hi there,
 
I am facing problem in removing cmp beans. When ever I tried to remove a cmp it throws IllegalArgumentException i.e.
 
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
 
but this happened only in case when I have my own primary key class. If I have java class as a primary key, removing of bean cause no problem but when I declare my own primary key class it throws exception. If any body have tried this scenario on jboss 2.4.6 then let me know his findings.
 
I am using Jboss version 2.4.6 the tomcat 4.0.3, jdk is 1.4., SQLServer 2000 with Microsoft jdbc driver, OS windows NT and the client I have tried are either jsps, servlets or session beans in all three cases problem remains same, 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 object,  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 have posted this problem earlier too and tried some suggested solutions but problem remains there.
 
Nayyer Kamran
 
 

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>
    <enterprise-beans>
        <entity>
            <ejb-name>ApplicationCOMP</ejb-name>
            <home>com.cst.pps.ejbs.cmp.tmpcomp.ApplicationHome</home>
            <remote>com.cst.pps.ejbs.cmp.tmpcomp.Application</remote>
            <ejb-class>com.cst.pps.ejbs.cmp.tmpcomp.ApplicationBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>com.cst.pps.ejbs.cmp.tmpcomp.ApplicationPK</prim-key-class>
            <reentrant>False</reentrant>
            <cmp-field>
                <field-name>appID</field-name>
            </cmp-field>
            <cmp-field>
                <field-name>appDesc</field-name>
            </cmp-field>
            <resource-ref>
                <res-ref-name>jdbc/PPSDS</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
            </resource-ref>
        </entity>
    </enterprise-beans>
    <assembly-descriptor>
        <container-transaction>
            <method>
                <ejb-name>ApplicationCOMP</ejb-name>
                <method-name>*</method-name>
            </method>
            <trans-attribute>Required</trans-attribute>
        </container-transaction>
    </assembly-descriptor>
</ejb-jar>
jboss.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC '-//JBoss//DTD JBOSS 2.4//EN' 'http://www.jboss.org/j2ee/dtd/jboss_2_4.dtd'>
<jboss>
    <enterprise-beans>
        <entity>
            <ejb-name>ApplicationCOMP</ejb-name>
            <jndi-name>TempComp</jndi-name>
            <resource-ref>
                <res-ref-name>jdbc/PPSDS</res-ref-name>
                <jndi-name>java:/PPSDS</jndi-name>
            </resource-ref>
        </entity>
    </enterprise-beans>
</jboss>
 
jaws.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jaws PUBLIC '-//JBoss//DTD JAWS 2.4//EN' 'http://www.jboss.org/j2ee/dtd/jaws_2_4.dtd'>
<jaws>
    <enterprise-beans>
        <entity>
            <ejb-name>ApplicationCOMP</ejb-name>
            <cmp-field>
                <field-name>appID</field-name>
                <column-name>AppID</column-name>
            </cmp-field>
            <cmp-field>
                <field-name>appDesc</field-name>
                <column-name>AppDesc</column-name>
            </cmp-field>
            <finder>
                <name>findAll</name>
                <query></query>
                <order></order>
            </finder>
            <table-name>Application</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 -----
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 name reminds me of Kamran Ashraf,  Great Pak Hockey Player.
 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Nayyer Kamran
Sent: Friday, August 16, 2002 5:56 PM
To: [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 as primarykey 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; nested exception is:

java.lang.IllegalArgumentException

at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:148)

at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenceManager.java:157)

at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:372)

at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:287)

at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:197)

at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:125)

at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)

... 46 more

Caused by: java.lang.IllegalArgumentException

at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)

at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)

at java.lang.reflect.Field.get(Field.java:228)

at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.getPkFieldValue(JDBCCommand.java:659)

at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.setPrimaryKeyParameters(JDBCCommand.java:360)

at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.setParameters(JDBCLoadEntityCommand.java:160)

at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:155)

at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:144)

... 52 more

[15:59:35,535,STDERR] tmperrorjavax.transaction.TransactionRolledbackException: Load failed; nested exception is:

java.lang.IllegalArgumentException; nested exception is:

java.rmi.ServerException: Load failed; nested exception is:

java.lang.IllegalArgumentExceptionLoad failed; nested exception is:

java.lang.IllegalArgumentException; nested exception is:

java.rmi.ServerException: Load failed; nested exception is:

java.lang.IllegalArgumentExceptionjava.rmi.ServerException: Load failed; nested exception is:

java.lang.IllegalArgumentException

Thanks
 
Nayyer

Reply via email to