English 中文(简体)
包括日本宇宙航空研究开发公司-RS REST-service Application的JPA项目
原标题:Including a JPA-Project in a JAX-RS REST-Service Application

我已撰写了一份日本宇宙航行局项目,该项目涵盖我的所有实体。 由于这两个实体也需要在教育、科学和技术部的服务项目中,我出口了JPA-项目,并将其列入教育、科学和技术部的项目(没有JPA-Facet)。

So everything can be deployed on the server and I can reach the REST-services from the frontend, but as soon as the EntityManager should be injected in a class nothing happens. This results in NullPointerExceptions since the entityManager is not present.

注射的班次为@Stateless和实体 Manager with the @PersistenceContext annotation.

因此,问题在于:投射是否在宽松的项目中工作,或者我是否必须当实体。 管理人员人工操作吗?

Thanks in advance!

在添加剂方面,我使用了玻璃鱼诉3.1.2和JPA2.0。

最佳回答

Going to answer my own question. With the help of netbeans I gathered some information that made me change my project structure lightly.

这正是:

  • Giving the REST-Project the JPA-facet
  • Store the persistence.xml in that project
  • in the PU link to the jar which contains the entites

这样做的办法是通过注入实体。 担任实体项目经理,我这样做!

问题回答

暂无回答




相关问题
Recommended way to develop using Jetty and Eclipse

I am currently developing a J2EE application and I would like to use Jetty. I would like to have iot integrated with Eclipse, so I could debug the appliaction. I ve tried out couple of plugins (...

Call function periodically in Java

we need run one function periodically in Java web application . How to call function of some class periodically ? Is there any way that call function when some event occured like high load in server ...

Why make an EJB rather than a Web Service?

I would have thought that there is a lot of information out there on this, but I haven t found anything that really answers my question. What are the advantages of making an EJB rather than a web ...

Where should I put this configuration setting?

I m designing a fairly small web application which will run on a Sun application server (v9.1). It only has a few pages, no database of its own, and will retrieve/update data via web services. There s ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

hibernate interceptors : afterTransactionCompletion

I wrote a Hibernate interceptor : public class MyInterceptor extends EmptyInterceptor { private boolean isCanal=false; public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[]...

热门标签