facebook

HQL Editor – Spring LocalSessionFactory Bean Exceptions

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #282616 Reply

    Thomas Heiss
    Member

    Hello,

    We are using MyEclipse Enterprise 6.0.1GA with Hibernate and Spring and the development teams owns a 5 user license.

    When we start the HQL editor, it raises a specific InvocationTargetException once the “hibernate project context” for the dataccess project gets refreshed (on startup of the HQL editor).

    We have been busy with this specific problem for multiple full-time days in the past months and weeks and I already tried to find the possible solutions / workarounds on Internet / forum / testing.

    For the moment it is 100% re-producable on all workstations for each test.
    From time to time the HQL editor works without the startup exceptions (and it worked before for n times too; when and why is not really clear; restart of MyEclipse does not really help, even not a project clean).
    Currently we really do not have any more ideas what we could test and what direction we could go.

    The stacktrace:

    
    org.hibernate.console.HibernateConsoleRuntimeException: LocalSessionFactoryBean could not be created.
        at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration$1.execute(MEConsoleConfiguration.java:160)
        at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
        at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration.buildWith(MEConsoleConfiguration.java:147)
        at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:119)
        at com.genuitec.eclipse.hibernate.action.MERefreshCCAction$1.run(MERefreshCCAction.java:93)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainSessionFactory' defined in URL [file:.../workspace/DataAccess/src/main/resources/spring-beans/spring-hibernate.xml]: Invocation of init method failed; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException--]null
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1175)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
        at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration$1.execute(MEConsoleConfiguration.java:156)
        ... 5 more
    Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException--]null
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
        at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
        at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
        at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:121)
        at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
        at org.hibernate.tuple.entity.AbstractEntityTuplizer.[init](AbstractEntityTuplizer.java:135)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.[init](PojoEntityTuplizer.java:55)
        at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.[init](EntityEntityModeToTuplizerMapping.java:56)
        at org.hibernate.tuple.entity.EntityMetamodel.[init](EntityMetamodel.java:269)
        at org.hibernate.persister.entity.AbstractEntityPersister.[init](AbstractEntityPersister.java:425)
        at org.hibernate.persister.entity.SingleTableEntityPersister.[init](SingleTableEntityPersister.java:109)
        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
        at org.hibernate.impl.SessionFactoryImpl.[init](SessionFactoryImpl.java:226)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
        ... 12 more
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedMethodAccessor131.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
        ... 31 more
    Caused by: java.lang.NoClassDefFoundError: de/.../dataaccess/....[SomeHibernateModelClass]
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        ... 36 more
    

    The spring-hibernate.xml looks like this:

    
    <bean id="mainSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" singleton="true" lazy-init="false">
            <property name="dataSource">
                <ref bean="mainDataSource" />
            </property>
            <property name="mappingLocations">
                <value>classpath:de/dialo/dataaccess/**/*.hbm.xml</value>
            </property>
    <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.show_sql">false</prop>
                    <prop key="hibernate.format_sql">false</prop>
                    <prop key="hibernate.use_sql_comments">false</prop>
                    <prop key="hibernate.max_fetch_depth">1</prop>
                    <prop key="hibernate.default_batch_fetch_size">764</prop>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                    <prop key="hibernate.cache.use_query_cache">false</prop>
                    <prop key="hibernate.cache.use_second_level_cache">false</prop>
                    <prop key="hibernate.generate_statistics">true</prop>
                    <prop key="hibernate.jdbc.fetch_size">1000</prop>
                    <prop key="hibernate.jdbc.batch_size">30</prop>
                    <prop key="hibernate.connection.autocommit">false</prop>
                    <prop key="hibernate.connection.release_mode">auto</prop>
                </props>
            </property>
        </bean>
    

    We already changed “classpath*:” to “classpath:”. Without that, some duplicate mapping exceptions were thrown. Is that normal, by the way?

    We run this spring hibernate configuration (even only with “classpath:”) in test and production. And it also works in local JUnit Tests (here it finds all the mapped Hibernate persistence classes).

    The problem seems to be, that the LocalSessionFactoryBean / Hibernate core classes CAN NOT find all the mapped Hibernate persistence classes even the hbm.xml files and .class files reside in the classpath of the project were the HQL editor gets started in (dataaccess). So all mapping files and Hibernate .class files get compiled into the “bin” directory of MyEclipse.

    What makes me wondering is, that 99,99% or from time to time even 100% these exceptions get thrown on HQL editor start, but sometimes after restart, clean (the exact WHEN is not really clear as already described) it works.
    So, it worked without any configuration / library change already.

    This is the environment:
    MyEclipse 6.01GA (Eclipse 3.3.1) – all-in one setup
    Spring 2.0.6
    Hibernate 3.2.4.sp1
    mysql connector 3.1.12 (on MySQL 5.0 / 5.1)

    Manual Java Build Path for MyEclipse dataccess project (hibernate capability), we DO NOT USE MyEclipse library Hibernate 3.2 Core Libraries / Advanced Support Libraries (the error is re-producable with them too. With manual libraries we could get it once working while it is not anymore right now):
    spring-2.0.6.jar
    mysql-connector-java-3.1.12-bin.jar
    hibernate-3.2.4.sp1.jar
    cglib-2.1.3.jar
    asm-attrs.jar
    asm.jar
    antlr-2.7.6.jar

    Our Hibernate mapping files do use Hibernate classes as well interfaces.
    Like this:

    
    <hibernate-mapping package="....dataaccess....">
    
        <class name="SomeHibernateModelClass" table="our_mapped_table"
            abstract="true" lazy="true" batch-size="50">
    

    So SomeHibernateModelClass would be an Java interface.

    The HQL editor was even once working without asm.jar but my intensive research on this topic evaluated, leaving out antlr and asm jars may get it even more worse.

    We would greatly appreciate tipps on this weird HQL editor errors as our work with Hibernate and DAO programming would benefit very much on this valuable feature.

    Thanks again.

    With best regards,
    Thomas

    #282625 Reply

    Loyal Water
    Member

    Thomas,
    Can you switch to a new workspace, create a new project hibernate project and check if the issue pops up again. Is this issue project specific ?

    #282630 Reply

    Thomas Heiss
    Member

    Dear Nipun,

    I can confirm that this does not depend on the current (working) MyEclipse workspace.
    As well as my collegue and I checked out the DataAccess project from SVN into a new MyEclipse workspace to validate configuration / dependency.
    It did not solve the issues (does not make it better or worser).

    Are there any log level debug options which could be turned on for Hibernate or MyEclipse HQL editor to test what is going on under the hook?

    We are also very interested in any options for CGLIB which could be turned off or bypassed to come over NoClassDefFound errors.

    Is this the first kind of Hibernate/CGLIB message which you see with those problems?

    Best regards,
    Thomas

    #282780 Reply

    Riyad Kalla
    Member

    Thomas,
    Due to the complexity of library interactions occuring with this project, we are going to need to work with you step-by-step to create an example project that we can use on this end to reproduce the problem consistently.

    Given that, is it possible, using the MyEclipse Derby Database, to walk through a series of steps or create an example Hibernate/Spring project that exhibits exactly the same behavior you are seeing with your “DataAccess” project that we can reproduce on this end and hand off to the development team?

    There are so many classload complexities that go on with the HQL Editor/Query tool inside the tool that the first thing we need to do is really narrow down a reproducable test case for us to research against first.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: HQL Editor – Spring LocalSessionFactory Bean Exceptions

You must be logged in to post in the forum log in