Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2779

ReverseMappingTool doesn't load persistence.xml

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.0
    • Fix Version/s: None
    • Component/s: jdbc
    • Labels:
      None
    • Environment:

      Description

      Steps to reproduce:

      1. download the openjpa zip for version 3.0.0, decompress it into a directory
      2. download the mariadb jdbc driver into the same directory
      3. in the same directory, create a subdirectory META-INF, then create a persistence.xml file, based on the model from this page
      4. create another directory, named src, inside the directory where the jars are
      5. replace the database url, driver name, username and password with values specific to the local setup
      6. run this command:
      java -cp ./:mariadb-java-client-2.4.0.jar:openjpa-all-3.0.0.jar org.apache.openjpa.jdbc.meta.ReverseMappingTool -pkg entities -d ./src

      Expected: for each table in the database appearing in the url, an entity class is generated inside the entities package.

      Actual: a stack trace is printed to stdout:

      9  INFO   [main] openjpa.Tool - The reverse mapping tool will run on the database.  The tool is gathering schema information; this process may take some time.  Enable the org.apache.openjpa.jdbc.Schema logging category to see messages about schema data.
      Exception in thread "main" <openjpa-3.0.0-r422266:1833209 fatal user error> org.apache.openjpa.util.UserException: The persistence provider is attempting to use properties in the persistence.xml file to resolve the data source. A Java Database Connectivity (JDBC) driver or data source class name must be specified in the openjpa.ConnectionDriverName or javax.persistence.jdbc.driver property. The following properties are available in the configuration: "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@f248234b". 
              at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:71)
              at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:850)
              at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:733)
              at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDataSource(JDBCConfigurationImpl.java:879)
              at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDataSource2(JDBCConfigurationImpl.java:921)
              at org.apache.openjpa.jdbc.schema.SchemaGenerator.<init>(SchemaGenerator.java:86)
              at org.apache.openjpa.jdbc.meta.ReverseMappingTool.run(ReverseMappingTool.java:2027)
              at org.apache.openjpa.jdbc.meta.ReverseMappingTool.run(ReverseMappingTool.java:2005)
              at org.apache.openjpa.jdbc.meta.ReverseMappingTool.run(ReverseMappingTool.java:1882)
              at org.apache.openjpa.jdbc.meta.ReverseMappingTool$1.run(ReverseMappingTool.java:1863)
              at org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:762)
              at org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:747)
              at org.apache.openjpa.jdbc.meta.ReverseMappingTool.main(ReverseMappingTool.java:1858)

      I downloaded the source code, and tried to run the same task in the IDE. I can't find any place in the code where the file META-INF/persistence.xml is loaded, so this is pretty much expected behavior, from how much I understood after spending half an hour or so with the source code.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Anonymous Coward Florin Jurcovici
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: