0

Could someone please explain to me how to use Hibernate with Payara (Glassfish) Server? I created my persistence.xml in META-INF, dropped all required jars in payara41/glassfish/lib directory, but when I try to deploy my bundle it can't find any hibernate packages, even though I specified them in Import-Packages. I could deploy every required Hibernate jar manually, but some of them doesn't have OSGi support. What am I doing wrong here? I just want to get a connection from Glassfish connection pool and list all entries from one table using Hibernate. Btw, why Payara doesn't have an update tool like Glassfish has?


Edited for OndrejM

I just want to be able to use Hibernate to work with my database from osgi bundles, that's all.

Alexey Galanov
  • 421
  • 4
  • 21

1 Answers1

2

Payara/Glassfish stores OSGi bundles in glassfish/modules directory, and not glassfish/lib. Try to put your hibernate bundle there. And it does not have to be a bundle, you can drop plain JARs there - the will be automatically turned into a bundle.

If you get dependency conflicts, you might be better off with repackaging hibernate into an OSGi bundle that includes all its dependencies. Otherwise you may run into conflicts with other Payara modules, which provides the same packages, but with different versions. Another solution would be to specify correct versions of hibernate dependencies, so that correct modules are picked up - but this could be tricky and time-consuming; and almost impossible to discuss over SO.

OndroMih
  • 7,280
  • 1
  • 26
  • 44
  • I have antlr-2.7.7.jar in C:\Program Files (x86)\payara41\glassfish\modules, but still I'm getting **Unable to resolve org.hibernate.core [645](R 645.0): missing requirement [org.hibernate.core [645](R 645.0)] osgi.wiring.package; (osgi.wiring.package=antlr)]** – Alexey Galanov Jun 21 '16 at 07:45
  • Can you explain in more detail what you are trying to achieve? Please update the question with details. Putting too many modules into Payara installation is not a standard thing to do. Your antlr JAR probably conflicts with `antlr-repackaged.jar` module, which also contains the package `antlr`. – OndroMih Jun 22 '16 at 07:14
  • 1
    I improved my answer - generally I think that you face conflicts between OSGi modules, which can be either tweaked by proper configuration of dependencies, or just packing all hibernate dependencies together. – OndroMih Jun 22 '16 at 09:56