Bug 801406

Summary: Invalid persistent.xml descriptor in the Petclinic example
Product: [Retired] JBoss Enterprise WFK Platform 2 Reporter: Karel Piwko <kpiwko>
Component: SpringAssignee: Tejas Mehta <tmehta>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Tomas Repel <trepel>
Severity: low Docs Contact:
Priority: medium    
Version: 2.0.0.ER2CC: jowilson, mnovotny, myarboro, ppenicka, rruss, snagarwa, trepel
Target Milestone: ---   
Target Release: 2.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: jbds petclinic
Fixed In Version: Doc Type: Known Issue
Doc Text:
When importing the Petclinic example application into JBoss Developer Studio 6, a persistence.xml file with invalid contents is created in the src/main/resources/META-INF/ directory. During deployment , this file has higher priority than the correct src/main/environments/eap-jpa/resources/META-INF/persistence.xml file, and the deployment fails. To work around this issue, remove the invalid src/main/resources/META-INF/persistence.xml file before deploying the application.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-22 19:31:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Petclinic war file, WFK2 ER5, build with eap-jpa profile none

Description Karel Piwko 2012-03-08 13:17:47 UTC
Description of problem:

When Petclinic example is deployed on EAP6, following error is show in console log: 

14:14:22,897 ERROR [org.hibernate.internal.util.xml.ErrorLogger] (MSC service thread 1-1) HHH000196: Error parsing XML (5) : cvc-complex-type.3.1: Value '1.0' of attribute 'version' of element 'entity-mappings' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '2.0'.


Version-Release number of selected component (if applicable):

Distributed petclinic example.

How reproducible:

Always.

Steps to Reproduce:
1. Deploy petclinic
  
Actual results:

Error message.

Expected results:

Parser recovers from the issue, it has no effect on application.

No error message.
Additional info:

Comment 1 Marius Bogoevici 2012-03-08 16:18:37 UTC
This is extremely odd. Is that to say that EAP6 is not backwards compatible with JPA 1.0?

Comment 2 Marius Bogoevici 2012-03-09 03:56:56 UTC
Trying to reproduce it myself, I don't get the same error against ER3. Rather, there's a NPE when the PU is bound in JNDI from web.xml (the cause of which I cannot really understand).

Comment 3 Marius Bogoevici 2012-03-09 05:22:37 UTC
Found https://issues.jboss.org/browse/JBPAPP-8397 which affects the deployment of Petclinic.

Comment 4 Marius Bogoevici 2012-03-09 05:31:49 UTC
Reproduced error reported in this ticket.

a) this does not cause the deployment to fail
b) the error message is coming from Hibernate and it's spurious - JPA 1.0 deployment should be allowed 

(tracked by https://issues.jboss.org/browse/JBPAPP-8398)

Comment 5 Karel Piwko 2012-03-12 17:43:54 UTC
Still it causes deployment exception for me:

18:36:43,234 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.persistenceunit."petclinic.war#petclinic": org.jboss.msc.service.StartException in service jboss.persistenceunit."petclinic.war#petclinic": Failed to start service
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_27]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_27]
	at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_27]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: petclinic] Unable to build EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
	at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
	at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
	... 3 more
Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
	at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:97)
	at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:67)
	at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:174)
	at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
	at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)
	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)
	at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
	... 9 more

18:36:43,452 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "petclinic.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"petclinic.war#petclinic\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"petclinic.war#petclinic\": Failed to start service"}}
18:36:43,487 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment petclinic.war in 35ms
18:36:43,488 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.persistenceunit."petclinic.war#petclinic": org.jboss.msc.service.StartException in service jboss.persistenceunit."petclinic.war#petclinic": Failed to start service

18:36:43,489 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"petclinic.war#petclinic\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"petclinic.war#petclinic\": Failed to start service"}}}}

Comment 6 Marius Bogoevici 2012-03-12 20:14:53 UTC
Added technical note, assigning to Rebecca

Comment 7 Marius Bogoevici 2012-03-12 20:14:53 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
During the import of the Petclinic project in JBDS, a default persistence.xml file with invalid contents is created under src/main/resources/META-INF. During deployment, this will supersede the correct one, to be found in src/main/environments/eap/resources/META-INF and will cause the deployment to fail. The solution in this case is to remove the src/main/resources/META-INF/persistence.xml file created during import.

Comment 8 Rebecca Newton 2012-03-13 02:31:53 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-During the import of the Petclinic project in JBDS, a default persistence.xml file with invalid contents is created under src/main/resources/META-INF. During deployment, this will supersede the correct one, to be found in src/main/environments/eap/resources/META-INF and will cause the deployment to fail. The solution in this case is to remove the src/main/resources/META-INF/persistence.xml file created during import.+During the import of the Petclinic project in JBDS, a default persistence.xml file with invalid contents is created under src/main/resources/META-INF. During deployment, this will supersede the correct one, to be found in src/main/environments/eap/resources/META-INF and will cause the deployment to fail. The workaround for this issue is to remove the src/main/resources/META-INF/persistence.xml file created during import.

Comment 9 JBoss JIRA Server 2012-03-13 04:26:11 UTC
Strong Liu <stliu> made a comment on jira JBPAPP-8398

https://hibernate.onjira.com/browse/HHH-6271

Comment 10 JBoss JIRA Server 2012-03-19 15:40:33 UTC
Strong Liu <stliu> updated the status of jira JBPAPP-8398 to Resolved

Comment 11 JBoss JIRA Server 2012-04-12 21:59:07 UTC
Scott Marlow <scott.marlow> made a comment on jira JBPAPP-8397

Probably easiest if I recreate locally.

Comment 12 JBoss JIRA Server 2012-04-12 22:27:35 UTC
Scott Marlow <scott.marlow> made a comment on jira JBPAPP-8397

I'm not sure what is causing the race yet.  From the [console output|https://gist.github.com/2002699] I can see the "Read persistence.xml" occurs first as expected (which comes from PersistenceUnitParseProcessor that runs during the PARSE deployment phase).

The NPE comes from the PersistenceRefProcessor which runs during the POST_MODULE phase.

We have our deployment phases providing the expected separation, deployment will complete the parsing of persistence.xml files, before any deployment threads try to read the result of parsing the persistence.xml.

I think its a thread safety bug in PersistenceUnitMetadataHolder.  Not sure why I didn't hit that before.

Can someone attach the petclinic.war to this jira, so I can recreate and then verify the fix.

Comment 13 JBoss JIRA Server 2012-04-12 23:14:28 UTC
Scott Marlow <scott.marlow> made a comment on jira JBPAPP-8397

Created a (AS7-4493) pull request to address the thread safety issue in PersistenceUnitMetadataHolder.

Comment 14 JBoss JIRA Server 2012-04-17 14:52:04 UTC
Scott Marlow <scott.marlow> made a comment on jira JBPAPP-8397

The thread safety fix for AS7-4493 has been merged to AS7 master.

Comment 15 JBoss JIRA Server 2012-05-03 16:21:21 UTC
Shelly McGowan <smcgowan> updated the status of jira JBPAPP-8397 to Resolved

Comment 16 JBoss JIRA Server 2012-05-15 14:58:14 UTC
Zbyněk Roubalík <zroubali> updated the status of jira JBPAPP-8398 to Closed

Comment 17 JBoss JIRA Server 2012-05-15 14:58:14 UTC
Zbyněk Roubalík <zroubali> made a comment on jira JBPAPP-8398

Verified on EAP 6.0.0.ER7

Comment 18 Tomas Repel 2012-05-15 15:25:43 UTC
Created attachment 584693 [details]
Petclinic war file, WFK2 ER5, build with eap-jpa profile

Comment 19 JBoss JIRA Server 2012-05-16 08:24:46 UTC
Zbyněk Roubalík <zroubali> updated the status of jira JBPAPP-8397 to Closed

Comment 20 JBoss JIRA Server 2012-05-16 08:24:46 UTC
Zbyněk Roubalík <zroubali> made a comment on jira JBPAPP-8397

Verified on EAP 6.0.0.ER7

Comment 21 JBoss JIRA Server 2012-06-01 06:29:18 UTC
Misty Stanley-Jones <misty> updated the status of jira JBPAPP-8398 to Reopened

Comment 22 JBoss JIRA Server 2012-06-01 06:29:18 UTC
Misty Stanley-Jones <misty> made a comment on jira JBPAPP-8398

Reopening for release note.

Comment 23 JBoss JIRA Server 2012-06-01 06:29:56 UTC
Misty Stanley-Jones <misty> updated the status of jira JBPAPP-8398 to Resolved

Comment 25 Tomas Repel 2012-06-01 11:49:41 UTC
Verified in WFK2 ER6 using JBDS 5.0.0.Beta3. The workaround described in Technical Notes still has to be used.

Comment 27 Isaac Rooskov 2012-08-13 03:52:04 UTC
Who handles the code examples for WFK? I'd like to get this issue assigned to the correct person so it doesn't get missed for WFK 2.1.

Thanks, 

Isaac

Comment 30 Marek Novotny 2012-10-11 08:42:15 UTC
*** Bug 824380 has been marked as a duplicate of this bug. ***

Comment 32 Tejas Mehta 2013-02-28 19:48:51 UTC
Tested with jbdevstudio-product-eap-universal-6.0.0.GA:

JBDS still adds a persistence.xml to src/main/resources/META-INF/ when importing, which continues to prevent pet-clinic from deploying. Workaround to delete the generated file (src/main/resources/META-INF/persistence.xml) works.

Comment 34 Petr Penicka 2013-04-08 15:08:19 UTC
Release note added to WFK 2.2 RN book.

Docs stage URL: https://documentation-devel.engineering.redhat.com/docs/en-US/JBoss_Web_Framework_Kit/2.2/html-single/2.2.0_Release_Notes/index.html

Build: JBoss_Web_Framework_Kit-2.2.0_Release_Notes-2.2-en-US-0-18

Comment 35 Tomas Repel 2013-04-17 11:57:48 UTC
Verified, release note added properly.

Comment 41 Sneha 2013-07-04 12:06:06 UTC
Updated doc text.

Comment 42 Joshua Wilson 2013-07-22 19:31:48 UTC
Migrated to JIRA.