Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.4.1
-
* Java version: 1.8.0_40, vendor: Oracle Corporation
* Windows 7 Enterprise
* Apache Maven 3.2.3
Description
Details
Please see attached sample web application and run it via:
mvn clean compile jetty:run
At startup we can see huge stack trace that tells literally nothing.
2015-07-01 16:38:50.076:WARN:oeja.ServletContainerInitializersStarter:main: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:|Exception 0 :|java.lang.RuntimeException: Failed initializing mapping files at org.apache.deltaspike.data.impl.meta.unit.PersistenceUnitReader.extractMappings(PersistenceUnitReader.java:82) at org.apache.deltaspike.data.impl.meta.unit.PersistenceUnitReader.lookupUnits(PersistenceUnitReader.java:54) ...
Whereas the exception should look like:
javax.servlet.ServletException: Caused by: javax.persistence.PersistenceException: [PersistenceUnit: netadminPU] Unable to resolve named mapping-file [META-INF/jpql/named-queries.xml]
Because corruption is about pointing out to a not-existing mapping file named named-queries.xml
Known workarounds
- Of course we can fix the corrupted persistence.xml file, by removing line:
<mapping-file>META-INF/jpql/named-queries.xml</mapping-file> - We can also remove dependency to "deltaspike-data" from pom.xml as it solves the issue
Because then we got perfectly clear and correct message that tells us what is wrong with persistene.xml.
For further details, please see file README.md inside attached application.
BTW: Why does the DeltaSpike parse persistence.xml at application startup? Shouldn't this file be parsed with a lazy manner, at first usage of the EntityManagerFactory?