EclipseLink 2.5 no consulta persistence.xml

Creé un Struts 2 web app using a maven archetype. Now, when I deployed that project on tomcat7 y editado persistence.xml to change database config, it is not reflecting in Application. To test my theory, I removed persistence.xml del WEB-INF/classes/META-INF/. Even then what I am getting is this:-

Connection refused: connect
java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect. Error Code: 40000
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect. Error Code: 40000

I don't have any idea from what location it is fetching the Persistence configuration. Here is my persistence.xml:-

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="em" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>com.ankitsoft.entities.City</class>
    <class>com.ankitsoft.entities.Country</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:derby:C:\proLoc\WEB-INF\DB"/>
      <property name="javax.persistence.jdbc.password" value="ankit"/>
      <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
      <property name="javax.persistence.jdbc.user" value="ankit"/>
    </properties>
  </persistence-unit>
</persistence>

¿Alguien puede ayudarme?

preguntado el 28 de mayo de 14 a las 13:05

The persistence.xml picked up isn't the one you thought. Are there any others around in a meta-inf directory somewhere, perhaps in a jar file? How are you getting the exception, as you must be accessing the persistence unit somehow - you can add properties through code to that location to turn on logging. -

Hello @Chris, I am using apache manager web app to host my app. Now, I recently noticed, whenever I undeploy and again deploy the app, it refreshes its config settings. Even if I restart the application, it won't reload the new configuration. I have to re-deploy it. -

1 Respuestas

If you are calling the persistence.xml in a bundle, then org.eclipse.persistence.jpa must be started before your bundle (or bundles). It is therefore a good idea to always add org.eclipse.persistence as an imported package in your manifest

respondido 09 mar '21, 13:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.