[hibernate-issues] [Hibernate-JIRA] Closed: (HBX-873) Merging annotations and XML sometimes causes an XML parser error

Max Rydahl Andersen (JIRA) noreply at atlassian.com
Sun Oct 28 04:07:39 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Max Rydahl Andersen closed HBX-873.
-----------------------------------

    Resolution: Cannot Reproduce

I can't reproduce this - if still an issue with later versions I would need more info.

> 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
>          Issue Type: Bug
>    Affects 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=f14052739a96c418c3fb6ec5cde5283d) 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>
> &lt;entity-mappings 
>   xmlns=&quot;http://java.sun.com/xml/ns/persistence/orm&quot;
>   xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
>   xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd&quot;
>   version=&quot;1.0&quot;&gt;
>     &lt;package&gt;au.com.blah.entries&lt;/package&gt;
>     
>     &lt;entity class=&quot;Entry&quot; metadata-complete=&quot;false&quot;&gt;
>         &lt;named-query name=&quot;entries.Entry.searchEntries&quot;&gt;       
>             &lt;query&gt;
>                 select ...
>                 etc etc
>             &lt;/query&gt;
>             &lt;hint name=&quot;org.hibernate.readOnly&quot; value=&quot;true&quot;/&gt;
>             &lt;hint name=&quot;org.hibernate.fetchSize&quot; value=&quot;50&quot;/&gt;
>         &lt;/named-query&gt;
>     &lt;/entity&gt;
> &lt;/entity-mappings&gt;
> </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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list