【问题标题】:Why glassfish5 does not deploy my war correctly?为什么 glassfish5 不能正确部署我的战争?
【发布时间】:2018-09-13 18:37:02
【问题描述】:

我正在使用 Eclipse 版本:Oxygen.3 Release (4.7.3)、Glassfish 5、java 版本 1.8.0_161、Hibernate 5.2.16(作为 JPA 实现)和 maven。

我正在应对以下情况:

测试1

  1. 我在eclipse中右键一个项目->更新项目->选择 全部 -> 好的
  2. 从服务器视图:右键单击 glassfish -> 调试
  3. 从服务器视图:右键单击 glassfish -> 添加和删除 -> 添加 “clusterer”模块(见下文我的 maven 结构)
  4. http://localhost:8080/clusterer/webapi/myresource我的ws 工作正常

测试2

  1. 在父项目上点击右键->运行方式->maven clean
  2. 在父项目上点击右键->运行方式->maven安装
  3. 从父项目复制战争 -> 将其粘贴到 path_folder/clusterer.war
  4. 停止上一个测试的域(比如说 domain1)
  5. 启动一个新域(比如说 domain2)
  6. asadmin --force deploy path_folder/clusterer.war
  7. 转至http://localhost:8080/clusterer/webapi/myresource
  8. 我收到以下错误:无法检索 unitName DBClusterer 的 EntityManagerFactory

我的ma​​ven项目结构如下:

p1  (parent pom with modules)
|   |  |
|   |  Clusterer (war)
|   |
|   ClusterService (ejb)
|
DBClusterer (jar)

hibernate.cfg.xml 和 persistence.xml(包含前面提到的持久性单元“DBClusterer”)位于 DBCluster 模块中。 hibernate.cfg.xml 位于 src/main/resources (在 java 构建路径中标记为源目录)。 persistence.xml 位于 src/main/java/META-INF(其中 src/main/java 在 java 构建路径中被标记为源目录)。

【问题讨论】:

    标签: eclipse hibernate maven jakarta-ee entitymanager


    【解决方案1】:

    我刚刚解决了这个问题。 Maven 希望将 persistence.xml 放入 main/java/resources/META-INF

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-15
      • 2017-09-20
      • 1970-01-01
      • 2011-04-12
      相关资源
      最近更新 更多