java - Hibernate Mappings cannot be found, only when running from a JAR -
java - Hibernate Mappings cannot be found, only when running from a JAR -
i have project in src/main/resources have 2 mapping files.
foo.hbm.xml, bar.hbm.xml
when running main class eclipse, works fine. when exporting jar file using maven assembly plugin, cannot create session mill due missing mapping files. error:
exception in thread "main" org.hibernate.mappingexception: resource: foo.hbm.xml not found
i not using spring altough tried spring , have same problem srping's session mill cannot find mapping when running jar. implementation following. code:
configuration hibernateconfig = new configuration(); hibernateconfig.configure("hibernate.cfg.xml"); hibernateconfig.addresource("foo.hbm.xml"); hibernateconfig.addresource("bar.hbm.xml"); hibernateconfig.setproperty("hibernate.connection.url", conf.dburl); hibernateconfig.setproperty("hibernate.connection.username", conf.dbusername); hibernateconfig.setproperty("hibernate.connection.password", conf.dbpassword);
i have tried add together mappings trough hibernate.cfg.xml did not work same result, works in eclipse not when using runnable jar. maven assemly config following.
<plugin> <artifactid>maven-assembly-plugin</artifactid> <configuration> <descriptorrefs> <descriptorref>jar-with-dependencies</descriptorref> </descriptorrefs> <archive> <manifest> <mainclass>com.app.entrypoint</mainclass> </manifest> </archive> </configuration> </plugin>
i create jar mvn assembly:assembly , when open mappings there in root (/) of jar.
edit
facepalm moment after looking @ 6 hours. foo.hbm.xml wrongly spelled mapping called motaccounts.hbm.xml , used motaccounts.hbm.xml.
what threw me off of possibility worked in eclipse, didn't worked in jar. said face palm moment.
java hibernate maven jar maven-assembly-plugin
Comments
Post a Comment