bmp and auto_increment
kevcpu Apr 4, 2003 12:29 AMI really need help...... I have jboss 3.0.6 installed on a freebsd 4.6 server and I am having major issues testing my bean. I am using the mysql 3.23. database. Basically, when I try to run my bean from the test driver I created I got the following exception in the server.log file:
[org.jboss.ejb.plugins.BMPPersistenceManager] Runt
imeException:
java.lang.ArrayIndexOutOfBoundsException: 9
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
845)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
867)
at com.mysql.jdbc.PreparedStatement.setBoolean(PreparedStatement.java:34
3)
at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setBoole
an(LocalPreparedStatement.java:66)
at com.ldn.ejb.entity.userentejb.UserEntEJBBean.ejbStore(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenc
eManager.java:472)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.stor
eEntity(CachedConnectionInterceptor.java:388)
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:708)
at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:1
17)
at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapCleanup.beforeComple
tion(GlobalTxEntityMap.java:185)
at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1394)
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:364)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
2003-04-03 22:26:59,928 ERROR [org.jboss.ejb.GlobalTxEntityMap] Store failed on
entity: 20
javax.ejb.EJBException: null; CausedByException is:
9
at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenc
eManager.java:494)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.stor
eEntity(CachedConnectionInterceptor.java:388)
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:708)
at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:1
17)
at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapCleanup.beforeComple
tion(GlobalTxEntityMap.java:185)
at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1394)
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:364)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
java.lang.ArrayIndexOutOfBoundsException: 9
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
845)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1
867)
at com.mysql.jdbc.PreparedStatement.setBoolean(PreparedStatement.java:34
3)
at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setBoole
an(LocalPreparedStatement.java:66)
at com.ldn.ejb.entity.userentejb.UserEntEJBBean.ejbStore(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenc
eManager.java:472)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.stor
eEntity(CachedConnectionInterceptor.java:388)
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:708)
at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:1
17)
at org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapCleanup.beforeComple
tion(GlobalTxEntityMap.java:185)
at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1394)
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:364)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesva:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
and i get the following on the screen:
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at $Proxy0.create(Unknown Source)
at Driver.main(Driver.java:20)
Caused by: javax.transaction.RollbackException: Unable to commit, tx=XidImpl [Fo
rmatId=257, GlobalId=lodown.kemetek.com//9, BranchQual=] status=STATUS_ROLLEDBAC
K
at org.jboss.tm.TxCapsule.commit(TxCapsule.java:425)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:251)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:62)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Sour
ce)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvo
kerProxy.java:138)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav
a:108)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.
java:77)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:8
0)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:198)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
Here is the database part of my bean class:
String query = "insert into users (username, password, first_name" + ", middle_name, last_name, city, state, zip, email, is_client") values (?,?,?,?,?,?,?,?,?,?)";
try
{
Context dsctx = new InitialContext();
ds = (DataSource)dsctx.lookup(dsn);
con = ds.getConnection();
ps = con.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
ps.setString(1, username);
ps.setString(2, password);
ps.setString(3, fname);
ps.setString(4, lname);
ps.setString(5, mname);
ps.setString(6, city);
ps.setString(7, state);
ps.setString(8, zip);
ps.setString(9, email);
ps.setBoolean(10, isclient.booleanValue());
if (ps.executeUpdate() != 1)
{
throw new CreateException("Failed to insert user into database");
}
rs = ps.getGeneratedKeys();
if (rs.next())
{
id = new Integer(rs.getInt(1));
}
return id;
Here is my ejb.jar.xml:
<!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>
<enterprise-beans>
This bean represents a user
<ejb-name>UserEnt</ejb-name>
com.ldn.ejb.entity.userentejb.UserEntEJBHome
com.ldn.ejb.entity.userentejb.UserEntEJBRemote
<ejb-class>com.ldn.ejb.entity.userentejb.UserEntEJBBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
False
<resource-ref>
DataSource for the LoDown database
<res-ref-name>jdbc/LoDownDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</enterprise-beans>
<assembly-descriptor>
<security-role>
This role represents everyone who is allowed full access to the Ship EJ
B.
<role-name>everyone</role-name>
</security-role>
<method-permission>
<role-name>everyone</role-name>
<ejb-name>UserEnt</ejb-name>
<method-name>*</method-name>
</method-permission>
<container-transaction>
<ejb-name>UserEnt</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
Here is my jboss.xml:
<?xml version="1.0"?>
false
<container-configurations/>
<resource-managers>
<resource-manager>
<res-name>jdbc/LoDownDS</res-name>
<res-jndi-name>java:/LoDownDS</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<ejb-name>UserEnt</ejb-name>
<jndi-name>user/UserEnt</jndi-name>
</enterprise-beans>
if anyone has a clue please respond.