Bug 777899 (SOA-427)

Summary: DB schema tool generates hibernate.cfg.xml with syntax error
Product: [JBoss] JBoss Enterprise SOA Platform 4 Reporter: Aleksandar Kostadinov <akostadinov>
Component: ToolingAssignee: Mike Brock <cbrock>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: urgent Docs Contact:
Priority: urgent    
Version: 4.2 CR3CC: jcoleman, rruss
Target Milestone: ---   
Target Release: 4.2 CP01   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/SOA-427
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-04-09 19:53:30 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:
Bug Depends On:    
Bug Blocks: 777558    
Attachments:
Description Flags
server.log.gz none

Description Aleksandar Kostadinov 2008-02-14 09:03:03 UTC
Date of First Response: 2008-02-14 21:22:48
project_key: SOA

Currently one can't configure SOA-P to use oracle 9i (10g not yet tested) using the SOA-P included schema tool. The dbinstall tool written by Jiri Pechanek does *not* have these issues present.

With help from Jiri Pechanec 2 issues identified:
1. build.xml contains a check for database name and allows only mysql, postgresql, oracle9i and oracle10g. It should allow mysql, postgresql and oracle. As well there should be another option commented in build.properties source.dir which selects database directory overriding the database name property. 
So configuration for oracle 9i should be:
org.jboss.esb.server.database=oracle
source.dir=oracle9i

2. After modifying build.xml to skip this check and configure database with the above properties I get the following exception on server startup:

 02:14:44,071 ERROR [MainDeployer] Could not create deployment: file:/qa/home/akostadinov/quickstart_tests/jbosssoa/jboss-as/server/all/deploy/oracle-ds.xml
org.jboss.deployment.DeploymentException: Trying to install an already registered mbean: jboss.jca:service=LocalTxCM,name=DefaultDS
        at org.jboss.system.ServiceCreator.install(ServiceCreator.java:103)
        at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:449)
        at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171)
        at org.jboss.system.ServiceController.install(ServiceController.java:226)
        at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy4.install(Unknown Source)
        at org.jboss.deployment.SARDeployer.create(SARDeployer.java:249)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy52.create(Unknown Source)
        at org.jboss.deployment.XSLSubDeployer.create(XSLSubDeployer.java:192)
        at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy9.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy4.start(Unknown Source)
        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy5.deploy(Unknown Source)
        at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
        at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
        at org.jboss.Main.boot(Main.java:200)
        at org.jboss.Main$1.run(Main.java:508)
        at java.lang.Thread.run(Thread.java:595)
<snip/>
--- Incompletely deployed packages ---
org.jboss.deployment.DeploymentInfo@4b717870 { url=file:/qa/home/akostadinov/quickstart_tests/jbosssoa/jboss-as/server/all/deploy/oracle-ds.xml }
  deployer: org.jboss.deployment.XSLSubDeployer@7691c0
  status: Deployment FAILED reason: Trying to install an already registered mbean: jboss.jca:service=LocalTxCM,name=DefaultDS
  state: FAILED
  watch: file:/qa/home/akostadinov/quickstart_tests/jbosssoa/jboss-as/server/all/deploy/oracle-ds.xml
  altDD: null
  lastDeployed: 1202973284064
  lastModified: 1202973284000
  mbeans:

Comment 1 Joshua Wulf 2008-02-15 02:22:48 UTC
Release Notes text:

The directory <install-directory>/jboss-as/tools/schema contains scripts to automatically reconfigure the platform to use the database of your choice. Instructions on using these scripts are included as comments in the file build.properties. The instructions in this file relating to Oracle 9i and 10g databases are incorrect. When configuring an Oracle 9i or 10g database the correct parameters to specify are as follows:

org.jboss.esb.server.database=oracle 
source.dir=oracle9i

or:

org.jboss.esb.server.database=oracle 
source.dir=oracle10g


Comment 2 Aleksandar Kostadinov 2008-02-15 08:08:43 UTC
No, that will not work as well!

Actually you need to checkout the original dbinstall tool (inside the vpn) and use it with the above described properties.

See again issue description. I mention there that even if one modifies the build.xml and configures oracle with the schema tool, there is the exception thrown.

Comment 3 Aleksandar Kostadinov 2008-02-15 08:09:19 UTC
inside the VPN and having allowed jboss.corp login and password...

Comment 4 Aleksandar Kostadinov 2008-02-26 14:59:54 UTC
Link: Added: This issue is a dependency of SOA-62


Comment 5 Mike Brock 2008-03-05 06:43:41 UTC
fixed merged.

Comment 6 Aleksandar Kostadinov 2008-03-12 05:47:14 UTC
Thanks, I'll verify that when next candidate release is out.

Comment 7 Joshua Wulf 2008-03-31 14:55:34 UTC
Please also refer to SOA-482

Comment 8 Len DiMaggio 2008-04-07 20:19:08 UTC
Still broken in CP01.

If the problem in SOA-499 is worked-around by copying the JDBC connector jar to the server/<name>/lib dir, this error is seen when the server starts:




16:05:30,414 INFO  [Configuration] configuring from resource: hibernate.cfg.xml
16:05:30,414 INFO  [Configuration] Configuration resource: hibernate.cfg.xml
16:05:30,584 ERROR [XMLHelper] Error parsing XML: hibernate.cfg.xml(56) The string "--" is not permitted within comments.
16:05:30,586 ERROR [JobExecutorThread] exception in job executor thread. waiting 5000 milliseconds
org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
        at org.jbpm.db.hibernate.HibernateHelper.createConfiguration(HibernateHelper.java:91)
        at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration(DbPersistenceServiceFactory.java:69)
        at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91)
        at org.jbpm.persistence.jta.JtaDbPersistenceService.isCurrentJtaTransactionAvailable(JtaDbPersistenceService.java:46)
        at org.jbpm.persistence.jta.JtaDbPersistenceService.<init>(JtaDbPersistenceService.java:27)
        at org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory.openService(JtaDbPersistenceServiceFactory.java:17)
        at org.jbpm.svc.Services.getService(Services.java:144)
        at org.jbpm.svc.Services.getPersistenceService(Services.java:183)
        at org.jbpm.JbpmContext.getPersistenceService(JbpmContext.java:628)
        at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:561)
        at org.jbpm.job.executor.JobExecutorThread.acquireJobs(JobExecutorThread.java:112)
        at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:58)
Caused by: org.dom4j.DocumentException: Error on line 56 of document  : The string "--" is not permitted within comments. Nested exception: The string "--" is not permitted within comments.
        at org.dom4j.io.SAXReader.read(SAXReader.java:482)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
        ... 13 more


Here's the offending line - see line 56 - in jboss-soa-p-standalone.4.2.0/jboss-as/server/default//deploy/jbpm.esb/hibernate.cfg.xml

    52      <!-- identity mappings (begin) === --> --> -->
    53      <mapping resource="org/jbpm/identity/User.hbm.xml"/>
    54      <mapping resource="org/jbpm/identity/Group.hbm.xml"/>
    55      <mapping resource="org/jbpm/identity/Membership.hbm.xml"/>
    56      <!-- <!-- <!-- ==== identity mappings (end) -->
    57      
    58      <!-- following mapping files have a dependendy on  -->
    59      <!-- the JCR API                                   -->



Comment 9 Len DiMaggio 2008-04-07 20:19:41 UTC
Server log for April 7 comment/reopen


Comment 10 Len DiMaggio 2008-04-07 20:19:41 UTC
Attachment: Added: server.log.gz


Comment 11 Len DiMaggio 2008-04-08 01:59:54 UTC
In the April 4 CP01 build - the original bug is replaced by a new one.

The schema tool generates a broken hibernate.cfg.xml file - see line 56.

Here are the diffs between the file as shipped (with the hsql/h2 config) and after the schema tool is run - in this case with a postgresql database:


[ldimaggi@ldimaggi Desktop]$ diff hibernate.cfg.xml hibernate.cfg.xml_after_DB_config 

11c11
<     <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
---
>     <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
52c52
<     <!-- identity mappings (begin) ===
---
>     <!-- identity mappings (begin) === --> -->
56c56
<     ==== identity mappings (end) -->
---
>     <!-- <!-- ==== identity mappings (end) -->


Comment 12 Len DiMaggio 2008-04-08 02:04:35 UTC
Link: Added: This issue related SOA-499


Comment 14 Julian Coleman 2008-04-08 12:21:01 UTC
I think the problem is that the string replacement in the build.xml cannot be applied more than once.  If it is applied subsequently, only part of the line matches and thus the extra <!-- or --> appear.

A fix would be to change the build.xml (build = jboss-soa-p-standalone.4.2.0/jboss-as/tools/schema source = build-tools/resource/schema/esb/build.xml) as follows:

-- 8< --
--- build.xml.dist	2008-04-08 09:43:50.000000000 +0100
+++ build.xml	2008-04-08 13:09:47.000000000 +0100
@@ -104,6 +104,20 @@
             </sequential>
         </macrodef>
 
+        <macrodef name="reconfigureregex">
+            <attribute name="file"/>
+            <attribute name="old"/>
+            <attribute name="new"/>
+            <sequential>
+                <move file="@{file}" tofile="@{file}.orig"/>
+                <move file="@{file}.orig" tofile="@{file}">
+                    <filterchain>
+                        <replaceregex pattern="@{old}" replace="@{new}"/>
+                    </filterchain>
+                </move>
+            </sequential>
+        </macrodef>
+
         <!--<delete dir="${target.dir}"/>-->
         <!--<mkdir dir="${target.dir}"/>-->
 
@@ -215,10 +229,10 @@
                      new="${hibernate.dialect}"/>
 
         <!-- Enable Identity componnent in jBPM -->
-        <reconfigure file="${target.dir}/deploy/jbpm.esb/hibernate.cfg.xml" old="&lt;!-- identity mappings (begin) ==="
+        <reconfigureregex file="${target.dir}/deploy/jbpm.esb/hibernate.cfg.xml" old="&lt;!-- identity mappings \(begin\) ===$"
                      new="&lt;!-- identity mappings (begin) === --&gt;"/>
-        <reconfigure file="${target.dir}/deploy/jbpm.esb/hibernate.cfg.xml" old="==== identity mappings (end) --&gt;"
-                     new="&lt;!-- ==== identity mappings (end) --&gt;"/>
+        <reconfigureregex file="${target.dir}/deploy/jbpm.esb/hibernate.cfg.xml" old="^    ==== identity mappings \(end\) --&gt;$"
+                     new="    &lt;!-- ==== identity mappings (end) --&gt;"/>
 
 
         <reconfigure file="${target.dir}/deploy/jbossesb.sar/esb.juddi.xml" old="juddi-sql/hsqldb/"

-- 8<---

Comment 15 Mike Brock 2008-04-08 14:54:18 UTC
fixed in trunk.

Comment 16 Len DiMaggio 2008-04-08 15:45:38 UTC
Setting blocker flag

Comment 17 Len DiMaggio 2008-04-09 19:53:30 UTC
Verified fixed in CP01, April 9 build (CR3) 

Comment 18 Len DiMaggio 2008-04-24 23:32:20 UTC
Link: Added: This issue is a dependency of SOA-524


Comment 19 Len DiMaggio 2008-04-25 16:21:18 UTC
Link: Removed: This issue is a dependency of SOA-524