SourceForge has been redesigned. Learn more.
Close

XSDtoDB SQL generation problem

Help
2008-01-21
2013-04-25
  • Simone Capuccini

    Hi, I'm an italian student using xsd to db tool for academic purpose. I'm trying to create an SQL script file for a database reflecting an XSD file but I get the following error.
    I tried it many times even with different XSD file like the sample contained in the pipedbutils. I get the same error even trying to load a DTD file. I'm using UBUNTU linux with java-6-sun-1.6.0.03. I don't know what to do at the moment.
    Here is the code.
    Thank you very much.

    thecaps@TheCapsUBUNTU:~/Desktop/xsd2db$ java -jar xsd2db.jar --xsdURL=file:/home/thecaps/Desktop/books.xsd
    1 [main] INFO org.hibernate.cfg.Environment  - Hibernate 3.0.5
    7 [main] INFO org.hibernate.cfg.Environment  - loaded properties from resource hibernate.properties: {hibernate.use_sql_comments=true, hibernate.connection.driver_class=org.postgresql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=postgres, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:postgresql://localhost:5432/uniprot, hibernate.show_sql=true, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
    8 [main] INFO org.hibernate.cfg.Environment  - using java.io streams to persist binary types
    8 [main] INFO org.hibernate.cfg.Environment  - using CGLIB reflection optimizer
    11 [main] INFO org.hibernate.cfg.Environment  - using JDK 1.4 java.sql.Timestamp handling

    Downloading books.xsd...
    Download successful...
    info: org.xml.sax.SAXParseException: Using Xerces from jar:file:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/rt.jar!/com/sun/org/apache/xerces/internal/impl/Version.class
    info: org.xml.sax.SAXParseException: generating code
    964 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Starting code augmentation.
    964 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Processing [5] class items.
    965 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Processing [Bookstore].
    968 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Processing [Book].
    968 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Processing [BookstoreType].
    968 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Processing [BookType].
    969 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Processing [AuthorName].
    969 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Finished processing class items.
    969 [main] DEBUG org.jvnet.jaxbcommons.equals.addon.AddOn  - Finished code augmentation.
    969 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Starting code augmentation.
    969 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Processing [5] class items.
    969 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Processing [Bookstore].
    969 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Processing [Book].
    970 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Processing [BookstoreType].
    970 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Processing [BookType].
    970 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Processing [AuthorName].
    970 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Finished processing class items.
    970 [main] DEBUG org.jvnet.jaxbcommons.hashcode.addon.AddOn  - Finished code augmentation.
    1039 [main] DEBUG org.jvnet.hyperjaxb2.addon.AddOn  - Processing class item [Bookstore].
    1096 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing class [Bookstore]
    1124 [main] DEBUG org.jvnet.hyperjaxb2.addon.AddOn  - Processing class item [Book].
    1124 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing class [Book]
    1124 [main] DEBUG org.jvnet.hyperjaxb2.addon.AddOn  - Processing class item [BookstoreType].
    1124 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing class [BookstoreType]
    1125 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing field [BookstoreType.Book]
    1252 [main] DEBUG org.jvnet.hyperjaxb2.addon.AddOn  - Processing class item [BookType].
    1252 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing class [BookType]
    1253 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing field [BookType.Price]
    1270 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing field [BookType.Author]
    1287 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing field [BookType.Genre]
    1287 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing field [BookType.Title]
    1288 [main] DEBUG org.jvnet.hyperjaxb2.addon.AddOn  - Processing class item [AuthorName].
    1289 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing class [AuthorName]
    1289 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing field [AuthorName.FirstName]
    1289 [main] DEBUG org.jvnet.jaxbcommons.visitor.ClassifyingVisitor  - Processing field [AuthorName.LastName]
    Exception in thread "main" java.lang.AbstractMethodError: org.apache.xerces.dom.DocumentImpl.getXmlStandalone()Z
            at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:373)
            at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:127)
            at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:94)
            at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:663)
            at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:709)
            at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
            at org.jvnet.hyperjaxb2.hibernate.mapping.utils.HibernateMappingUtils.marshall(HibernateMappingUtils.java:64)
            at org.jvnet.hyperjaxb2.addon.AddOn.run(AddOn.java:118)
            at edu.lmu.xmlpipedb.xsd2db.Xsd2db.run(Xsd2db.java:253)
            at edu.lmu.xmlpipedb.xsd2db.Xsd2dbCommandLine.run(Xsd2dbCommandLine.java:162)
            at edu.lmu.xmlpipedb.xsd2db.Xsd2dbCommandLine.main(Xsd2dbCommandLine.java:150)

     
    • dondi

      dondi - 2008-01-22

      Hello Simone,

      We haven't moved to Java 1.6 yet in XMLPipeDB, and the difference in versions appears to be the issue.  Note this line in the error log:

      > info: org.xml.sax.SAXParseException: Using Xerces from jar:file:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/rt.jar!/com/sun/org/apache/xerces/internal/impl/Version.class

      This indicates that you're using the Xerces implementation that resides in your Java 1.6 installation.  The AbstractMethodError typically indicates a reference to a method that is not present in the loaded version of a class --- something that can happen when you are using code that is expecting one version of some library (Xerces) but is actually using another.

      As a workaround, would it be possible in your case to switch to the latest Java 1.5 JDK, and try it from there?  It works from our end in Java 1.5.

      Hope this helps...

       
    • Simone Capuccini

      Thank you very much. Using Java 1.5 it works great. I'm now able to generate SQL mapping schema for any kind of XSD and then a MySQL DB. My goal was to load  XML information from an XML file into the database created with XSDtoDB according with the loaded schema. I read the whole manual available on this site and understood that the ImportEngine class should do this, but it doesn't explain how to use it (in particular the "?input stream?" to pass to the loadtoDB() method..). I'd like to store the XML file automatically into the previously generated DB (without any GUI) for my degree project.

       
      • dondi

        dondi - 2008-01-24

        Hello Simone,

        Sorry if the manual was unclear on this.  At this point, the functionality becomes the same as a combination of JAXB and Hibernate, so I would refer you to the documentation of those respective projects.

        As an overview, what you need to do is:

        1. Use JAXB to read an XML file that conforms to the XSD that you used, then convert it into a Java object tree.  The InputStream that you referred to is one of many ways to send an XML file into JAXB, and happens to be the one that ImportEngine uses.  You can derive an InputStream from any file.

        2. A successful JAXB read should produce a single Java object that represents the top-level tag of the XML file that you used.  "Within" this Java object are all of the other objects that correspond from the tags nested inside the top-level tag.

        3. At this point, you then use Hibernate.  Open a Hibernate session to your database (per the Hibernate documentation) then save the Java object using that session.  For this part, especially configuration, use the Hibernate documentation.

        The XMLPipeDBUtilities classes are mainly for a GUI shell; to use these functions without a GUI, go directly to the JAXB and Hibernate APIs.  You can look at the code inside ImportEngine to see how those methods are used, then just use those as a pattern for your own program.  Also, we haven't really moved to the very latest versions of JAXB and Hibernate; XMLPipeDB was written with JAXB 1.x and Hibernate 2.x.  The latest JAXB (2.x) and Hibernate (3.x) may be backward-compatible, but so far we haven't tested this for ourselves.

        Good luck on your degree project!

         
    • sabrina a

      sabrina a - 2008-11-05

      Hi, my doubt is similar to the one from  Simone. I am a brazilian student trying to use XMLPipeDb for academic purpose. My objective is load data from XML files into the database created with XSDtoDb without use a GUI. I read the manual and I understood that the method loadToDB should do this but I didn't understand how to instantiate an ImportEngine. Reading the manual it seemed to me that I should use the ConfigurationEngine class too, but I didn't understand how. Could you help me to understand this, please?

      Should I use XMLPipeDBUtilities? If not, I would like to look at the code inside ImportEngine and ConfigurationEngine to use as a pattern for my program as you suggested for Simone. I found only files with extension .jar (the compiled classes) to download. Where can I download the source code (files with extension .java)?

      Thank you very much,

      Sabrina Azevedo.

       
      • dondi

        dondi - 2008-11-05

        Hi Sabrina,

        Yes, you can use the code in XMLPipeDB Utilities as a pattern for loading XML files into the relational database without a GUI.  To see it top-to-bottom, look at the sample/ application.  While this application does have a GUI, you can essentially follow the same logic.  The GUI mainly allows the user to choose a file.  If you take that segment out and replace it with some other mechanism for determining the XML file to load, you can "skip" to the import call (i.e., whatever gets triggered with then import button in the GUI is clicked).

        All of this code can be seen in the Subversion browser, or via anonymous Subversion checkout, under /trunk/xmlpipedbutils.  Hope this helps.

         

Log in to post a comment.