[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-873?page=all ]
Emmanuel Bernard moved ANN-438 to HBX-873:
------------------------------------------
Project: Hibernate Tools (was: Hibernate Annotations)
Key: HBX-873 (was: ANN-438)
Version: 3.2beta7
(was: 3.2.0.cr1)
Merging annotations and XML sometimes causes an XML parser error
----------------------------------------------------------------
Key: HBX-873
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-873
Project: Hibernate Tools
Type: Bug
Versions: 3.2beta7
Environment: Hibernate 3.2 CR2, SQL Server 2005
Reporter: James Telfer
Assignee: Max Rydahl Andersen
Attachments: ann438.zip
I created a class and annotated it with EJB 3 annotations, then created an XML descriptor
to store my named queries. The XML I used is excerpted below. I then added the mapping
file to my cfg.xml as a <mapping resource=""/%gt; element. When Hibernate
was configured, it threw the parser exception included below also.
The same error occurred when configuring my application within Tomcat (via Spring). To
narrow down the problemI created a very simple class to configure Hibernate and ran that
in Eclipse. This worked. The line used to configure Hibernate was: <code>new
AnnotationConfiguration().configure(new
File("hibernate.cfg.xml")).buildSessionFactory();</code>.
Eclipse is running on Windows using the JDK 1.5.07 Server VM with parallel GC and the
Eclipse runner used the JDK server VM with standard GC. Tomcat was using the JRE 1.5.07
client VM. I changed the VM used by Tomcat and it succeeded. Hibernate Tools still fails
to read the configuration file.
If any further information is required, I'd be happy to provide it. There is a forum
thread
(
http://forum.hibernate.org/viewtopic.php?p=2310540&sid=f14052739a96c4...)
that describes a similar problem, but the user's fix is not feasible in this
scenario.
<pre>
org.hibernate.MappingException: Could not read mappings from resource:
au/com/crowncontent/precis/entries/dao/mappings.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:523)
at
org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:425)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1479)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1458)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1432)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1386)
at
org.hibernate.console.ConsoleConfiguration.loadConfigurationXML(ConsoleConfiguration.java:225)
at org.hibernate.console.ConsoleConfiguration.access$0(ConsoleConfiguration.java:172)
at org.hibernate.console.ConsoleConfiguration$1.execute(ConsoleConfiguration.java:148)
at
org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:129)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:109)
at
org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:54)
at
org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:63)
at
org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
at
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
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.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: org.hibernate.MappingException: invalid mapping
at
org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:571)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:520)
... 39 more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of
element 'entity-mappings'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.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.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1944)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.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(AbstractSAXParser.java:1242)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at
org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:567)
... 40 more
</pre>
ORM XML:
<pre>
<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
orm_1_0.xsd"
version="1.0">
<package>au.com.blah.entries</package>
<entity class="Entry"
metadata-complete="false">
<named-query name="entries.Entry.searchEntries">
<query>
select ...
etc etc
</query>
<hint name="org.hibernate.readOnly"
value="true"/>
<hint name="org.hibernate.fetchSize"
value="50"/>
</named-query>
</entity>
</entity-mappings>
</pre>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira