Problema com Entity Bean

1 resposta
V
Estou tendo um problema com BMP Entity Bean, quando crio um bean ele retorna um erro da seguinte forma
org.jboss.tm.JBossTransactionRolledbackException: null; nested exception is: 
	org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=michellangelo/22, BranchQual=, localId=22] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Account 123-456-789 failed to save to database; CausedByException is:
	Invalid argument in JDBC call: parameter index out of range: 1); - nested throwable: (org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=michellangelo/22, BranchQual=, localId=22] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Account 123-456-789 failed to save to database; CausedByException is:
	Invalid argument in JDBC call: parameter index out of range: 1))
	at org.jboss.ejb.plugins.TxInterceptorCMT.throwJBossException(TxInterceptorCMT.java:522)
	at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:459)
	at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:322)
	at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:126)
	at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:99)
	at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
	at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:508)
	at org.jboss.ejb.Container.invoke(Container.java:891)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
	at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
	at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
	at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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:460)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
	at java.lang.Thread.run(Thread.java:534)
Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=michellangelo/22, BranchQual=, localId=22] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Account 123-456-789 failed to save to database; CausedByException is:
	Invalid argument in JDBC call: parameter index out of range: 1)
	at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:344)
	at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:454)
	... 29 more
Caused by: javax.ejb.EJBException: Account 123-456-789 failed to save to database; CausedByException is:
	Invalid argument in JDBC call: parameter index out of range: 1
	at examples.bmp.AccountBean.ejbStore(AccountBean.java:223)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.jboss.ejb.plugins.BMPPersistenceManager.invokeEjbStore(BMPPersistenceManager.java:483)
	at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeEjbStore(CachedConnectionInterceptor.java:412)
	at org.jboss.ejb.EntityContainer.invokeEjbStore(EntityContainer.java:729)
	at org.jboss.ejb.GlobalTxEntityMap$2.invokeEjbStore(GlobalTxEntityMap.java:117)
	at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:239)
	at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.beforeCompletion(GlobalTxEntityMap.java:302)
	at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1383)
	at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1075)
	at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:296)
	... 30 more
Não entendo muito o que esse erro quer dizer, o meu codigo do ejbCreate() é da seguinte forma
public AccountPK ejbCreate(String accountID, String ownerName)
    	throws CreateException
    {
        PreparedStatement pstmt = null;
        Connection conn = null;
        
        try
        {
            System.out.println("ejbCreate() called");
            
            conn = getConnection();
            pstmt = conn.prepareStatement("insert into accounts(id, " +
            		"ownerName, balance) values(?, ?, ?)");
            pstmt.setString(1, accountID);
            pstmt.setString(2, ownerName);
            pstmt.setDouble(3, balance);
            
            if(pstmt.executeUpdate() == 0)
                new CreateException("Could not insert data in the table");
            else
                System.out.println("Inserido");
            
            pstmt.close();
            pstmt = null;
            
            conn.close();
            conn = null;
            
            this.accountID = accountID;
            this.ownerName = ownerName;
            this.balance = 0;
            
            return new AccountPK(accountID);
        } catch(Exception ex)
        {
            throw new CreateException(ex.toString());
        } finally
        {
            
            try
            {
                if (pstmt != null)
                    pstmt.close();
            } catch(Exception ex){}
            
            try
            {
                if (conn != null)
                {
                    conn.close();
                    conn = null;
                }
            } catch(Exception ex){}

        }
    }

Alguem sabe me responder o que esta acontecendo?

1 Resposta

Z

Qual é o código dessa linha?:
examples.bmp.AccountBean.ejbStore(AccountBean.java:223)

Criado 14 de março de 2005
Ultima resposta 24 de mar. de 2005
Respostas 1
Participantes 2