why can't my EAR project see the annotated EJBs and Entities in my JPA project?

南笙酒味 提交于 2019-12-12 03:18:23

问题


I'm using IBM RAD 7 (aka Eclipse 3.4) and WebSphere 7.

I have a workspace with a basic EJB setup; projects TestEAR, TestEJB, TestJPA, TestWeb.

I can annotate an ejb ("@Stateless EntityService") in the TestEJB project and it works fine. But if I put an ejb ("@Stateless EntityDAO") in the TestJPA project it doesn't get injected in the EntityService. If I move EntityDAO to the TestEJB project it works fine.

Also, if I annotate a class an entity ("@Entity MyEntity") it is not known as an entity to the container (I get a "not recognized entity" ... "Known entity types: []" error). But if I add a my.domain.MyEntity tag to the TestEJB's persistence.xml it works fine.

QUESTION: Why can't the TestEJB project recognize annotated classes in the TestJPA project?

NOTE: There is no "Deployment Assembly" tab in Eclipse 3.4, but there is a "Java EE Module Dependencies" tab (TestEAR > Properties > Java EE Module Dependencies); I checked and all projects are in the list and checked (ie. TestEJB, TestJPA, TestWeb).

Any help is greatly appreciated! This one has me truly stumped.

Thanks, Rob


回答1:


Seems there are a few questions here...

For your TestEJB project not using TestJPA beans make sure both are listed as an <ejb> module and not <jar> module in your application.xml file in TestEAR. Also make sure they are both part of the EAR.

For the No Known Entity types if that error is appearing within RSA you might want to right click on the project and look for "JPA Tools" and select "Configure JPA entities", if you do not see "JPA Tools" ensure JPA facets are enabled for that project. If it is occuring on the server (WAS I presume) make sure the following line is not in your persistence.xml <exclude-unlisted-classes>true</exclude-unlisted-classes> or all classes will need to be listed therein, not necessarily a bad thing.

Unless it is absolutely critical I would store your EJBs and Entities in the same project for simplicity.



来源:https://stackoverflow.com/questions/9436313/why-cant-my-ear-project-see-the-annotated-ejbs-and-entities-in-my-jpa-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!