edrikL / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

net.bull.javamelody.JpaPersistence.guessDelegate (JpaPersistence.java:202) [javamelody-core-1.55.0.jar:1.55.0]Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: Can't find a delegate #460

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Installl WildFly 8.2 from http://wildfly.org/downloads/
2. Run WildFly form command line standalone.bat (or .sh) (there is an example 
datasource)
3. Build application (mvn package)
4. Copy application to deployments folder

What is the expected output? What do you see instead?
Java melody is able to start monitor JDBC

What version of the product are you using? On what application server, JDK,
operating system?
- Windows 7
- Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
- Jboss wildfly 8.2

Please provide any additional information below.
Exception thrown:
2015-02-26 11:53:33,694 ERROR [org.jboss.msc.service.fail] (ServerService 
Thread Pool -- 68) MSC000001: Failed to start service 
jboss.persistenceunit."melodytest-1.0-SNAPSHOT.war#QuickStart": 
org.jboss.msc.service.StartException in service 
jboss.persistenceunit."melodytest-1.0-SNAPSHOT.war#QuickStart": 
java.lang.IllegalStateException: java.lang.ClassNotFoundException: Can't find a 
delegate
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_60]
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: 
Can't find a delegate
    at net.bull.javamelody.JpaPersistence.guessDelegate(JpaPersistence.java:202) [javamelody-core-1.55.0.jar:1.55.0]
    at net.bull.javamelody.JpaPersistence.loadOrGuessDelegate(JpaPersistence.java:170) [javamelody-core-1.55.0.jar:1.55.0]
    at net.bull.javamelody.JpaPersistence.findDelegate(JpaPersistence.java:162) [javamelody-core-1.55.0.jar:1.55.0]
    at net.bull.javamelody.JpaPersistence.createContainerEntityManagerFactory(JpaPersistence.java:124) [javamelody-core-1.55.0.jar:1.55.0]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    ... 8 more
Caused by: java.lang.ClassNotFoundException: Can't find a delegate
    ... 15 more

2015-02-26 11:53:33,703 ERROR [org.jboss.as.controller.management-operation] 
(DeploymentScanner-threads - 2) JBAS014613: Operation 
("full-replace-deployment") failed - address: ([]) - failure description: 
{"JBAS014671: Failed services" => 
{"jboss.persistenceunit.\"melodytest-1.0-SNAPSHOT.war#QuickStart\"" => 
"org.jboss.msc.service.StartException in service 
jboss.persistenceunit.\"melodytest-1.0-SNAPSHOT.war#QuickStart\": 
java.lang.IllegalStateException: java.lang.ClassNotFoundException: Can't find a 
delegate

Original issue reported on code.google.com by javafx....@gmail.com on 26 Feb 2015 at 12:12

Attachments:

GoogleCodeExporter commented 9 years ago
I have reproduced the same exception.
And you can find the class related to this at:
https://code.google.com/p/javamelody/source/browse/trunk/javamelody-core/src/mai
n/java/net/bull/javamelody/JpaPersistence.java#31

First, in your META-INF/persistence.xml file, you have written the following 
line to monitor JPA:
<provider>net.bull.javamelody.JpaPersistence</provider>
At the moment, a simple and working workaround to the issue is to not try to 
monitor JPA when using WildFly 8.2. That is, keep JavaMelody monitoring but 
remove "<provider>net.bull.javamelody.JpaPersistence</provider>" from your 
META-INF/persistence.xml file.

Then, this issue happens because the context class loader in the webapp does 
not find the org.hibernate.jpa.HibernatePersistenceProvider / 
org.hibernate.ejb.HibernatePersistence classes.
So, another workaround is to configure the class loading for WildFly: add a 
META-INF/MANIFEST.MF file in the resources of your webapp, with the following 
content:
Manifest-Version: 1.0
Dependencies: org.hibernate
That will workaround the issue and will probably make the JPA monitoring work.
References:
https://docs.jboss.org/author/display/WFLY8/JPA+Reference+Guide
https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly

Meanwhile, I have posted an asynchronous question to Sirona and JavaMelody 
mailing lists to ask if that could be simplified for a later release:
https://groups.google.com/forum/#!topic/javamelody/u4iDM4lHxsQ

Original comment by evernat@free.fr on 21 Mar 2015 at 11:37

GoogleCodeExporter commented 9 years ago
After discussion with Sirona devs (Romain in the users' group above), the 
suggestion to use 
"PersistenceProviderResolverHolder.getPersistenceProviderResolver().getPersisten
ceProviders()" was included in Sirona and is now also included in javamelody.
So the 2 workarounds given in the comment above will not be needed anymore to 
monitor JPA in WildFly 8.2, with the next javamelody release.

This is committed in trunk (revision 4051) and ready for the next release 
(1.56).

To test that it works, you can download a build of the trunk, including this 
change, at:
https://javamelody.ci.cloudbees.com/job/javamelody/net.bull.javamelody$javamelod
y-core/lastSuccessfulBuild/artifact/net.bull.javamelody/javamelody-core/

Original comment by evernat@free.fr on 1 Apr 2015 at 9:30