Announcement Announcement Module
Collapse
No announcement yet.
Upgrade to Hibernate3 - Spring 1.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Upgrade to Hibernate3 - Spring 1.2

    Hello,

    I'm trying to upgrade to Hib3 and Spring1.2 and i get an error that i couldn't find in the posts i read from this forum. I changed packages to org.springframework.orm.hibernate3 and i still get this error:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean fai
    led; nested exception is org.hibernate.MappingException: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
    org.hibernate.MappingException: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
    at org.hibernate.cfg.Configuration.addInputStream(Con figuration.java:405)

    In my application-context i have the session factory configuration as follows:


    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="mappingResources">
    <list>
    <value>com/backend/businessobject/SourceSystem.hbm.xml</value>
    <value>com/backend/businessobject/UserSecurityPermissions.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.Orac le9Dialect</prop>
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.cglib.use_reflection_optimizer">tru e</prop>
    <prop key="hibernate.cache.provider_class">org.hibernate .cache.HashtableCacheProvider</prop>
    <prop key="hibernate.jdbc.batch_size">0</prop>
    <prop key="c3p0.min_size">3</prop>
    <prop key="c3p0.max_size">5</prop>
    <prop key="c3p0.timeout">1800</prop>
    </props>
    </property>
    <property name="dataSource">
    <ref local="dataSource"/>
    </property>
    </bean>


    Can anyone give a hand?

    Thanks a lot,
    M

  • #2
    Check if your hbm.xml's have DTD set correctly.

    Comment


    • #3
      Thank you for your reply. I managed to set my DTD properly and it doesn't seem to complain about that anymore. However, i have a different problem now, related to the Cache.

      I used to use <prop key="hibernate.cache.provider_class">net.sf.hibern ate.cache.HashtableCacheProvider</prop>
      and i replaced it by <prop key="hibernate.cache.provider_class">org.hibernate .cache.HashtableCacheProvider</prop>

      I don't receive any error, the output windo justs closes and this is the last output i can see:

      15:43:49,098 INFO Dialect:91 - Using dialect: org.hibernate.dialect.Oracle9Dialect
      15:43:49,114 INFO SettingsFactory:91 - Default batch fetch size: 1
      15:43:49,114 INFO SettingsFactory:95 - Generate SQL with comments: disabled
      15:43:49,114 INFO SettingsFactory:99 - Order SQL updates by primary key: disabled
      15:43:49,114 INFO SettingsFactory:285 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
      15:43:49,130 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
      15:43:49,130 INFO SettingsFactory:107 - Query language substitutions: {}
      15:43:49,130 INFO ConnectionProviderFactory:53 - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider
      15:43:54,371 INFO SettingsFactory:149 - JDBC batch size: 15
      15:43:54,371 INFO SettingsFactory:152 - JDBC batch updates for versioned data: disabled
      15:43:54,387 INFO SettingsFactory:157 - Scrollable result sets: enabled
      15:43:54,387 INFO SettingsFactory:165 - JDBC3 getGeneratedKeys(): disabled
      15:43:54,387 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
      15:43:54,387 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional se
      15:43:54,403 INFO SettingsFactory:177 - Automatic flush during beforeCompletion(): disabled
      15:43:54,403 INFO SettingsFactory:180 - Automatic session close at end of transaction: disabled
      15:43:54,403 INFO SettingsFactory:186 - Second-level cache: enabled
      15:43:54,403 INFO SettingsFactory:190 - Query cache: disabled
      15:43:54,403 INFO SettingsFactory:272 - Cache provider: org.hibernate.cache.HashtableCacheProvider
      15:43:54,403 INFO SettingsFactory:205 - Optimize cache for minimal puts: disabled
      15:43:54,403 INFO SettingsFactory:214 - Structured second-level cache entries: enabled
      15:43:54,403 INFO SettingsFactory:226 - Statistics: disabled
      15:43:54,418 INFO SettingsFactory:230 - Deleted entity synthetic identifier rollback: disabled
      15:43:54,418 INFO SettingsFactory:244 - Default entity-mode: pojo
      15:43:54,481 INFO SessionFactoryImpl:147 - building session factory

      any idea this time? Thanks a lot!!
      m

      Comment


      • #4
        I don't see the problem here?

        Comment


        • #5
          That's the problem, that i don't see any error and the server crashes, what means the output window closes without giving more information. maybe by looking at my config file you can see the problem?

          <!-- Hibernate SessionFactory Definition -->
          <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
          <property name="mappingResources">
          <list>
          <value>com/businessobject/FeedStates.hbm.xml</value>
          <value>com/businessobject/FeedStatic.hbm.xml</value>
          </list>
          </property>
          <property name="hibernateProperties">
          <props>
          <prop key="hibernate.dialect">org.hibernate.dialect.Orac le9Dialect</prop>
          <prop key="hibernate.show_sql">false</prop>
          <prop key="hibernate.cglib.use_reflection_optimizer">tru e</prop>
          <prop key="hibernate.cache.provider_class">org.hibernate .cache.HashtableCacheProvider</prop>
          <prop key="hibernate.jdbc.batch_size">0</prop>
          <prop key="c3p0.min_size">3</prop>
          <prop key="c3p0.max_size">5</prop>
          <prop key="c3p0.timeout">1800</prop>
          </props>
          </property>
          <property name="dataSource">
          <ref local="dataSource"/>
          </property>
          </bean>
          <!-- Hibernate Template Defintion -->
          <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibernat eTemplate">
          <property name="sessionFactory">
          <ref bean="sessionFactory"/>
          </property>
          <property name="jdbcExceptionTranslator">
          <ref bean="jdbcExceptionTranslator"/>
          </property>
          </bean>

          Comment


          • #6
            What kind of server are you running?
            Try looking at server's log.

            Comment


            • #7
              i looked at the log but doesn't give any more info. I cleaned the server and deploy again without cache.provider-class specification and this is what i get

              17:16:42,307 INFO SettingsFactory:190 - Query cache: disabled
              17:16:42,307 INFO SettingsFactory:272 - Cache provider: org.hibernate.cache.EhCacheProvider
              17:16:42,307 INFO SettingsFactory:205 - Optimize cache for minimal puts: disabled
              17:16:42,307 INFO SettingsFactory:214 - Structured second-level cache entries: enabled
              17:16:42,307 INFO SettingsFactory:226 - Statistics: disabled
              17:16:42,307 INFO SettingsFactory:230 - Deleted entity synthetic identifier rollback: disabled
              17:16:42,323 INFO SettingsFactory:244 - Default entity-mode: pojo
              17:16:42,354 INFO SessionFactoryImpl:147 - building session factory
              17:16:42,370 INFO DefaultListableBeanFactory:513 - Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [dataSource,sessionFactory,ser
              viceLocatorBean,jdbcExceptionTranslator,hibernateT emplate,feedManagerDao,userDao,explorerSearchDao,e xplorerEntityDao,transactionManager,userService,fe edManagerServiceTarget,feedManagerService,explorer
              SearchServiceTarget,explorerSearchService,explorer EntityServiceTarget,explorerEntityService]; root of BeanFactory hierarchy}
              17:16:42,510 ERROR ContextLoader:177 - Context initialization failed
              org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean fai
              led; nested exception is java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
              java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
              at org.hibernate.cache.EhCacheProvider.start(EhCacheP rovider.java:124)
              at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi onFactoryImpl.java:164)

              If i add now the lib ehcache-1.1.jar which contains the file missing i get this error:
              17:22:27,675 INFO SessionFactoryImpl:147 - building session factory
              17:22:27,691 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: zip:C:/Program Files/BEA/user_projects/domains/clr/mys
              lete/extract/myserver_Portal_Portal/jarfiles/WEB-INF/lib/ehcache-1.121709.jar!/ehcache-failsafe.xml
              before the window crashes. In the log from weblogic server i don't get much: (lasts lines i see):

              ####<21.04.2005 17.22 Uhr CEST> <Info> <HTTP> <wzrh994176297> <myserver> <main> <<anonymous>> <> <BEA-101047> <[ServletContext(id=13878940,name=Portal,context-path=/Portal)] WebServiceServlet: init>
              ####<21.04.2005 17.22 Uhr CEST> <Info> <HTTP> <wzrh994176297> <myserver> <main> <<anonymous>> <> <BEA-101047> <[ServletContext(id=13878940,name=Portal,context-path=/Portal)] SpringContextServlet: init>
              ####<21.04.2005 17.22 Uhr CEST> <Info> <HTTP> <wzrh994176297> <myserver> <main> <<anonymous>> <> <BEA-101047> <[ServletContext(id=13878940,name=Portal,context-path=/Portal)] Loading Spring root WebApplicationContext>

              Comment


              • #8
                This is not an error, it is just a warning issued for cache storage deifnition not being applied.

                WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: zip:C:/Program Files/BEA/user_projects/domains/clr/mys
                lete/extract/myserver_Portal_Portal/jarfiles/WEB-INF/lib/ehcache-1.121709.jar!/ehcache-failsafe.xml

                Uf, I never used BEA, and from no more info I cannot tell you anything more.

                Comment


                • #9
                  ok thanks. Could you maybe tell me how to desactivate de use of the cache? after the warning the application crashes and i wonder i canlive without it..
                  thanks again for your help

                  Comment


                  • #10
                    hibernate.cache.use_second_level_cache=false

                    But I believe you must still provide CacheProvider, although it won't be used.

                    Comment


                    • #11
                      After all the help, i think i should post the origin of the problem and the solution that i found on the web, so if someone faces something like this can solve the prob.

                      It was an issue with the new Query parser in Hibernate 3, which uses antlr. The problem is that weblogic 8 uses the infamous 33 MB weblogic.jar, which already includes a version of antlr. This causes class loading problems and an error since the antlr classes are loaded by the servers classloader and can not see the classes in hibernate3.jar which is inside an ear or a war. This nice line is given as an indication of what went wrong:

                      CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken

                      After this error, System.exit() is called from antlr, which makes it even harder to find what's wrong (Weblogic just shuts down). The correct solution is to set the Hibernate property "hibernate.query.factory_class" to "org.hibernate.hql.classic.ClassicQueryTranslatorF actory" (in your Spring configuration or in hibernate.properties).

                      Comment


                      • #12
                        Nice 'bug' catch. 8)

                        Comment

                        Working...
                        X