Java EE数据库Facade连接错误

时间:2013-11-11 07:19:53

标签: java netbeans netbeans-7 java-ee-7

我正在尝试使用Facade连接到数据库。我使用的是Netbeans 7.3.1 JDK 1.7和JAva EE 7。

有一个企业应用程序,一个bean客户端应用程序和一个类库。我主要使用netbeans中的插入代码方法来创建连接。我收到以下错误:

 java.lang.reflect.InvocationTargetException
   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:601)
   at org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:446)
   at org.glassfish.appclient.client.AppClientFacade.launch(AppClientFacade.java:183)
   atorg.glassfish.appclient.client.AppClientGroupFacade.main(AppClientGroupFacade.java:65)
Caused by: 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.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:212)
   at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
   at com.sun.proxy.$Proxy299.count(Unknown Source)
   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:601)

 Caused by: java.lang.IllegalArgumentException: No [EntityType] was found for the key class [com.javaee.test.db.Questions] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class>com.javaee.test.db.Questions</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)

我不确定问题究竟在哪里,所以我没有发布任何代码。如果您有提示,我可以放下代码。

1 个答案:

答案 0 :(得分:1)

昨晚我犯了同样的错误。我想我们正在上同班!要修复它,请展开ejb项目 - &gt;配置文件 - &gt;的persistence.xml

在“常规”下,有一个选中的复选框“在 _ 模块中包含所有实体类”。我取消选中该框,然后手动添加每个类。这照顾了例外。希望这会有所帮助。