创建实体bean时的EJBException

时间:2013-11-15 13:24:43

标签: java ejb

我添加并修改了实体bean中的一些字段(并进行了一些其他更改),然后在创建实体bean时得到EJBException。在进行更改之前一切正常。 TipListBean是我调用create的实体bean。以下是例外情况:

[#|2013-11-15T14:41:36.063+0000|INFO|sun-appserver-pe8.2|javax.enterprise.system.container.ejb|_ThreadID=17;|EJB5018: An exception was thrown during an ejb invocation on [TipListBean]|#]

[#|2013-11-15T14:41:36.063+0000|INFO|sun-appserver-pe8.2|javax.enterprise.system.container.ejb|_ThreadID=17;|
javax.ejb.EJBException
    at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:2807)
    at com.sun.ejb.containers.BaseContainer.checkExceptionNoTx(BaseContainer.java:2647)
    at com.sun.ejb.containers.BaseContainer.checkExceptionBeanMgTx(BaseContainer.java:2585)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:2485)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:819)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:160)
    at $Proxy20.addTip(Unknown Source)
    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:585)
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:167)
    at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
    at beans._TipList_DynamicStub.addTip(_TipList_DynamicStub.java)
    at web.MakeTip.doPost(MakeTip.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
    at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Caused by: java.lang.RuntimeException: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is: 
    javax.transaction.RollbackException: Transaction marked for rollback.
    at beans.TipListBean.addTip(TipListBean.java:28)
    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:585)
    at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:957)
    at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:158)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:151)
    ... 41 more
Caused by: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is: 
    javax.transaction.RollbackException: Transaction marked for rollback.
    at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.wrapException(Util.java:657)
    at javax.rmi.CORBA.Util.wrapException(Util.java:279)
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:177)
    at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
    at beans._TipHome_DynamicStub.create(_TipHome_DynamicStub.java)
    at beans.TipListBean.addTip(TipListBean.java:21)
    ... 50 more
Caused by: java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is: 
    javax.transaction.RollbackException: Transaction marked for rollback.
Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
    at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:283)
    at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:336)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:2732)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:2521)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:819)
    at com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocationHandler.java:231)
    at $Proxy17.create(Unknown Source)
    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:585)
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:167)
    at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
    at beans._TipHome_DynamicStub.create(_TipHome_DynamicStub.java)
    at beans.TipListBean.addTip(TipListBean.java:21)
    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:585)
    at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:957)
    at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:158)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:151)
    at $Proxy20.addTip(Unknown Source)
    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:585)
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:167)
    at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
    at beans._TipList_DynamicStub.addTip(_TipList_DynamicStub.java)
    at web.MakeTip.doPost(MakeTip.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
    at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
|#]

[#|2013-11-15T14:41:36.065+0000|WARNING|sun-appserver-pe8.2|javax.enterprise.system.stream.err|_ThreadID=17;|
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    java.rmi.RemoteException
    at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.wrapException(Util.java:657)
    at javax.rmi.CORBA.Util.wrapException(Util.java:279)
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:177)
    at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
    at beans._TipList_DynamicStub.addTip(_TipList_DynamicStub.java)
    at web.MakeTip.doPost(MakeTip.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
    at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Caused by: java.rmi.RemoteException
|#]

调用者TipListBean类和我试图调用的TipBean类创建。

package beans;

import javax.ejb.FinderException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext; 
import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;

public class TipListBean implements SessionBean{

 public String addTip(String result, String amount, String tipster, String targetId, String sport, 
   String league, String homePlayer, String visitorPlayer, String closingtime)
  throws CreateException, CreateException, FinderException, RemoteException {

  Tip tip = null;
  try{
   TipHome tipHome = getTipHome();
   tip = tipHome.create(targetId, result, amount, tipster, targetId);
   return "Tip and Target created with the following ID: "; //+ tip.getTickerSymbol();
  } 
  catch (CreateException ce){
   throw ce;
  } 
  catch(Exception ex){ 
   throw new RuntimeException(ex);
  }
 }

 private TipHome getTipHome() throws NamingException {
  InitialContext jndiContext = new InitialContext();
  TipHome home = (TipHome)jndiContext.lookup("ejb/beans.Tip"); 
  return home;   
 }

 public void ejbActivate() {}
 public void ejbPassivate() {}
 public void ejbRemove() {}
 public void ejbCreate() {}
 public void setSessionContext(SessionContext context) {}
}



package beans;

import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import java.rmi.RemoteException;
import javax.ejb.FinderException;

public abstract class TipBean implements EntityBean{

 private EntityContext _context;
 public abstract String getTickerSymbol() throws RemoteException;
 public abstract void setTickerSymbol(String ticker) throws RemoteException;
 public abstract String getResult() throws RemoteException;
 public abstract void setResult(String result) throws RemoteException;
 public abstract String getAmount() throws RemoteException;
 public abstract void setAmount(String amount) throws RemoteException;
 public abstract String getTipster() throws RemoteException;
 public abstract void setTipster(String tipster) throws RemoteException;
 public abstract String getTargetId() throws RemoteException;
 public abstract void setTargetId(String targetId) throws RemoteException;

 public String ejbCreate(String ticker, String result, String amount, String tipster, String targetId) 
  throws CreateException, RemoteException {
  setTickerSymbol(ticker);
  setResult(result);
  setAmount(amount);
  setTipster(tipster);
  setTargetId(targetId);
  return null;
 }

 public void ejbPostCreate(String ticker, String result, String amount, String tipster, String targetId) 
  throws CreateException{
 }

 public void setEntityContext(EntityContext ctx){
  _context = ctx;
 }

 public void unsetEntityContext(){
  _context = null;
 }

 public void ejbRemove(){}
 public void ejbLoad(){}
 public void ejbStore(){}
 public void ejbPassivate(){}
 public void ejbActivate(){}

}

0 个答案:

没有答案