简体   繁体   中英

Error injecting entity manager with Wicket/JPA

I have an app using Wicket for the presentation layer with CDI/Weld, JPA 2.0, EJB 3.1 etc. (Java EE 6) deployed on GlassFish v3.0.1.

When I try to inject an EJB into a wicket page using @EJB I get the following error: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName

When I try to inject using @Inject, I get the following error: java.lang.IllegalStateException: Unable to convert ejbRef for ejb UserRepository to a business object of type class

I believe the problem is stemming from JPA. I am using the exact same configuration that I used with a JSF application which worked properly, so I am lost as to what the issue could be. The connection pools are set up properly and pinging correctly through GlassFish, I have included wicket-weld on the classpath and I have even tried using the old Java EE 5 wicketstuff project for wicketstuff-javaeeapi with the same results.

Any help would be appreciated.

If you get the exception:

Unable to retrieve EntityManagerFactory for unitName

It might mean it is not detecting your persistence.xml file. Make sure it's in the WEB-INF\\classes\\META-INF directory.

You can verify that your app has JPA enabled by going to the Admin Console in GlassFish, go to the Applications section and see if it shows something like [ejb, web, weld, jpa] for your app. If it doesn't show jpa then it's not finding your JPA config file.

Could always try to lookup the EJB via its standard "java:global" name. That should at least let you rule out wicket as a possible source of issues and get you a little closer to a working system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM