在 Jetty 中配置 JPA 时出现问题
我正在尝试将 JPA (Toplink) 配置为在从 Maven 插件运行的 Jetty 中运行,并且收到 javax.naming.NameNotFoundException。 具体细节。
web.xml:
<persistence-unit-ref>
<persistence-unit-ref-name>persistence/mod</persistence-unit-ref-name>
<persistence-unit-name>ModPU</persistence-unit-name>
</persistence-unit-ref>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="ModPU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<properties>
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost/mod"/>
<property name="toplink.jdbc.user" value="user"/>
<property name="toplink.jdbc.driver" value="org.gjt.mm.mysql.Driver"/>
<property name="toplink.jdbc.password" value="pass"/>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
代码:
@PersistenceUnit(unitName = "ModPU")
EntityManagerFactory emf;
引用 emf 时出错:
Caused by: javax.naming.NameNotFoundException; remaining name 'persistence/ugc'
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:634)
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:665)
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:665)
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:680)
at org.mortbay.naming.java.javaRootURLContext.lookup(javaRootURLContext.java:112)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.jersey.server.impl.container.servlet.ThreadLocalNamedInvoker.invoke(ThreadLocalNamedInvoker.java:65)
... 37 more
I am trying to get JPA (Toplink) configured to run in Jetty being run from the maven plugin and am getting a javax.naming.NameNotFoundException. The specifics.
web.xml:
<persistence-unit-ref>
<persistence-unit-ref-name>persistence/mod</persistence-unit-ref-name>
<persistence-unit-name>ModPU</persistence-unit-name>
</persistence-unit-ref>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="ModPU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<properties>
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost/mod"/>
<property name="toplink.jdbc.user" value="user"/>
<property name="toplink.jdbc.driver" value="org.gjt.mm.mysql.Driver"/>
<property name="toplink.jdbc.password" value="pass"/>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
code:
@PersistenceUnit(unitName = "ModPU")
EntityManagerFactory emf;
error when referencing emf:
Caused by: javax.naming.NameNotFoundException; remaining name 'persistence/ugc'
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:634)
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:665)
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:665)
at org.mortbay.naming.NamingContext.lookup(NamingContext.java:680)
at org.mortbay.naming.java.javaRootURLContext.lookup(javaRootURLContext.java:112)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.jersey.server.impl.container.servlet.ThreadLocalNamedInvoker.invoke(ThreadLocalNamedInvoker.java:65)
... 37 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这一行是不需要的,应该删除。
我相信web.xml 中的
I believe the line:
in your web.xml is not needed and should be removed.