Announcement Announcement Module
Collapse
No announcement yet.
loading hbm from an external jar Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • loading hbm from an external jar

    Hi everyone.

    I have refactored a project to make it more modular.
    I have problem loading hibernate mapped object that are defined in a jar and not in the same project where spring is loaded.

    The long story:

    Instead of one single project, I have a "core" project with the domain classes and the services, and many web interfaces (WSDL, REST...) that depends on the core jar.
    The core jar have the spring configuration for the hibernate environment and for all the application services.

    Now the spring config that I found in the project was a spring + pure hibernate (no JPA). So there is a DataSource, a SessionFactory, an HibernateTemplate with a HibernateTransactionManager.

    sessionFactory bean has this property:
    <property name="mappingDirectoryLocations" value="classpath*:com/company/profiles/core/domain" />

    that works inside the "core" project but is broken when the spring is loaded from one of the "web" project, with a:

    Caused by: java.io.FileNotFoundException: URL [jar:file:/.../home/ildella/.m2/repository/com/company/profiles-core/1.0-SNAPSHOT/profiles-core-1.0-SNAPSHOT.jar!/com/company/profiles/core/domain] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/.../home/ildella/.m2/repository/com/company/profiles-core/1.0-SNAPSHOT/profiles-core-1.0-SNAPSHOT.jar!/com/company/profiles/core/domain
    at org.springframework.util.ResourceUtils.getFile(Res ourceUtils.java:204)
    at org.springframework.core.io.AbstractFileResolvingR esource.getFile(AbstractFileResolvingResource.java :51)
    at org.springframework.core.io.UrlResource.getFile(Ur lResource.java:168)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.buildSessionFactory(LocalSessionFactoryBe an.java:705)


    Note: I shortened some path in the log, maybe you find some mistakes but trust me, paths are all correct, the problem is loading from the jar.

    So I have two possible ways here:

    1. understand why spring can't load the mapping from the jar and fix it
    2. move to a JPA configuration which I am sure works, from other project I have, that can load domain classes mapped with hbm from the jars cause JPA make autoscan of all hbm so there are no problems.
    In this second option, I have some concern about the old project using HibernateTemplate that needs a SessionFactory that is not defined if I use a org.springframework.orm.jpa.LocalEntityManagerFact oryBean.

    Any tip?

    Thanks.
    Last edited by ildella; Jul 19th, 2010, 08:50 AM.
Working...
X