java - JPA 2.1 应用程序在重新部署到 WebLogic 12.2.1 时需要重新启动托管服务器

标签 java jpa eclipselink weblogic12c

在我们当前的应用程序中使用 JPA 2.1 时,我们在发送 Web 服务请求时遇到 500 内部服务器错误。仅在重新启动应用程序的托管服务器后,问题才会解决并且 JPA 才能正常工作。我使用 eclipselink 作为我的 JPA 提供程序,因为这是服务器上提供的。我当前的部署解压了ear 文件并部署了一个包含META-INF(application.xml、MANIFEST.MF、weblogic-application.xml)的分解文件以及包含类和persistence.xml 文件的war 文件。我目前正在使用 wldeploy ant 脚本进行部署,并将重新部署作为操作。

JPA 仅在初始部署后或托管服务器反弹(如果我要重新部署)后才起作用。

这可能是我的部署、结构、EAR 和 WAR 文件的问题,还是 JPA 的实现问题?

我已在 Web 服务类中添加了 @RequestScoped 注释。

我已将 beans.xml 文件包含在我的 Web 文件夹中,其中包含以下行:

bean-discovery-mode="annotated">

我的网络文件夹包含以下内容:

web/WEB-INF/classes/persistence.xml
web/beans.xml
web/web.xml
web/weblogic.xml

持久性.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">
    <persistence-unit name="DB" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/PublicAPI</jta-data-source>
    </persistence-unit>
</persistence>

Beans.xml

 <?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                  http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    bean-discovery-mode="annotated">
 </beans>

weblogic.xml

 <?xml version='1.0' encoding='UTF-8'?>
 <weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web- 
 app"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app 
 http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
<context-root>/PublicAPI/</context-root>

网络服务

@ApplicationPath("")
@Path("inventory/")
@Api(value = "Engineering Public API")
@RequestScoped
public class SsmcResource {
    @Inject
    private SsmcListProcedure ssmcListProcedure;

    @POST
    @Path("GetSSMCList")
    @Produces(MediaType.APPLICATION_JSON)
    public SsmcResponse getSSMCList(SsmcRequest ssmcRequest)
    {
        SsmcResponse response = null;
        response = new SsmcResponse();
        SsmcList ssmc = ssmcRequest.getSsmc();
        CallerStatus callerStatus = ssmcRequest.getCallerStatus();
        InitializeCallerStatus(callerStatus);
        response.setSsmc(ssmcListProcedure.getSSMCList(ssmc.getSeries(), ssmc.getStyle(), ssmc.getMaterial(), ssmc.getColor()));
        return response;
    }
}

JPA 类:

@Dependent
@Default
public class SsmcListProcedure implements SsmcDAO {

@PersistenceContext(unitName = "DB")
private EntityManager em;

@Override
public List<SsmcList> getSSMCList(String seriesInd, String styleInd, String materialInd, String colorInd)
{
    Query q = em.createNamedStoredProcedureQuery("SsmcList");
    q.setParameter("p_series_ind", seriesInd);
    q.setParameter("p_style_ind", styleInd);
    q.setParameter("p_material_ind", materialInd);
    q.setParameter("p_color_ind", colorInd);
    return (List<SsmcList>) q.getResultList();

}
}

重新部署后,发送 POST 请求时,我在日志中收到以下错误:

WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 3
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl

最佳答案

这看起来像是已经有补丁的错误。 (JAX-RS + CDI)。

检查支持oracle。

关于java - JPA 2.1 应用程序在重新部署到 WebLogic 12.2.1 时需要重新启动托管服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56707251/

相关文章:

java - 禁用 Hibernate 批处理

java - 无法在 JPA2 中使用继承的复合键作为派生 id

mysql - JPA规范基于外键的多重连接

java - 如何使用 LEFT OUTER JOIN 创建 JPA 查询

java - 在 EclipseLink 上使用投影时出现 NotReadablePropertyException

java - 如何使用 JPA 延迟加载实体属性

Java WS 仅在 tcp/ip 监视器打开时响应

Java初学者问题: System. out.println

java - Hadoop 是一个不错的开源项目吗?

mysql - @embeddable 类的列表的字段信息在 eclipselink api 中的哪个位置编码?