当我的persistence.xml文件的位置时,我感到难过.我正在使用eclipselink 2.4作为我的JPA 2.0实现,并且我的persistence.xml位于src/main/resources/META-INF/persistence.xml下,因为许多帖子状态.
第一个问题:在eclipse中发布到我的服务器后,我收到一条错误,指出我找不到我的persistence.xml.
Exception: : java.lang.IllegalArgumentException: No persistence unit named 'X'
is available in scope Webapp. Available persistence units: [] at
Run Code Online (Sandbox Code Playgroud)

这是我的persistence.xml的代码
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="X" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>localJTA</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-server" value="WebLogic"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
如果我将META-INF移动到webapp/WEB-INF/classes/META-INF,那么它可以工作!我无法理解问题所在.

我检查了项目构建路径,一切看起来都不错.

我遇到的第二个问题是我的带注释的实体类没有被eclipselink自动拾取.在我的JPA配置中,我有自动选择的发现注释类.

我的xml中也有以下内容
<exclude-unlisted-classes>false</exclude-unlisted-classes>
Run Code Online (Sandbox Code Playgroud)
使用的技术:weblogic 12c服务器,EJB 3.1,JPA 2.0,M2E-WTP和JSF 2.1
更新1:在路径src/main/resources/META-INF/persistence.xml上保留META-INF并执行maven install以构建war文件,META-INF文件夹正确放置在WEB-INF/classes/META-中像INF/persistence.xml一样(在战争中).似乎只是在Eclipse中构建和运行webapp的时间和问题.有谁能解释一下?
更新2:在src/main/resources中保留META-INF,即src/main/resources/META-INF/persistence.xml以及我的persistence.xml中的以下内容,而不是显式列出实体类
<exclude-unlisted-classes>false</exclude-unlisted-classes>
Run Code Online (Sandbox Code Playgroud)
如果我构建战争并通过weblogic控制台通过Internet Explorer部署它.为什么它不在日食里面工作!?
更新3:
你是否检查了构建的内容 -Yes,在Eclipse中我自动构建了set.查看项目文件夹,我看到java包com,包含persistence.xml的META-INF文件夹,以及在Webapp/target/classes下的resources文件夹.
如果战争是相同的 - 你是指你在C:\ workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\Weblogic12cDomain_auto_generated_ear_\Webapp.war中找到的Webapp.war文件夹?如果是这样,那里唯一的东西是WEB-INF\lib\jsf-impl-2.1.7.jar
然后你检查了用于在Eclipse中测试你的应用程序的类路径 - 这个条目可以在我的类路径中找到,如预期的在Webapp /下的.classpath …
我有一个简单的事务,它应该返回存储在实时数据库中的子节点的计数并递增它。值得注意的是,此事务位于 firebase cloud onWrite 函数内部。
问题是返回的数据为空。我知道当客户端数据过时时这是可能的,但是函数退出时没有错误并且提交是错误的。
当我使用完全相同的引用来检索数据快照时,会返回正确的值。
var ref = admin.database(devDB).ref('/path/to/countValue');
ref.transaction(function(count) {
if(count != null) {
var newCount = count + 1;
return newCount;
}
}, function(error, committed, ss) {
if(error) {
console.log('error: ', error);
}
console.log('committed: ', committed);
});
Run Code Online (Sandbox Code Playgroud) javascript firebase firebase-realtime-database google-cloud-functions firebase-admin