在EJB调用期间发生系统异常

在EJB调用期间发生系统异常

本文介绍了在EJB调用期间发生系统异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告:EJB5184:在EJB EmpFacade调用期间发生系统异常,方法为:public java.util.List com.session.AbstractFacade.findAll()
警告: javax.ejb.EJBException
在com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
在com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698 )
在com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
在com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
在com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
at com。 sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
在com.sun.ejb.containers.EJBLocalObjectInv ocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy $ Proxy243.findAll(Unknown Source)
at com.session .__ EJB31_Generated__EmpFacade__Intf ____ Bean __。findAll(Unknown Source)
at com.control.EntityController.processRequest(EntityController.java:62)
在com.control.EntityController.doGet(EntityController.java:157)
在javax.servlet.http.HttpServlet.service(HttpServlet。 java:687)
在javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
在org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
在org .apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
在com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
在org.apache .catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
在com.sun.enterprise.v3 .services.impl.ContainerMapper.service(ContainerMapper.java:188)
在org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
在org.glassfish.grizzly .http.server.HttpHandler.doHandle(HttpHandler.java:168)
在org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
在org.glassfish.grizzly .filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
在org.glassfish.grizzly.filterchain。 DefaultFilterChain.executeChainP艺术(DefaultFilterChain.java:206)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain。 java:114)
在org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
在org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
在org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:55)
在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:564)
在org.gla ssfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:544)
在java.lang.Thread.run(Thread.java:744)
导致:java.lang.IllegalArgumentException:在Metamodel中找不到关键类[com.entity.Emp]的[EntityType] - 请验证在persistence.xml中使用特定< class> com.entity.Emp< / class>引用了[Entity]类;属性或全局< exclude-unlisted-classes> false< / exclude-unlisted-classes>元件。 $ org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl。 java:193)
在org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl.internalFrom(CommonAbstractCriteriaImpl.java:114)
在org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl。 from(AbstractQueryImpl.java:246)
at com.session.AbstractFacade.findAll(AbstractFacade.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun。 reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java: 606)
在org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
在org.g lassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
在com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
在com.sun。 ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
在com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
在com.sun.ejb.EjbInvocation。继续(EjbInvocation.java:582)
在org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke( Method.java:606)
在com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorMan ager.java:883)
在com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
在com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java: 582)
在com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
在com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java: 140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:606)
在com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java: 883)
在com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
在com.sun.ejb.containers。拦截器.InterceptorManager.intercept(InterceptorManager.java:369)
在com.sun.ejb.containers.BaseContainer .__ intercept(BaseContainer.java:4667)
在com.sun.ejb.containers.BaseContainer。截图(BaseContainer.java:4655)
在com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
... 34更多

警告: StandardWrapperValve [EntityController]:Servlet的Servlet.service()EntityController抛出异常
javax.ejb.EJBException
在com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
在com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
在com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
在com。 sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
在com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
在com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
在com.sun。 ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
在com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
在com.sun.proxy $ Proxy243 .findAll(Unknown Source)
at com.session .__ EJB31_Generated__EmpFacade__Intf ____ Bean __。findAll(Unknown Source)
at com.control.EntityController.processRequest(EntityController.java:62)
at com.control。 EntityController.doGet(EntityController.java:157)
在javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
在javax.servlet.http.HttpServlet.service(HttpServlet.java: 790)
在org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
在org.apache.catalina.core.StandardWrappe rValve.invoke(StandardWrapperValve.java:318)
在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
在org.apache.catalina.core.StandardPipeline.doInvoke( StandardPipeline.java:734)
在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
在com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java: 99)
在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
在org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
在com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
在org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
在org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
在org.glassfish.grizzly.http.server.HttpServerFilt er.handleRead(HttpServerFilter.java:189)
在org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter (DefaultFilterChain.java:288)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java :136)
在org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
在org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
在org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
在org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
在org.glassfish.grizzly.st rategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:55)
在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
在org.glassfish.grizzly.threadpool .AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:564)
在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:544)
在java.lang.Thread.run (Thread.java:744)
导致:java.lang.IllegalArgumentException:在Metamodel中找不到关键类[com.entity.Emp]的[EntityType] - 请确认[Entity]类是在persistence.xml中使用特定的< class> com.entity.Emp< / class>引用。属性或全局< exclude-unlisted-classes> false< / exclude-unlisted-classes>元件。 $ org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl。 java:193)
在org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl.internalFrom(CommonAbstractCriteriaImpl.java:114)
在org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl。 from(AbstractQueryImpl.java:246)
at com.session.AbstractFacade.findAll(AbstractFacade.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun。 reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java: 606)
在org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
在org.g lassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
在com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
在com.sun。 ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
在com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
在com.sun.ejb.EjbInvocation。继续(EjbInvocation.java:582)
在org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke( Method.java:606)
在com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorMan ager.java:883)
在com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
在com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java: 582)
在com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
在com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java: 140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:606)
在com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java: 883)
在com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
在com.sun.ejb.containers。拦截器.InterceptorManager.intercept(InterceptorManager.java:369)
在com.sun.ejb.containers.BaseContainer .__ intercept(BaseContainer.java:4667)
在com.sun.ejb.containers.BaseContainer。截图(BaseContainer.java:4655)
在com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
... 34更多

Emp.java

  @Entity 
@Table(name =EMP)
@XmlRootElement
@NamedQueries({
@NamedQuery(name =Emp.findAll,query = SELECT e FROM Emp e),
@NamedQuery(name =Emp.findByEmpno,query =SELECT e FROM Emp e WHERE e.empno =:empno),
@NamedQuery(name = emp.findByEname,query =SELECT e FROM Emp e WHERE e.ename =:ename),
@NamedQuery(name =Emp.findByJob,query =SELECT e FROM Emp e WHERE e。 job =:job),
@NamedQuery(name =Emp.findByMgr,query =SELECT e FROM Emp e WHERE e.mg r =:mgr),
@NamedQuery(name =Emp.findByHiredate,query =SELECT e FROM Emp e WHERE e.hiredate =:hiredate),
@NamedQuery(name = Emp.findBySal,query =SELECT e FROM Emp e WHERE e.sal =:sal),
@NamedQuery(name =Emp.findByComm,query =SELECT e FROM Emp e WHERE e.comm =
public class Emp实现可序列化{
private static final long serialVersionUID = 1L;
// @Max(value =?)@Min(value =?)//如果你知道你的十进制字段的范围考虑使用这些注释来强制实现字段验证
@Id
@Basic (optional = false)
@NotNull
@Column(name =EMPNO)
private BigDecimal empno;
@Size(max = 10)
@Column(name =ENAME)
private String ename;
@Size(max = 9)
@Column(name =JOB)
private String job;
@Column(name =MGR)
private Short mgr;
@Column(name =HIREDATE)
@Temporal(TemporalType.TIMESTAMP)
private Date hiredate;
@Column(name =SAL)
private BigDecimal sal;
@Column(name =COMM)
private BigDecimal comm;
@Column(name =DEPTNO)
private short deptno;

public Emp(){
}

public Emp(BigDecimal empno){
this.empno = empno;
}

public BigDecimal getEmpno(){
return empno;
}

public void setEmpno(BigDecimal empno){
this.empno = empno;
}

public String getEname(){
return ename;
}

public void setEname(String ename){
this.ename = ename;
}

public String getJob(){
return job;
}

public void setJob(String job){
this.job = job;
}

public Short getMgr(){
return mgr;
}

public void setMgr(Short mgr){
this.mgr = mgr;
}

public Date getHiredate(){
return hiredate;
}

public void setHiredate(Date hiredate){
this.hiredate = hiredate;
}

public BigDecimal getSal(){
return sal;
}

public void setSal(BigDecimal sal){
this.sal = sal;
}

public BigDecimal getComm(){
return comm;
}

public void setComm(BigDecimal comm){
this.comm = comm;
}

public Short getDeptno(){
return deptno;
}

public void setDeptno(Short deptno){
this.deptno = deptno;
}

@Override
public int hashCode(){
int hash = 0;
hash + =(empno!= null?empno.hashCode():0);
返回哈希;
}

@Override
public boolean equals(Object object){
// TODO:Warning - 此方法在id字段为没有设置
if(!(object instanceof Emp)){
return false;
}
Emp other =(Emp)对象;
if((this.empno == null&& other.empno!= null)||(this.empno!= null&!this.empno.equals(other.empno))) {
return false;
}
返回true;
}

@Override
public String toString(){
returncom.entity.Emp [empno =+ empno +];
}

}

persistence.xml

 <?xml version =1.0encoding =UTF-8?> 
< persistence version =2.1xmlns =http://xmlns.jcp.org/xml/ns/persistencexmlns:xsi =http://www.w3.org/2001/XMLSchema-实例xsi:schemaLocation =http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd\">
< persistence-unit name =SampleBeanPUtransaction-type =JTA>
< jta-data-source> jdbc / OracleDS< / jta-data-source>
< class> com.entity.Emp< / class>
< class> com.entity.Dept< / class>
<属性>
< property name =eclipselink.logging.level.sqlvalue =FINEST/>
< / properties>
< / persistence-unit>
< / persistence>

每个清理和构建或编译任何文件在访问任何页面时都会超出异常。每次重新启动glassfish服务器时,要解决此问题。既然,这不是很好的解决办法。所以,有人帮我解决这个问题吗?

解决方案

似乎我解决了我的问题。我发现这个



在我的类中添加以下代码,我创建了 EMF

  @PreDestroy 
public void destruct()
{
emf.close();
}

@override servlet destroy 方法并调用上面的方法。现在,它的作品。!!!


WARNING:   EJB5184:A system exception occurred during an invocation on EJB EmpFacade, method: public java.util.List com.session.AbstractFacade.findAll()
WARNING:   javax.ejb.EJBException
    at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
    at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
    at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at com.sun.proxy.$Proxy243.findAll(Unknown Source)
    at com.session.__EJB31_Generated__EmpFacade__Intf____Bean__.findAll(Unknown Source)
    at com.control.EntityController.processRequest(EntityController.java:62)
    at com.control.EntityController.doGet(EntityController.java:157)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: No [EntityType] was found for the key class [com.entity.Emp] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class>com.entity.Emp</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
    at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:173)
    at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl.java:193)
    at org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl.internalFrom(CommonAbstractCriteriaImpl.java:114)
    at org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl.from(AbstractQueryImpl.java:246)
    at com.session.AbstractFacade.findAll(AbstractFacade.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    ... 34 more

WARNING:   StandardWrapperValve[EntityController]: Servlet.service() for servlet EntityController threw exception
javax.ejb.EJBException
    at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
    at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
    at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at com.sun.proxy.$Proxy243.findAll(Unknown Source)
    at com.session.__EJB31_Generated__EmpFacade__Intf____Bean__.findAll(Unknown Source)
    at com.control.EntityController.processRequest(EntityController.java:62)
    at com.control.EntityController.doGet(EntityController.java:157)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: No [EntityType] was found for the key class [com.entity.Emp] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class>com.entity.Emp</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
    at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:173)
    at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl.java:193)
    at org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl.internalFrom(CommonAbstractCriteriaImpl.java:114)
    at org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl.from(AbstractQueryImpl.java:246)
    at com.session.AbstractFacade.findAll(AbstractFacade.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    ... 34 more

Emp.java

@Entity
@Table(name = "EMP")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Emp.findAll", query = "SELECT e FROM Emp e"),
    @NamedQuery(name = "Emp.findByEmpno", query = "SELECT e FROM Emp e WHERE e.empno = :empno"),
    @NamedQuery(name = "Emp.findByEname", query = "SELECT e FROM Emp e WHERE e.ename = :ename"),
    @NamedQuery(name = "Emp.findByJob", query = "SELECT e FROM Emp e WHERE e.job = :job"),
    @NamedQuery(name = "Emp.findByMgr", query = "SELECT e FROM Emp e WHERE e.mgr = :mgr"),
    @NamedQuery(name = "Emp.findByHiredate", query = "SELECT e FROM Emp e WHERE e.hiredate = :hiredate"),
    @NamedQuery(name = "Emp.findBySal", query = "SELECT e FROM Emp e WHERE e.sal = :sal"),
    @NamedQuery(name = "Emp.findByComm", query = "SELECT e FROM Emp e WHERE e.comm = :comm"),
    @NamedQuery(name = "Emp.findByDeptno", query = "SELECT e FROM Emp e WHERE e.deptno = :deptno")})
public class Emp implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "EMPNO")
    private BigDecimal empno;
    @Size(max = 10)
    @Column(name = "ENAME")
    private String ename;
    @Size(max = 9)
    @Column(name = "JOB")
    private String job;
    @Column(name = "MGR")
    private Short mgr;
    @Column(name = "HIREDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date hiredate;
    @Column(name = "SAL")
    private BigDecimal sal;
    @Column(name = "COMM")
    private BigDecimal comm;
    @Column(name = "DEPTNO")
    private Short deptno;

    public Emp() {
    }

    public Emp(BigDecimal empno) {
        this.empno = empno;
    }

    public BigDecimal getEmpno() {
        return empno;
    }

    public void setEmpno(BigDecimal empno) {
        this.empno = empno;
    }

    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public Short getMgr() {
        return mgr;
    }

    public void setMgr(Short mgr) {
        this.mgr = mgr;
    }

    public Date getHiredate() {
        return hiredate;
    }

    public void setHiredate(Date hiredate) {
        this.hiredate = hiredate;
    }

    public BigDecimal getSal() {
        return sal;
    }

    public void setSal(BigDecimal sal) {
        this.sal = sal;
    }

    public BigDecimal getComm() {
        return comm;
    }

    public void setComm(BigDecimal comm) {
        this.comm = comm;
    }

    public Short getDeptno() {
        return deptno;
    }

    public void setDeptno(Short deptno) {
        this.deptno = deptno;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (empno != null ? empno.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Emp)) {
            return false;
        }
        Emp other = (Emp) object;
        if ((this.empno == null && other.empno != null) || (this.empno != null && !this.empno.equals(other.empno))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entity.Emp[ empno=" + empno + " ]";
    }

}

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="SampleBeanPU" transaction-type="JTA">
        <jta-data-source>jdbc/OracleDS</jta-data-source>
        <class>com.entity.Emp</class>
        <class>com.entity.Dept</class>
        <properties>
            <property name="eclipselink.logging.level.sql" value="FINEST"/>
        </properties>
    </persistence-unit>
</persistence>

After each Clean and Build or Compiling of any file I'm getting above exception while accessing any page. To resolve this issue each time I have to restart the glassfish server. Since, this won't be good solution. So, anyone help me to resolve this issue ?

解决方案

It seems I resolved my issue. I found this link

And added following code in my class where I'm creating instance of EMF

@PreDestroy
public void destruct()
{
    emf.close();
}

and @override servlet destroy method and call above method. Now, It works.!!!

这篇关于在EJB调用期间发生系统异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 20:54