7 Replies Latest reply on Dec 28, 2005 3:55 AM by sun yimin

    JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Mapping

    artemis Ozten Newbie

      Build .har, and deployed.
      This is my hbm.xml file.

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE hibernate-mapping PUBLIC "=//Hinernate Mapping DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
      <hibernate-mapping package="com.ssi.listener.bean">







      </hibernate-mapping>


      Built a .war and in a sevlet, had following code:


      InitialContext ctx = new InitialContext();
      SessionFactory factory = (SessionFactory)
      ctx.lookup("java:/org/hibernate/SessionFactory");
      Session hsession = factory.openSession();
      CWsmType wsmtype = new CWsmType();
      wsmtype.setTypeId("123");
      wsmtype.setWsmDefaultName("myType"); try {
      Transaction transaction=hsession.beginTransaction();
      hsession.save(wsmtype);
      transaction.commit();
      } finally {
      hsession.close();
      }

      Deployed the .war.

      At runtime, that is what I see.


      14:53:56,312 INFO [STDOUT] org.hibernate.MappingException: Unknown entity: com.ssi.listener.bean.CWsmType
      at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:555)
      at org.hibernate.impl.SessionImpl.getEntityPersiste
      r(SessionImpl.java:1070)

      Why doesnt the session see the persistece object?

      Any ideas, inputs? Thanks.

        • 1. Re: JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Map
          Darran Lofthouse Master

          Can you post your deployment descriptors wrapped with [ code ][ / code ] tags without the spaces and use the preview button.

          Can you also execute the command 'jar -tf harname.har' and post the output here.

          What messages are displayed when you deploy the har?

          • 2. Re: JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Map
            artemis Ozten Newbie

            Here is what I see when I deploy the .har file:


            15:34:51,203 INFO [Hibernate] Using JDBC batch size : null
            15:34:51,203 INFO [Configuration] Searching for mapping documents in jar: listenerHAR.har
            15:34:51,203 INFO [Configuration] processing extends queue
            15:34:51,203 INFO [Configuration] processing collection mappings
            15:34:51,203 INFO [Configuration] processing association property references
            15:34:51,203 INFO [Configuration] processing foreign key constraints
            15:34:51,203 INFO [NamingHelper] JNDI InitialContext properties:{}
            15:34:51,218 INFO [DatasourceConnectionProvider] Using datasource: java:/PostgresDS
            15:34:51,218 INFO [SettingsFactory] RDBMS: PostgreSQL, version: 8.0.3
            15:34:51,218 INFO [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.0 JDBC3 with SSL (build 311)
            15:34:51,218 INFO [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
            15:34:51,218 INFO [SettingsFactory] JDBC batch size: 15
            15:34:51,218 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
            15:34:51,218 INFO [SettingsFactory] Scrollable result sets: enabled
            15:34:51,218 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
            15:34:51,218 INFO [SettingsFactory] Aggressive release : enabled
            15:34:51,218 INFO [SettingsFactory] Default batch fetch size: 1
            15:34:51,218 INFO [SettingsFactory] Generate SQL with comments: disabled
            15:34:51,218 INFO [SettingsFactory] Order SQL updates by primary key: disabled
            15:34:51,218 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
            15:34:51,218 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
            15:34:51,218 INFO [SettingsFactory] Query language substitutions: {}
            15:34:51,218 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JTATransactionFactory
            15:34:51,218 INFO [NamingHelper] JNDI InitialContext properties:{}
            15:34:51,218 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
            15:34:51,218 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
            15:34:51,218 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
            15:34:51,218 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
            15:34:51,218 INFO [SettingsFactory] Automatic flush during beforeCompletion(): enabled
            15:34:51,218 INFO [SettingsFactory] Automatic session close at end of transaction: enabled
            15:34:51,218 INFO [SettingsFactory] Second-level cache: enabled
            15:34:51,218 INFO [SettingsFactory] Query cache: disabled
            15:34:51,218 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
            15:34:51,218 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
            15:34:51,218 INFO [SettingsFactory] Structured second-level cache entries: enabled
            15:34:51,218 INFO [SettingsFactory] Echoing all SQL to stdout
            15:34:51,218 INFO [SettingsFactory] Statistics: disabled
            15:34:51,218 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
            15:34:51,218 INFO [SettingsFactory] Default entity-mode: pojo
            15:34:51,218 INFO [SessionFactoryImpl] building session factory
            15:34:51,218 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
            15:34:51,218 INFO [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
            15:34:51,218 INFO [Configuration] processing extends queue
            15:34:51,218 INFO [Configuration] processing collection mappings
            15:34:51,218 INFO [Configuration] processing association property references
            15:34:51,218 INFO [Configuration] processing foreign key constraints
            15:34:51,218 INFO [Configuration] processing extends queue
            15:34:51,218 INFO [Configuration] processing collection mappings
            15:34:51,218 INFO [Configuration] processing association property references
            15:34:51,218 INFO [Configuration] processing foreign key constraints
            15:34:51,218 INFO [SchemaExport] Running hbm2ddl schema export
            15:34:51,218 INFO [SchemaExport] exporting generated schema to database
            15:34:51,218 INFO [NamingHelper] JNDI InitialContext properties:{}
            15:34:51,218 INFO [DatasourceConnectionProvider] Using datasource: java:/PostgresDS
            15:34:51,218 INFO [SchemaExport] schema export complete
            15:34:51,218 INFO [NamingHelper] JNDI InitialContext properties:{}
            15:34:51,218 INFO [SessionFactoryImpl] Checking 0 named queries
            15:34:51,218 INFO [Hibernate] SessionFactory successfully built and bound into JNDI [java:/org/hibernate/SessionFactory]




            Here is the hbm.xml completely:

            <hibernate-mapping package="com.ssi.listener.bean">







            </hibernate-mapping>

            • 3. Re: JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Map
              artemis Ozten Newbie

              Here is the hibernate-service.xml:

              <?xml version="1.0" encoding="UTF-8"?>
              <!-- ==================================================================== -->
               <!-- Hibernate session factory and management -->
               <!-- ==================================================================== -->
               <mbean code="org.jboss.hibernate.jmx.Hibernate"
               name="jboss.har:service=Hibernate">
               <attribute name="DatasourceName">java:/PostgresDS</attribute>
               <attribute name="SessionFactoryName">java:/org/hibernate/SessionFactory</attribute>
               <attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
               <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
               <attribute name="Hbm2ddlAuto">create</attribute>
               <attribute name="ShowSqlEnabled">true</attribute>
               </mbean>
              


              Here is the one and only mapping ...hbm.xml file:
              <?xml version="1.0"?>
              <!DOCTYPE hibernate-mapping PUBLIC
               "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
               "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
              
              
              <hibernate-mapping>
               <class name="com.ssi.listener.bean.CWsmType" table="WSM_TYPE" >
               <id name="id" column="ID" type="long">
               <generator class="increment"/>
               </id>
               <property name="typeId" column="TYPE_ID" type="string"/>
               <property name="wsmDefaultName" column="WSM_DEFAULT_NAME" type="string"/>
               </class>
              </hibernate-mapping>
              

              Here is the .har:

              META-INF/MANIFEST.MF
              META-INF/hibernate-service.xml
              com/ssi/listener/bean/CWsmType.class
              com/ssi/listener/bean/CWsmType.hbm.xml

              Here is the .war that tries to persist one object:

              C:\jboss-4.0.2\server\myconfig\deploy>jar -tf listener.war
              META-INF/MANIFEST.MF
              WEB-INF/classes/META-INF/MANIFEST.MF
              WEB-INF/classes/META-INF/hibernate-service.xml
              WEB-INF/classes/com/ssi/listener/bean/CWsmType.class
              WEB-INF/classes/com/ssi/listener/bean/CWsmType.hbm.xml
              WEB-INF/classes/com/ssi/listener/common/IApplicationConstants.class
              WEB-INF/classes/com/ssi/listener/common/IErrorCodes.class
              WEB-INF/classes/com/ssi/listener/common/IRequestCodes.class
              WEB-INF/classes/com/ssi/listener/common/IRequestParamNames.class
              WEB-INF/classes/com/ssi/listener/common/IResponseMessages.class
              WEB-INF/classes/com/ssi/listener/common/IStatusCodes.class
              WEB-INF/classes/com/ssi/listener/common/util/CRequestParamHandler.class
              WEB-INF/classes/com/ssi/listener/servlet/CAddGwConfig.class
              WEB-INF/classes/com/ssi/listener/servlet/CAddWsmConfigQuery.class
              WEB-INF/classes/com/ssi/listener/servlet/CAddWsmControl.class
              WEB-INF/classes/com/ssi/listener/servlet/CGetRequestType.class
              WEB-INF/classes/com/ssi/listener/servlet/CGwHeartBeat.class
              WEB-INF/classes/com/ssi/listener/servlet/CResponseXml.class
              WEB-INF/classes/com/ssi/listener/servlet/CUpdateWsmConfig.class
              WEB-INF/classes/com/ssi/listener/servlet/CUpdateWsmSensorData.class
              WEB-INF/web.xml


              The .har deployment finally succeeded when I switched to Hibernate2. (A table was created in the db). But earlier exception occurs when the servlet in the .war tries to persist the one and only object:

              22:56:00,031 INFO [STDOUT] net.sf.hibernate.MappingException: No persister for: com.ssi.listener.bean.CWsmType
              at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
              at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
              at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)



              • 4. Re: JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Map
                deniz hepsen Newbie

                Hi,

                How did you solve the problem ?

                • 5. Re: JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Map
                  sun yimin Newbie

                  I have the same problem.
                  I Use JBoss AS 4.0.3 SP1 + JBossHibernate2.

                  • 6. Re: JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Map
                    sun yimin Newbie

                    The *.har be deployed ok.
                    use a test.jsp such as:

                    <%@ page import="javax.naming.*" %>
                    <%@ page import="net.sf.hibernate.*" %>
                    
                    <%
                     InitialContext ctx = new InitialContext();
                     SessionFactory factory = (SessionFactory)
                     ctx.lookup("java:/hibernate/CmmsSF");
                     Session hsession = factory.openSession();
                     try {
                     Query query = hsession.createQuery("from com.ymsun.entapps.cmms.model.User");
                     System.out.println(query.list().get(0));
                    
                     } finally {
                     hsession.close();
                     }
                    %>
                    
                    
                    

                    it's ok.
                    But when i use the spring in my web application such as:
                    <!-- Hibernate SessionFactory -->
                     <bean id="sessionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
                     <property name="jndiName"><value>java:/hibernate/CmmsSF</value></property>
                     </bean>
                    
                     <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
                     <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
                     </bean>
                     ......
                    

                    then report:
                    org.springframework.orm.hibernate.HibernateSystemException: Unknown entity class
                    : com.ymsun.entapps.cmms.model.User; nested exception is net.sf.hibernate.Mappin
                    gException: Unknown entity class: com.ymsun.entapps.cmms.model.User
                    net.sf.hibernate.MappingException: Unknown entity class: com.ymsun.entapps.cmms.
                    model.User
                     at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryI
                    mpl.java:347)
                     at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:
                    2718)
                     at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1998
                    )
                     at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1937)
                     at org.springframework.orm.hibernate.HibernateTemplate$1.doInHibernate(H
                    ibernateTemplate.java:448)
                     at org.springframework.orm.hibernate.HibernateTemplate.execute(Hibernate
                    Template.java:363)
                     at org.springframework.orm.hibernate.HibernateTemplate.get(HibernateTemp
                    late.java:442)
                     at org.springframework.orm.hibernate.HibernateTemplate.get(HibernateTemp
                    late.java:436)
                     at com.ymsun.entapps.cmms.dao.hibernate.UserDAOHibernate.getUser(UserDAO
                    Hibernate.java:26)
                     at com.ymsun.entapps.cmms.service.impl.UserManagerImpl.getUser(UserManag
                    erImpl.java:40)
                    ......
                    


                    • 7. Re: JBoss 4.0.2 wiyth Hibernate3 exception org.hibernate.Map
                      sun yimin Newbie

                      i solved the problem, it's seemed that domain classes deployed to *.har can not be deployed to the war again. classloader issue.