1 Reply Latest reply on Oct 24, 2005 8:02 PM by Alex Chang

    scanForMappings scan one hibernate-mapping file twice in jbo

    Alex Chang Newbie

      i put a hibernate-service.xml in ear , and add jboss-app.xml in META-INF.

      ------------------------------------------------------------------------------
      hibernate-service.xml like this:
      <?xml version="1.0" encoding="UTF-8"?>
      server
      mbean code="org.jboss.hibernate.jmx.Hibernate" name="epm-hibernate:name=EPMSessionFactory"

      attribute name="DatasourceName"
      java:/XAOracleEPMDS
      /attribute

      attribute name="Dialect"
      org.hibernate.dialect.Oracle9Dialect
      /attribute

      attribute name="SessionFactoryName"
      java:/hibernate/EPMSessionFactory
      /attribute

      attribute name="Hbm2ddlAuto"
      false
      /attribute

      attribute name="ShowSqlEnabled"
      true
      /attribute

      attribute name="CacheProviderClass"
      org.hibernate.cache.HashtableCacheProvider
      /attribute

      /mbean
      /server
      ------------------------------------------------------------------------------------

      ------------------------------------------------------------------------------
      jboss-app.xml like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
      jboss-app
      module
      service
      hibernate-service.xml
      /service
      /module
      /jboss-app
      ---------------------------------------------------------------------------------

      the ear catalog like this:

      test.ear
      |---META-INF
      | |----application.xml
      | |----jboss-app.xml
      | |----MANIFEST.MF
      |
      |---hibernate-service.xml
      |---epm-ejb.jar
      |---epm-web.war


      Problem is, if i don't put any hbm.xml in test-ejb.jar , nothing wrong.But when i put a hbm.xml in test-ejb.jar,it has a wrong:

      07:15:49,749 INFO [Configuration] Mapping file: E:\epm\jboss-4.0.3RC2\server\default\deploy\epm-app.ear\epm-ejb.jar\conf\hbm\EpmGProject.hbm.xml
      07:15:50,079 INFO [HbmBinder] Mapping class: com.metarnet.epm.business.bo.Project -> EPM_G_PROJECT
      07:15:50,159 INFO [Configuration] Mapping file: E:\epm\jboss-4.0.3RC2\server\default\deploy\epm-app.ear\epm-ejb.jar\conf\hbm\EpmGProject.hbm.xml
      07:15:50,249 ERROR [Configuration] Could not compile the mapping document
      org.hibernate.MappingException: duplicate import: com.metarnet.epm.business.bo.Project

      The jboss scan the same hibernate-mapping file twice!
      anybody would help me ? thanks!

        • 1. Re: scanForMappings scan one hibernate-mapping file twice in
          Alex Chang Newbie

          problem resolved.

          07:54:52,157 DEBUG [Hibernate] Passing directory [E:\epm\jboss-4.0.3RC2\server\default\deploy\epm-app.ear\epm-web.war] to Hibernate Configration
          07:54:52,217 DEBUG [Hibernate] Passing directory [E:\epm\jboss-4.0.3RC2\server\default\deploy\epm-app.ear\epm-ejb.jar] to Hibernate Configration
          07:54:52,247 INFO [Configuration] Mapping file: E:\epm\jboss-4.0.3RC2\server\default\deploy\epm-app.ear\epm-ejb.jar\conf\hbm\EpmGProject.hbm.xml
          07:54:52,377 DEBUG [DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath under org/hibernate/
          07:54:52,377 DEBUG [DTDEntityResolver] found http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath
          07:54:52,828 INFO [HbmBinder] Mapping class: com.metarnet.epm.business.bo.Project -> EPM_G_PROJECT
          07:54:52,908 DEBUG [HbmBinder] Mapped property: pid -> PID
          07:54:52,978 DEBUG [HbmBinder] Mapped property: projectName -> PROJECT_NAME
          07:54:52,978 DEBUG [HbmBinder] Mapped property: projectId -> PROJECT_ID
          07:54:52,978 DEBUG [HbmBinder] Mapped property: speciality -> SPECIALITY
          07:54:52,978 DEBUG [HbmBinder] Mapped property: province -> PROVINCE
          07:54:52,978 DEBUG [HbmBinder] Mapped property: netType -> NET_TYPE
          07:54:52,978 DEBUG [HbmBinder] Mapped property: projectCode -> PROJECT_CODE
          07:54:52,978 DEBUG [HbmBinder] Mapped property: principal -> PRINCIPAL
          07:54:52,978 DEBUG [HbmBinder] Mapped property: principalTel -> PRINCIPAL_TEL
          07:54:52,978 DEBUG [HbmBinder] Mapped property: enPs -> EN_PS
          07:54:52,978 DEBUG [HbmBinder] Mapped property: enManual -> EN_MANUAL
          07:54:52,988 DEBUG [Hibernate] Passing directory [E:\epm\jboss-4.0.3RC2\server\default\deploy\epm-app.ear] to Hibernate Configration

          I trace this Hibernate.scanForMappings(), it first scan epm-ejb.jar, and scan epm.ear.

          so , put the hbm.xml at ear but not in ejb.jar and web.war,all right.