Charles,

Do you have a Dynamic-Import or something in the Javassist bundle that
allow it to use the exported class?

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/3/24 cmoulliard <[email protected]>:
>
> Apparently "mappingDirectoryLocations" does not work when the configuration
> files are packages in a jar of a bundle separately.
>
> Nevertheless, mappingLocations works like this :
>
>                <property name="mappingLocations">
>                    <list>
>
> <value>classpath*:META-INF/org/apache/camel/example/reportincident/model/*.hbm.xml</value>
>                        </list>
>                </property>
>
> Unfortunalely, I have the following error now :
>
> Is it a bug in javassist (3.9.0.GA) who cannot load the
> org.hibernate.proxy.HibernateProxy class or a issue with felix classloading
> ?
>
> remark : org.apache.proxy package is well defined in my MANIFEST file (and
> of course expeorted by Hibernate 3.3.1.GA bundle)
>
> {code}
> Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError:
> org/hibernate/proxy/HibernateProxy
>        at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:174)
>        at
> org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:162)
>        ... 58 more
> Caused by: javassist.CannotCompileException: by
> java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
>        at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:167)
>        at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:170)
>        ... 59 more
> Caused by: java.lang.NoClassDefFoundError:
> org/hibernate/proxy/HibernateProxy
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:159)
>        ... 60 more
> Caused by: java.lang.ClassNotFoundException:
> org.hibernate.proxy.HibernateProxy
>        at
> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:558)
>        at
> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)
>        at
> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1427)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> {code}
>
> cmoulliard wrote:
>>
>> Gert,
>>
>> Nobody from Spring-Hibernate has provided a feedback now. From my point of
>> view after digging the question since last friday, I'm convinced that the
>> issue is not at all related to SMX4. I have created a ticket at Spring DM.
>>
>> I have been able to find a workaround using mappingResources instead of
>> mappingLocations or mappingDirectoryLocations but this means that the
>> hbm.xml files (this is what spring team has done in their petclinic
>> example) must be put in the same bundle where the
>> org.springframework.orm.hibernate3.LocalSessionFactoryBean is instantiated
>> :
>>
>>       <bean id="sessionFactory"
>> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>>
>>               <!-- Classloading does not work under OSGI -->
>>               <property name="mappingResources">
>>                       <list>
>>                               <value>Incident.hbm.xml</value>
>>                       </list>
>>               </property>
>>
>> For the moment, this is not blocking. So, I can continue to work and I
>> have been able to integrate camel, cxf, spring and Hibernate (using
>> commons-dbcp and mysql) top of SMX4. I will start to write the second of
>> my tutorial with the material that I have.
>>
>> Remark : You are right, the problem comes from a classloading issue with
>> Hibernate or maybe between the name stored in the EntityPersister object
>> (package name + class vs class name)
>>
>> Regards,
>>
>> Charles
>>
>>
>>
>> Gert Vanthienen wrote:
>>>
>>> Charles,
>>>
>>> Did you get an answer for this on the Spring-Hibernate forum or do you
>>> rather think it's more OSGi/ServiceMix Kernel related?
>>> From our angle, the most likely explanation would be a classloader
>>> mismatch or a missing import (probably dynamic-import) from the
>>> hibernate bundle to find the hbm files or link them to the correct
>>> class.  What imports/exports are you using?
>>>
>>> Regards,
>>>
>>> Gert Vanthienen
>>> ------------------------
>>> Open Source SOA: http://fusesource.com
>>> Blog: http://gertvanthienen.blogspot.com/
>>>
>>>
>>>
>>> 2009/3/20 cmoulliard <[email protected]>:
>>>>
>>>> Hi,
>>>>
>>>> I don't if this is the good forum to post this issue. If this is not the
>>>> case, I will post my topic on spring-hibernate forum
>>>>
>>>> My issue is the following, Hibernate claims that entity Incident does
>>>> not
>>>> exist.
>>>>
>>>> s...@root:osgi> org.hibernate.MappingException: Unknown entity:
>>>> org.apache.camel.example.reportincident.model.Incident
>>>>        at
>>>> org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:580)
>>>>        at
>>>> org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1365)
>>>>        at
>>>> org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
>>>>        at
>>>> org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:535)
>>>>        at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:103)
>>>>        at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
>>>>        at
>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:534)
>>>>        at
>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:526)
>>>>        at
>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:522)
>>>>        at
>>>> org.apache.camel.example.reportincident.dao.impl.IncidentDAOImpl.saveIncident(IncidentDAOImpl.java:101)
>>>>
>>>> This error occurs when Hibernate does not find or load the file hbm.xml
>>>>
>>>> Here is my config  :
>>>>
>>>> As you can see I have used mappingLocations instead of mappingResources
>>>> because they was an error during the load of the files with
>>>> mappingResources
>>>>
>>>>        <!--  Hibernate SessionFactory Definition -->
>>>>        <bean id="sessionFactory"
>>>> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>>>>
>>>>                <!-- Classloading does not work under OSGI -->
>>>>                <property name="mappingResources">
>>>>                        <list>
>>>>
>>>> <value>META-INF/org/apache/camel/example/reportincident/model/Incident.hbm.xml</value>
>>>>                        </list>
>>>>                </property>
>>>>
>>>>                <!-- see here
>>>>
>>>> http://www.carbonfive.com/community/archives/2007/05/using_classpath.html
>>>> and
>>>>                     http://jira.springframework.org/browse/SPR-3965
>>>>                     for more info about the classloading issue on OSGI
>>>> -->
>>>>                <property name="mappingLocations">
>>>>                        <list>
>>>>
>>>> <value>classpath*:META-INF/org/apache/camel/example/reportincident/model/Incident.hbm.xml</value>
>>>>                        </list>
>>>>                </property>
>>>>
>>>>
>>>> Any idea ?
>>>>
>>>> Regards
>>>>
>>>> -----
>>>> Charles Moulliard
>>>> SOA Architect
>>>>
>>>> My Blog :  http://cmoulliard.blogspot.com/
>>>> http://cmoulliard.blogspot.com/
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Issue-with-Hibernate-and-hbm.xml-files-%28SMX4%29-tp22623666p22623666.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>> -----
>>> ---
>>> Gert Vanthienen
>>> http://gertvanthienen.blogspot.com
>>>
>>
>>
>
>
> -----
> Charles Moulliard
> SOA Architect
>
> My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
> --
> View this message in context: 
> http://www.nabble.com/Issue-with-Hibernate-and-hbm.xml-files-%28SMX4%29-tp22623666p22676649.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Reply via email to