- This topic has 6 replies, 3 voices, and was last updated 18 years, 6 months ago by AzCoder.
-
AuthorPosts
-
elabuschagneParticipantHi all,
I’m fairly new to Java and all the tools available to it, so please bear with me if I’m missing something obvious.
I need to switch off DTD validtation when running the hbm2ddl tool.
I’m generating the hibernate mapping files from POJOs using XDoclet annotations. Then I use the hbm2ddl tool to generate the schema in a PostgreSQL database.
All works great, I do have one irritatiing little problem. I want to work on my project using my laptop offline.
This causes problems with getting to the DTD files as I’m not online. I can fix this by chaning the location of the DTD in the hbm.xml files to point to a local DTD file.
Of course, every time I run XDoclet againg, my edits are overwritten and I have to edit ALL the mapping files by hand again.
Is there a way to either switch off DTD validation or to change the way XDoctet generates the mapping files to point to a local DTD?
I’ve Google’d and searched in this forum for an anwer, so far to no avail.
Thanks
Etienne
elabuschagneParticipantOne more thing, here is the Ant build file I use to run the hbm2ddl process:
<?xml version="1.0"?> <project name="HealthWindow2" default="hibernateschemaexport"> <description> HealthWindow 2 </description> <target name="hibernateschemaexport"> <taskdef name="hibernateschemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask" > </taskdef> <hibernateschemaexport config="etc/hibernate.cfg.xml" quiet="no" text="no" drop="no" delimiter=";" output="etc/schema-export.sql"> <fileset dir="src"><include name="**/*.hbm.xml"/> </fileset> </hibernateschemaexport> </target> </project>
and the thrown exception, trying to run it offline:
Buildfile: D:\!data\!Projects\eclipse\healthwindow2\build.xml hibernateschemaexport: [hibernateschemaexport] 2006/05/20 09:35:43 org.hibernate.cfg.Environment <clinit> [hibernateschemaexport] INFO: Hibernate 3.0.5 [hibernateschemaexport] 2006/05/20 09:35:43 org.hibernate.cfg.Environment <clinit> [hibernateschemaexport] INFO: hibernate.properties not found [hibernateschemaexport] 2006/05/20 09:35:43 org.hibernate.cfg.Environment <clinit> [hibernateschemaexport] INFO: using CGLIB reflection optimizer [hibernateschemaexport] 2006/05/20 09:35:43 org.hibernate.cfg.Environment <clinit> [hibernateschemaexport] INFO: using JDK 1.4 java.sql.Timestamp handling [hibernateschemaexport] 2006/05/20 09:35:43 org.hibernate.cfg.Configuration configure [hibernateschemaexport] INFO: configuring from file: hibernate.cfg.xml [hibernateschemaexport] 2006/05/20 09:35:43 org.hibernate.cfg.Configuration doConfigure [hibernateschemaexport] INFO: Configured SessionFactory: null [hibernateschemaexport] 2006/05/20 09:35:44 org.hibernate.cfg.Configuration addFile [hibernateschemaexport] INFO: Mapping file: D:\!data\!Projects\eclipse\healthwindow2\src\com\healthwindow2\business\Address.hbm.xml [hibernateschemaexport] 2006/05/20 09:35:44 org.hibernate.cfg.Configuration addFile [hibernateschemaexport] SEVERE: Could not configure datastore from file: D:\!data\!Projects\eclipse\healthwindow2\src\com\healthwindow2\business\Address.hbm.xml [hibernateschemaexport] org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net [hibernateschemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:484) [hibernateschemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:264) [hibernateschemaexport] at org.hibernate.cfg.Configuration.addFile(Configuration.java:226) [hibernateschemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195) [hibernateschemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135) [hibernateschemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [hibernateschemaexport] at org.apache.tools.ant.Task.perform(Task.java:364) [hibernateschemaexport] at org.apache.tools.ant.Target.execute(Target.java:341) [hibernateschemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369) [hibernateschemaexport] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [hibernateschemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [hibernateschemaexport] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [hibernateschemaexport] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) [hibernateschemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [hibernateschemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) [hibernateschemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) [hibernateschemaexport] Nested exception: [hibernateschemaexport] java.net.UnknownHostException: hibernate.sourceforge.net [hibernateschemaexport] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177) [hibernateschemaexport] at java.net.Socket.connect(Socket.java:507) [hibernateschemaexport] at java.net.Socket.connect(Socket.java:457) [hibernateschemaexport] at sun.net.NetworkClient.doConnect(NetworkClient.java:157) [hibernateschemaexport] at sun.net.www.http.HttpClient.openServer(HttpClient.java:365) [hibernateschemaexport] at sun.net.www.http.HttpClient.openServer(HttpClient.java:477) [hibernateschemaexport] at sun.net.www.http.HttpClient.<init>(HttpClient.java:214) [hibernateschemaexport] at sun.net.www.http.HttpClient.New(HttpClient.java:287) [hibernateschemaexport] at sun.net.www.http.HttpClient.New(HttpClient.java:299) [hibernateschemaexport] at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:792) [hibernateschemaexport] at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:744) [hibernateschemaexport] at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:669) [hibernateschemaexport] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:913) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:872) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:282) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1021) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) [hibernateschemaexport] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242) [hibernateschemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:465) [hibernateschemaexport] at org.dom4j.io.SAXReader.read(SAXReader.java:264) [hibernateschemaexport] at org.hibernate.cfg.Configuration.addFile(Configuration.java:226) [hibernateschemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195) [hibernateschemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135) [hibernateschemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [hibernateschemaexport] at org.apache.tools.ant.Task.perform(Task.java:364) [hibernateschemaexport] at org.apache.tools.ant.Target.execute(Target.java:341) [hibernateschemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369) [hibernateschemaexport] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [hibernateschemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [hibernateschemaexport] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [hibernateschemaexport] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) [hibernateschemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [hibernateschemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) [hibernateschemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) BUILD FAILED D:\!data\!Projects\eclipse\healthwindow2\build.xml:18: Schema text failed: Could not configure datastore from file: D:\!data\!Projects\eclipse\healthwindow2\src\com\healthwindow2\business\Address.hbm.xml Total time: 2 seconds
Haris PecoMemberEtienne,
Try remove xercesXX.jar and xml-apis.jar from hibernate libraries which you add to ant config
Hibernate validation framework will find dtd correct in hibernate.jar, but if you use xerces then xerces will find dtd on internet.
xerces*.ajr and xml-apis.jar aren’t necessary for java >= 1.4Best
elabuschagneParticipantHi there,
Thanks for the prompt reply.
The place where I have added jars for Ant to find is in Window->Preferences->Ant->Runtime(Classpath tab).
There are various .jars under Ant Home Entries and Contributed Entries. I cannot find either xerces*.jar or xml-apis.jar there.
Is there another place where those can be specified? It seems that code in the dom4j-1.4.jar calls the xerces code. I have tried remowing that library (even though the xerces code is not in that) but that just gave me a ClassNotFound exception.
Thanks for all the help!
Etienne
Haris PecoMemberEttiene,
Xercers is in hibernate libraries – Have you Hibernate variable libraries ?
If yes, then you can try remove xerces.jar and xmla-apis.jar from variable path
Please,can you send little example project with just ant file and your settingsThanks
elabuschagneParticipantThanks so far for all the help.
I have a deadline looming for the 1st of June, so will temporarily get along by doing a global search and replace in my hbm.xml files and point it to a local file.
After the deadline has passed, will I try and set up a small project that reproduces the problem and send that to you.
Thanks
Etienne
AzCoderMemberAs far as I know – It should look for the dtd in the local classpath first before going out on the net….
Do you have the correct DTD in the local classpath – look carefully at the exact version and spelling. Are you using the 3.2 jar?
-
AuthorPosts