Plugin Not Working with a persistence.xml and annotations
---------------------------------------------------------

                 Key: MHIBERNATE-67
                 URL: http://jira.codehaus.org/browse/MHIBERNATE-67
             Project: Maven 2.x Hibernate Plugin
          Issue Type: Bug
          Components: hbm2ddl
    Affects Versions: 2.0
            Reporter: Tim O'Brien
            Assignee: Tim O'Brien
            Priority: Critical
             Fix For: 2.1


Email sent to user@ from Lawrence Li:

I'm trying to generate code that uses java annotations (jdk=true, ejb3=true - 
when using the Ant Hibernate tools for the hbm2java task) when running the 
hbm2java goal.  I'm trying to generate the code from my persistence.xml file.  
I'm sure I have my configuration incorrect, but I can't figure it out.  The 
error is listed below.  The error below seems to indicate it cannot parse my 
persistence.xml file, which is pasted here for your convenience:

<?xml version="1.0"?>

   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_1_0.xsd";
   version="1.0">
   <persistence-unit name="create831">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/DefaultDS</jta-data-source>
       <properties>
           <property name="hibernate.hbm2ddl.auto" value="validate" />
           <property name="hibernate.connection.driver_class"
               value="oracle.jdbc.driver.OracleDriver" />
           <property name="hibernate.connection.url"
               value="jdbc:oracle:thin:@test.com:1521:myDB" />
           <property name="hibernate.dialect"
               value="org.hibernate.dialect.OracleDialect" />
           <property name="hibernate.connection.username" value="username" />
           <property name="hibernate.connection.password"
               value="password" />
           <property name="hibernate.show_sql" value="true" />
           <property name="hibernate.format_sql" value="true" />
           <property name="jboss.entity.manager.factory.jndi.name"
               value="java:/create831EntityManagerFactory" />
       </properties>
   </persistence-unit>
</persistence>

Here's a snippet of my pom.xml:

<plugin>
               <groupId>org.codehaus.mojo</groupId>
               <artifactId>hibernate3-maven-plugin</artifactId>
               <version>2.0-alpha-2</version>
               <configuration>
                   <components>
                       <component>
                           <name>hbm2java</name>
                           <outputDirectory>
                               /src/main/java/
                           </outputDirectory>
                           <implementation>
                               annotationconfiguration
                           </implementation>
                       </component>
                   </components>
                   <componentProperties>
                       <jdk5>true</jdk5>
                       <ejb3>true</ejb3>
                       <drop>false</drop>
                       <configurationfile>
                           /src/main/resources/META-INF/persistence.xml
                       </configurationfile>
                   </componentProperties>
               </configuration>
           </plugin>

What is going on here?  Is the plugin able to generate code just from the 
persistence.xml file?  Also, where can I find more information on how to set 
options on the code generation?  I'm a little confused by the documentation.  

C:\create831>mvn hibernate3:hbm2java
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'hibernate3'.
Downloading: http://repo1.maven.org/maven2/oracle/jdbc/driver/oracle.jdbc.driver
/10.2.0.3/oracle.jdbc.driver-10.2.0.3.pom
[INFO] -------------------------------------------------------------------------
---
[INFO] Building Create EDI 831 file from EDI 820 file
[INFO]    task-segment: [hibernate3:hbm2java]
[INFO] -------------------------------------------------------------------------
---
[INFO] Preparing hibernate3:hbm2java
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
Downloading: http://repo1.maven.org/maven2/oracleApps/oracleApps/1.0/oracleApps-
1.0.pom
[INFO] [hibernate3:hbm2java]
[INFO] using annotationconfiguration task.
[INFO] Configuration XML file loaded: 
C:\create831\src\main\resources\META-INF\persistence.xml
17:58:46,851  INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations
3.2.0.GA
17:58:46,866  INFO org.hibernate.cfg.Environment - Hibernate 3.2.0.cr5
17:58:46,866  INFO org.hibernate.cfg.Environment - hibernate.properties not foun
d
17:58:46,866  INFO org.hibernate.cfg.Environment - Bytecode provider name : cgli
b
17:58:46,866  INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timest
amp handling
[INFO] Configuration XML file loaded: 
C:\create831\src\main\resources\META-INF\persistence.xml
17:58:46,913  INFO org.hibernate.cfg.Configuration - configuring from file: pers
istence.xml
17:58:46,960 ERROR org.hibernate.util.XMLHelper - Error parsing XML: 
C:\create831\src\main\resources\META-INF\persistence.xml(2) Document is 
invalid: no grammar found.
17:58:46,960 ERROR org.hibernate.util.XMLHelper - Error parsing XML: 
C:\create831\src\main\resources\META-INF\persist
ence.xml(2) Document root element "persistence", must match DOCTYPE root "null".

[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] invalid configuration
Document is invalid: no grammar found.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.hibernate.MappingException: invalid configuration
       at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1411)
       at org.hibernate.cfg.Configuration.configure(Configuration.java:1386)
       at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfigura
tion.doConfiguration(AbstractComponentConfiguration.java:74)
       at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfigura
tion.getConfiguration(AbstractComponentConfiguration.java:37)
       at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(
HibernateExporterMojo.java:186)
       at org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configure
Exporter(Hbm2JavaGeneratorMojo.java:69)
       at org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(Hibernat
eExporterMojo.java:241)
       at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateE
xporterMojo.java:140)
       at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:443)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:539)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone
Goal(DefaultLifecycleExecutor.java:493)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:463)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:311)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:278)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:143)
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
       at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
       at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
       at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

       at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.

       at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAX
ParseException(ErrorHandlerWrapper.java:236)
       at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Err
orHandlerWrapper.java:172)
       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
XMLErrorReporter.java:382)
       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
XMLErrorReporter.java:316)
       at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scan
StartElement(XMLNSDocumentScannerImpl.java:177)
       at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSCo
ntentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
       at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
       at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
       at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:834)
       at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:764)
       at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.
java:148)
       at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab
stractSAXParser.java:1242)
       at org.dom4j.io.SAXReader.read(SAXReader.java:465)
       at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1408)
       ... 25 more

Thanks in advance!


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to