我在 Netbeans 工作,并将我的实体 bean 和 Web 服务放在不同的项目中。我在 Web 服务项目中包含实体 bean,但是 ApplicaitonConfig.java 文件不断被覆盖并删除我为相关 jar 文件中的实体 bean 创建的条目。
我的问题是:是否需要让 EntityBeans 和 WebServices 共享同一个项目/jar 文件?如果不是,那么包含 jar 文件中的实体 bean 的适当方法是什么?
<?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="jdbc/emrPool" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/emrPool</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="none"/>
<property name="eclipselink.cache.shared.default" value="false"/>
</properties>
</persistence-unit>
</persistence>
根据 Melc 的输入,我验证了事务类型设置为 JTA 并且 jta-data-source 设置为 Glassfish JDBC 资源的值。不幸的是,问题仍然存在。我打开了 WAR 文件并验证了 EntityBean.jar 文件是最新版本,并且位于 War 文件的 WEB-INF/lib 目录中。我认为这与实体没有向实体经理“注册”这一事实有关。但是我不知道为什么他们没有被注册。