InvalidMappingException Hibernate mapping file...anybody can you give resolution
My mapping file is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping >
<class name="com.myapp.companypojo.Company" table="COMPANY">
<property column="COMPANYNAME" length="25" name="companyName" not-null="false" type="java.lang.String"/>
<property column="LOCATION" length="25" name="location" not-null="false" type="java.lang.String"/>
<property column="NOOFEMPLOYESS" length="25" name="totalEmployees" type="java.lang.String"/>
<property column="LOB" length="25" name="lineOfBusiness" type="java.lang.String"/>
</class>
</hibernate-mapping>
After validating the mapping file from IDE it throw an below error and console I got InvalidMappingException
...anybody can u give resolution??
XML validation started.
Checking file:/C:/Documents%20and%20Settings/Administrator/My%20Documents/NetBeansProjects/CMCApp/src/java/com/myapp/companypojo/Company.hbm.xml... The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array),((join,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)". [12] XML validation finished.
INFO: Launching GlassFish on Apache Felix OSGi platform Welcome to Felix. ================= INFO: Started bundle org.glassfish.core.kernel [73] INFO: Started bundle org.glassfish.common.glassfish-mbeanserver [12] INFO: Started bundle org.glassfish.common.common-util [90] INFO: Started bundle GlassFish-Application-Common-Module [13] INFO: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Module [13] ] INFO: registering service = org.apache.felix.framework.StartLevelImpl@16dadf9, contract = org.osgi.service.startlevel.StartLevel, name = null INFO: registering service = org.apache.felix.framework.PackageAdminImpl@290fbc, contract = org.osgi.service.packageadmin.PackageAdmin, name = null no resource bundle found for version, using default GlassFish version INFO: Started bundle org.glassfish.branding.branding [92] INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started INFO: Started bundle org.glassfish.admin.config-api [81] INFO: Started bundle org.glassfish.common.internal-api [31] INFO: Started bundle org.glassfish.deployment.deployment-common [103] INFO: Started bundle org.glassfish.deployment.deployment-autodeploy [38] INFO: Started bundle org.glassfish.registration.glassfish-registration [79] INFO: Started bundle org.glassfish.flashlight.flashlight-framework [106] INFO: Listening on port 8080 INFO: Network listener http-listener-2 on port 8181 disabled per domain.xml INFO: Listening on port 4848 INFO: Started bundle org.glassfish.common.container-common [34] INFO: The Admin Console is already installed, but not yet loaded. INFO: Started bundle org.glassfish.connectors.gf-connectors-connector [76] INFO: Started bundle org.glassfish.security.security [63] INFO: Started bundle org.glassfish.scripting.gf-jruby-connector [75] INFO: Started bundle org.glassfish.persistence.jpa-connector [91] INFO: Started bundle org.glassfish.web.gf-web-connector [120] INFO: security.secmgroff INFO: Started bundle org.glassfish.security.securitycommon [53] INFO: Security startup service called INFO: Started bundle org.glassfish.security.realms [23] INFO: Security service(s) started successfully.... INFO: registering service = org.glassfish.web.DirContextURLStreamHandlerService@179f36b, contract = org.osgi.service.url.URLStreamHandlerService, name = null INFO: Started bundle org.glassfish.common.glassfish-naming [28] INFO: Started bundle org.glassfish.web.web-glue [116] INFO: Total number of available updates : 1 INFO: Number of available updates since Fri Nov 13 17:55:30 IST 2009 : 0 INFO: Started bundle org.glassfish.common.glassfish-api [104] INFO: Started bundle org.glassfish.connectors.connectors-runtime [37] INFO: Started bundle org.glassfish.transaction.jta [68] INFO: Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://HP26258104442:8686/jmxrmi INFO: Created HTTP listener http-listener-1 on port 8080 INFO: Created HTTP listener admin-listener on port 4848 INFO: Created virtual server server INFO: Created virtual server __asadmin INFO: Started bundle org.glassfish.deployment.dol [22] INFO: Started bundle org.glassfish.web.web-core [112] INFO: Dual registration of jndi stream handler: factory already defined INFO: Unknown loader 116.0 class org.apache.felix.framework.searchpolicy.ContentClassLoader INFO: Started bundle org.glassfish.web.jsf-connector [125] INFO: Started bundle org.glassfish.web.jstl-connector [117] INFO: Using com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedDelegate as the delegate INFO: Started bundle org.glassfish.connectors.work-management [77] INFO: Started bundle org.glassfish.common.glassfish-ee-api [48] INFO: Started bundle org.glassfish.connectors.connectors-internal-api [30] INFO: policy.loading INFO: Started bundle org.glassfish.web.war-util [110] INFO: Started bundle org.glassfish.security.websecurity [109] INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1cbd4f7 class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading chain catalog from jar:file:/C:/Documents%20and%20Settings/Administrator/My%20Documents/NetBeansProjects/MyStrutsApp/build/web/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml INFO: Tiles definition factory loaded for module ''. INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml' INFO: Loading validation rules file from '/WEB-INF/validation.xml' INFO: Loading application MyStrutsApp at /MyStrutsApp INFO: Loading MyStrutsApp Application done is 11141 ms INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1cbd4f7 class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading chain catalog from jar:file:/C:/Documents%20and%20Settings/Administrator/My%20Documents/NetBeansProjects/CMCApp/build/web/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml INFO: Tiles definition factory loaded for module ''. INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml' INFO: Loading validation rules file from '/WEB-INF/validation.xml' INFO: Loading application CMCApp at /CMCApp INFO: Loading CMCApp Application done is 3109 ms INFO: Sun GlassFish Enterprise Server v3 Prelude startup time : Felix(17750ms) startup services(17109ms) total(34859ms) INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1cbd4f7 class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading chain catalog from jar:file:/C:/Documents%20and%20Settings/Administrator/My%20Documents/NetBeansProjects/CMCApp/build/web/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml INFO: Tiles definition factory loaded for module ''. INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml' INFO: Loading validation rules file from '/WEB-INF/validation.xml' INFO: Loading application CMCApp at /CMCApp INFO: Deployment of CMCApp done is 4406 ms INFO: Tiles definition factory found for request processor ''. INFO: Hibernate 3.2.5 INFO: hibernate.properties not found INFO: Bytecode provider name : cglib INFO: using JDK 1.4 java.sql.Timestamp handling INFO: configuring from resource: /hibernate.cfg.xml INFO: Configuration resource: /hibernate.cfg.xml INFO: Reading mappings from resource : com/myapp/companypojo/Company.hbm.xml SEVERE: Error parsing XML: XML InputStream(11) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array),((join,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query))". SEVERE: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/myapp/companypojo/Company.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:569) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508) at org.hibernate.cfg.Configuration.configure(Configuration.java:1428) at org.hibernate.cfg.Configuration.configure(Configuration.java:1414) at com.myapp.hibernate.CompanyHibernateUtil.addCompanyDetails(CompanyHibernateUtil.java:33) at com.myapp.struts.CompanyDetailsAction.execute(CompanyDetailsAction.java:43) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431) at org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180) at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633) at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570) at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152) at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56) at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325) at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184) Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:502) at org.hibernate.cfg.Configuration.addResource(Configuration.java:566) ... 47 more Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array),((join,subclass*)|joined-开发者_运维知识库subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)". 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.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2048) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:932) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685) 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.Configuration.addInputStream(Configuration.java:499) ... 48 more INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1cbd4f7 class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading chain catalog from jar:file:/C:/Documents%20and%20Settings/Administrator/My%20Documents/NetBeansProjects/CMCApp/build/web/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml INFO: Tiles definition factory loaded for module ''. INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml' INFO: Loading validation rules file from '/WEB-INF/validation.xml' INFO: Loading application CMCApp at /CMCApp INFO: Deployment of CMCApp done is 3109 ms
This seems to be the interesting part of the stacktrace:
org.xml.sax.SAXParseException: The content of element type "class" must match "(meta,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array),((join,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)"
It looks like at least the id or composite-id tag must be in the class mapping. It looks as though the company name might be a good id, or you could have an auto-generated id if you expect there to be more than one company with the same name. All the options are available here: Chapter 5: Basic O/R Mapping
Go in your IDE (Eclipse, for instance), right click the xml file and press "Validate". It will tell you where you do not conform to the xml schema. (The exception means that)
精彩评论