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-tp22623666p22662677.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.