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)
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.
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="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 :
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.
Also on the Glassfish server console the resource is correctly shown as FCKDatabase and not FCKDatabase_pm
Any idea where this __pm comes from ?
System:
Netbeans 7.3
Glassfish Server 3.1.2
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:
Connecting a MySQL database to Glassfish classpath is not set or classname is wrong
Blog Class name is wrong or classpath is not set for: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
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.
In the image, the second option shows the generated name, which is invalid en Glassfish because the ':'
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
Redeploy the application and check.
In my case I just moved my glassfish-resources.xml file,
from:
my_web_app / src / main / webapp / WEB-INF
to:
my_web_app / src / main / setup
And GlassFish started to recognize the file the created the resources.
Related
I'm having three xml files and in all of them the schema versions are defined. However I removed all the version and kept it as default one, But I'm having these error messages and my beans are not getting intialized. Please refer the attached image to see the errors:
ApplicationContext.xml file
SecurityConfig.xml file
Servlet-context.xml file
Spring-version : 5.3.19
Java version - 17
Maven - 3.8.7
Wildfly - 25
I've also tried to make the schema version as 5.3.19, by making that error goes away but at the runtime same error comes. Please help me in resolving this.
When injecting a simple CDI managed bean into a servlet (starting from the generated code sample "SimpleServlet"), when accessing the servlet, Bluemix Liberty logs this error :
"SimpleServlet cannot be injected as class
wasdev.sample.servlet.SimpleServlet is not in a bean archive."
This is so even when a beans.xml file with discovery "all" is used.The target looks like this
Reason for Error :
The error is due to not having a beans.xml in the built application war i.e. JavaHelloWorldApp.war
Currently, for performance reasons, the beans.xml file is always required in order to use CDI on Bluemix.
Solution :
Copied the bean.xml inside the /src/main/webapp/WEB-INF/beans.xml then built the code.
This made sure that the bean.xml is packaged into the war file i.e. JavaHelloWorldApp.war and the error is resolved.
To verify bean.xml is deployed correctly to Bluemix, select the java application on Bluemix console, click and open the java application dashboard. Select Runtime, select Files tab, browse and verify that the bean.xml is deployed correctly inside WEB-INF as shown in the snapshot below.
I've ported an application from JEE6 to JEE7 (glassfish 3.1.2.2 to 4.1),
I've upgraded the META-INF/validation.xml with latest version (as stated here): http://antoniogoncalves.org/2013/06/04/java-ee-7-deployment-descriptors/):
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.1.xsd"
version="1.1">
<message-interpolator>com.infomaxgroup.adaecommerce.validation.DatabaseMessageInterpolator</message-interpolator>
</validation-config>
The custom messageinterpolator is never called, so I've tried to set a name of a non existent class:
<message-interpolator>foo.foo.foo.Bar</message-interpolator>
and tried to insert an error (xxx after the opening tag):
<message-interpolatorxxx>foo.foo.foo.Bar</message-interpolator>
I've no exception into log, seems like that validation.xml (that my JEE6 application processes good) is not loaded at all into my ported JEE7 application...
Any idea on how to solve the issue ?
Many thanks in advance...
Solved from myself,
the problem was that validation.xml must be placed into META-INF/validation.xml folder of the "ejb module", into my JEE6 application I had that file into WEB-INF folder of the "web module" (strangely the JEE6 application works good...), now my JEE7 application correctly load validation.xml configuration and works using the message interpolator, very good !
I'm trying to deploy multiple instances of our service on our staging server, all on the same TomEE instance. They all have different context paths (platform_foo, platform_bar).
I'm getting an exception:
Caused by: org.apache.openejb.DuplicateDeploymentIdException: Application cannot be deployed as it contains deployment-ids which are in use: app: /var/www/apache-tomee-jaxrs-1.6.0/webapps/platform_foo
UsersService
SessionsService
My openejb-jar.xml:
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxrs.providers = <redacted>
</properties>
</pojo-deployment>
</openejb-jar>
I tried everything from setting an ID on the web-app element in web.xml, to setting the deployment-id in the openejb-jar.xml. Nothing seems to work.
Looks like someone has answered a similar question that I just didn't search for hard enough.
Tomcat / "Application cannot be deployed as it contains deployment-ids" error
Just deploy in another folder that webapp. I had same issue in tomEE and solved with this
I recently completed this tutorial: "http://static.springsource.org/docs/Spring-MVC-step-by-step/", but now I want it to work with Hibernate and annotations. I know I'm close but I've hit a roadblock and I can't figure it out. I've posted my code on the Spring forums here. I would greatly appreciate ANY help. Thanks
I'm trying to incorporate annotations and hibernate into it, but I've run into a problem and I can't figure it out. I keep getting errors of "No persistence unit with name 'product' found". ANY help would be greatly appreciated.
You need a META-INF/persistence.xml, with <persistence-unit name="product">. See here
(I usually put it in WEB-INF/classes/META-INF. As noted in the comments, with maven you can place it in src/main/resources/META-INF)
this is a example of file persistence.xml
<persistence 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"
version="2.0">
<persistence-unit name="poduct" transaction-type="RESOURCE_LOCAL">
</persistence-unit>
</persistence>
create this file inside "src/main/resources/META-INF" if you use Maven project.
I run onto the same problem and had to manually edit the Web Deployment Assembly Configuration so as to instruct /META-INF/persistence.xml to be deployed under WEB-INF/classes/ (the red box in the attached img was manually edited)
i have the same problem. But when you use the ide(for example eclipse) and configure your server in the ide. When you asosiate the piece and restart the server always have the same error because detected the persistence unit is used, you need delete that part of the server and deploy to the oldway. Enter to the console and install the peace of you project and works!!
And the other is when you check the diagnostic in wls you need said who user is the owner of the jdbc, only select and check (for example, AdminServer) and save and check again!!
:D