java 附加有 __pm 的 JNDI 资源名称。部署失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15473918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JNDI resource name appended with __pm . Deployment fails
提问by rockstar
I am trying to run a very simple ear applicaiton . i seem to run into exactly this issue but the discussions here dont work for me JDBC resource name being modified by container (__pm
being appended to it)
我正在尝试运行一个非常简单的耳朵应用程序。我似乎遇到了这个问题,但这里的讨论对我不起作用 JDBC 资源名称正在被容器修改(__pm
被附加到它上面)
In my case also the datasource name is being appened by __pm
. I have no clue where it comes from but the server logs point to the fact that instead of searching for databasename
it searches for databasename__pm
and fails the deployment.
在我的情况下,数据源名称也由__pm
. 我不知道它来自哪里,但服务器日志指出这样一个事实,即不是搜索,databasename
而是搜索databasename__pm
部署失败。
Persistence.xml :-
持久性.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="FCK-ejbPU" transaction-type="JTA">
<jta-data-source>FCKDatabase</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
Glassfish logs :
Glassfish 日志:
Error occurred during deployment: Exception while preparing the app : Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/FCKDatabase__pm), (applicationName=FCK) }. Please see server.log for more details.
Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method : java.lang.RuntimeException: Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/FCKDatabase__pm), (applicationName=FCK) }
Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/FCKDatabase__pm), (applicationName=FCK) }
As you can see my the JNDI name of my resources is appened with __pm
.
如您所见,我的资源的 JNDI 名称附加了__pm
.
Also on the Glassfish server console the resource is correctly shown as FCKDatabase and not FCKDatabase_pm
同样在 Glassfish 服务器控制台上,资源正确显示为 FCKDatabase 而不是 FCKDatabase_pm
Any idea where this __pm
comes from ?
知道这__pm
是从哪里来的吗?
System:
系统:
- Netbeans 7.3
- Glassfish Server 3.1.2
- 网豆 7.3
- Glassfish 服务器 3.1.2
采纳答案by rockstar
The problem was that the mysql connector jar file was not placed into the glassfish server. This kicks in a series of problems. The one that I posted above is just one of the error messages that the server logs contains. I suggest going through the entire list of error message and try to debug from there. The following link helped me place the jar files at the correct location:
问题是mysql连接器jar文件没有放入glassfish服务器。这引发了一系列问题。我在上面发布的只是服务器日志中包含的错误消息之一。我建议查看整个错误消息列表并尝试从那里进行调试。以下链接帮助我将 jar 文件放在正确的位置:
回答by Schubert David Rodriguez
Since Netbeans 7.1 when the IDE generates the persistence.xml
the jta
field and glassfish-resouces
JDNI name is generated with a prefix java:module/
, it has to be deleted in both files, it has to look like jdbc/[anyName]
. This was tested on Netbeans 8.1 and Glassfish 4.0.
由于NetBeans 7.1时,IDE生成persistence.xml
的jta
领域和glassfish-resouces
JDNI名称与前缀产生的java:module/
,它在两个要删除的文件,它看起来像jdbc/[anyName]
。这是在 Netbeans 8.1 和 Glassfish 4.0 上测试的。
回答by Nallamachu
Here is another solution which I have found, it will be helpful to anyone.
这是我找到的另一个解决方案,它对任何人都有帮助。
Copy the resource name which you are facing the problem and follow the below steps.
复制您遇到问题的资源名称,然后按照以下步骤操作。
- Login into Glassfish console
- Goto Resources
- JDBC --> JDBC Resources
- Click on New button to add resource
- Enter the copied resource into JNDI name field and select the pool name and enter the description.
- Click on Ok button
- 登录 Glassfish 控制台
- 转到资源
- JDBC --> JDBC 资源
- 点击新建按钮添加资源
- 在 JNDI 名称字段中输入复制的资源并选择池名称并输入描述。
- 单击确定按钮
Redeploy the application and check.
重新部署应用程序并检查。
回答by Nallamachu
In my case I just moved my glassfish-resources.xml
file,
就我而言,我只是移动了我的glassfish-resources.xml
文件,
from:
从:
my_web_app / src / main / webapp / WEB-INF
my_web_app / src / main / webapp / WEB-INF
to:
到:
my_web_app / src / main / setup
my_web_app/src/main/ setup
And GlassFish started to recognize the file the created the resources.
GlassFish 开始识别创建资源的文件。