Jpa-hibernate error while starting the service

后端 未结 2 1805
予麋鹿
予麋鹿 2021-01-16 06:03

Below is the error from the log that i see after starting the service... can you help resolving this issue.

2013-08-22 10:35:37,111 | DEBUG | l Console Threa         


        
相关标签:
2条回答
  • 2021-01-16 06:18

    The current aries jpa container jar 1.0.0 has a bug that makes it swallow exceptions on creating the EntityManager. A colleague of me opened the aries bug: https://issues.apache.org/jira/browse/ARIES-1160

    I created a second patch that can be applied to the 1.0.0 sources to create a jar that correctly logs the exception. Check out the 1.0.0 tag of aries jpa container, apply the patch and build.

    When you then run in karaf you should see the real source of the error.

    0 讨论(0)
  • 2021-01-16 06:38

    In case you use Aries JPA you should see two EntityManagerFactory services:

    • jpa-container picks up your bundle with the persistence.xml and creates an Entity manager factory
    • jpa-container-context picks up every EntityManagerFactory service and makes a new managed EntityManagerFactory service with the (org.apache.aries.jpa.proxy.factory=true) service property key-value pair

    The second does not exist in your environment. There can be two causes:

    • aries-jpa-container-context is not in your OSGi environment or it is not in ACTIVE state
    • The original EntityManagerFactory service is not registered as some dependency is missing

    You can check it if you open an OSGi console and check what services available. If there is no EntityManagerFactory service at all, the second is your problem.

    Check if all of your bundles are active! If they are, check if you have all the services that jpa-container needs: TransactionManager, DataSource or DataSourceFactory and a javax.persistence.spi.PersistenceProvider service for Hibernate. If any of the services are missing aries-jpa-container will pick up your bundle but will never create the EntityManagerFactory.

    I implemented an own jpa-container that works almost the same way as aries-jpa-container. If you replace the aries-jpa-container (only that one, the jpa-container-context should be left there) it will log more messages at INFO level for you what is missing. The container is available here. A sample application is available that uses hibernate is available at https://github.com/everit-org/osgi-hibernate. After running "mvn install" you will find itests/core/target/eosgi-itests-dist/equinox a subfolder where you can start the working application with on equinox server with bin/runconsole.sh.

    0 讨论(0)
提交回复
热议问题