Pergunta

I was facing the following error when starting my EJB application in IBM WebSphere Application Server WAS 7.

JPAPUnitInfo E CWWJP0015E: An error occurred in the org.hibernate.ejb.HibernatePersistence persistence provider when it attempted to create the container entity manager factory for the *YOUR_PERSISTENCE_UNIT* persistence unit. The following error occurred: [PersistenceUnit: *YOUR_PERSISTENCE_UNIT*] class or package not found

While this error message may be unnoticed during startup, at the latest when you try to get your entity manager, you will see this error:

javax.ejb.EJBException: Injection failure; nested exception is: java.lang.IllegalStateException: EntityManagerFactory has not been created for PU : PuId=

The error message is similar for different error scenarios, so you find a lot of solutions in the web, but none of them may fit.

Foi útil?

Solução

Indeed the hint from the error message class or package not found is correct, although not that helpful since the missing class name is not told.

In my case I had a class listed in my persistence.xml, which didn't exist any longer.

To see, where this error message comes from, have a look at Ejb3Configuration.addNamedAnnotatedClasses(...) there you will find the following:

throw new PersistenceException( getExceptionHeader() +  "class or package not found", cnfe );

So the information which class wasn't found is available in the cnfe ClassNotFoundException but unfortunately it's not propagated to the log file somehow.

To access the information simply put a debug breakpoint there and inspect the cnfe object.

Outras dicas

If any faces this problem again, like recently I there is pretty simple way to find exact cause, it is however pretty easy to overlook it.

Exact logs for this exception are not shown in main SystemOut/Err logs of WebSphere. It can be however found in ffdc logs (i.e. %APP_PROGILE_PATH%\logs\ffdc).

Look for entries like

[2/18/15 1:49:25:547 UTC] 0000004e FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on \IBM\AppSrv\logs\ffdc\server1_6d42a5e6_15.02.18_01.49.25.1322237127215208595734.txt com.ibm.ws.jpa.management.JPAPUnitInfo.createEMFactory 759

preceding your CWWJP0015E exception in SystemOut.log to find out exact file name for your incident.

If there is no entry for this exception try setting additionally higher log level. However it should not be required for default WebSphere settings. 1. Go to: WebSphere Administration Console > Troubleshooting > Logs and trace > server > Diagnostic trace > Change log detail levels 2. Set the logging level for "com.ibm.ws.jpa.*" to "All messages and traces" 3. Restart WebSphere

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top