Announcement Announcement Module
No announcement yet.
Cannot locate hibernate mappings files in jar Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot locate hibernate mappings files in jar

    We tried configuring the LocalSessionFactoryBean to locate the hibernate mapping files in a jar or directory. Neither seems to work. We get the error: class path resource [classpath*:hibernate-mapping] cannot be resolved to URL because it does not exist
    at RL(
    at ile(
    at org.springframework.orm.hibernate.LocalSessionFact oryBean.afterPropertiesSet(LocalSessionFactoryBean .java:463)

    Here's how we tried to configure the sessionfactory:

    <property name="mappingJarLocations">

    where hibernate-mappings.jar was in the root of the ear

    and we tried:

    <property name="mappingDirectoryLocations">

    where the directory was in the root directory of the ear.

    Neither works. I saw in your posting that you got it to work with the directory on the file system. Am I doing something wrong? We also tried giving the absolute path of the directory and jar - that didn't work either.

  • #2
    Can you do that?

    I have always kept my mapping files within the WAR and listed them directly. Using classpath:/class.hbm.xml,classpath:/class1.hbm.xml etc.

    Are you sure it can load them from a jar? If so you might have to use the special jar notation which is something like (i.e. I can't remember exactly ):


    Just guessing though so don't take this too seriously


    • #3
      Same problem

      Have you been able to fix this issue?
      I am getting the same error.



      • #4
        You must place your mapping files in a subdirectory. Do to limitations in the way java handles jar files, unfortunately, it's not possible to do a classpath* search for resources located in the root path of a jar/war etc..

        See the comments for PathMatchingResourcePatternResolver.




        • #5
          Oliver's right, but just to make it clear with a sample...
          For application contexts in the classpath at:


          If they're in WEB-INF/classes the following will work:

          If they're in a JAR in WEB-INF/lib (for example) the following will work:

          For anything in the root of a JAR, you can't use wildcards to load it.