I configured and I use Datanucleus JPA to connect to MySQL. I compile the classes and enhanced entities with datanucleus-enhancer-plugin. I can run my app using mvn exec:java and I can also run it after I create an archive with lib (jar dependencies).
The problem appears when I create a jar (jar-with-dependencies). I get this error:
javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "mysql" after trying the following discovered implementations: org.datanucleus.api.jpa.PersistenceProviderImpl from provider: org.datanucleus.api.jpa.PersistenceProviderImpl
at javax.persistence.Persistence.createPersistenceException(Persistence.java:244)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:186)
at cantina.crawler.util.JpaUtil.getRdbmsEntityManager(JpaUtil.java:29)
at cantina.crawler.bolt.SiteDetectorBolt.prepare(SiteDetectorBolt.java:32)
at backtype.storm.daemon.executor$fn__4050$fn__4059.invoke(executor.clj:610)
at backtype.storm.util$async_loop$fn__465.invoke(util.clj:375)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.datanucleus.exceptions.NucleusException: Error creating handler of type "persistence" for metadata parsing : MetaData handler plugin "persistence" was not found. Please check your CLASSPATH and plugin specification.
at org.datanucleus.metadata.xml.MetaDataParser.parseMetaDataStream(MetaDataParser.java:269)
at org.datanucleus.metadata.xml.MetaDataParser.parseMetaDataURL(MetaDataParser.java:137)
at org.datanucleus.metadata.MetaDataUtils.parsePersistenceFiles(MetaDataUtils.java:956)
at org.datanucleus.api.jpa.JPAEntityManagerFactory.<init>(JPAEntityManagerFactory.java:342)
at org.datanucleus.api.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:91)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:152)
... 6 more
Caused by: org.datanucleus.exceptions.NucleusUserException: MetaData handler plugin "persistence" was not found. Please check your CLASSPATH and plugin specification.
at org.datanucleus.metadata.xml.MetaDataParser.parseMetaDataStream(MetaDataParser.java:263)
... 11 more
I unziped the jar and the datanucleus-core files are there. I can not figure out what is happening.
You've not bothered looking after MANIFEST.MF and plugin.xml files when you changed the jar(s). DataNucleus jars are packaged to allow the (OSGi-based) plugin mechanism to identify plugins and capabilities. You've disabled that by playing around with those jars, so get the consequences.
Solution : either use the jars as provided, or merge them correctly (in which case it's your responsibility)
Related
I was upgrading spring 3.x to 5.3.x version in my project. Done some spring 5.3.x specific changes and deployed the build. Then following exception came:
Exception:"Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax.persistence.Converter"
Solution applied: added hibernate-jpa-2.1-api-1.0.0.Final as a solution.
Next following exception came:
"java.lang.ClassNotFoundException: org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
In spring docs, I could see ,OpenJpaVendorAdaptor is removed from spring5.x and jpa 2.1 compliant persistence provider is needed. when searching, could see using eclipselink is one of the solution instead of OpenJpa.
For which I have changed, org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter to org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter and in persistence.xml added org.eclipse.persistence.jpa.PersistenceProvider as provider tag.Then eclipselink-2.6.4 dependency added as gradle dependency.
could see jar is getting generated , but classes from jar is not picking up. getting following error on code compilation:
"Starting the enhancement task
[ant:openjpac] WARNING: Unable to load persistence provider "org.eclipse.persistence.jpa.PersistenceProvider" due to "java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider""
Please help.
i am getting below error while doing log in to my application which uses Java 8 and Jboss 7.0.5 (just patched from 7.0.4 to 7.0.5) :
11:57:19,190 ERROR [stderr] (default task-7) Caused by: java.lang.NoClassDefFoundError: com/sun/net/ssl/internal/ssl/Provider 2018-01-02 11:57:19,190 [default task-7] ERROR stderr - Caused by: java.lang.NoClassDefFoundError: com/sun/net/ssl/internal/ssl/Provider
This error has been occuring after applying patch
any help valuable suggestions would be really appriciated!!!
Jboss 7 looks for dependencies in the modules folder. You can't just go in the modules.xml file and add new modules if they don't actually exist.
What you need to do is find out whether there is a jar containing the missing class, if it exist then you need to add a reference to that module from your project, if does not exist, you need to manually download it and copy it to the modules directory and then reference it.
You have several ways you can reference it:
Add a classpath entry to your manifest file: Classpath: com.sun.net
Add a global reference to that module in your standalone.xml by adding a Global module.
For more details, look here.
Can you please help me with following error I'm facing in WAS9 environment:
In order to resolve the import
org.apache.cxf.binding.soap.SoapHeader
I added the following dependencies in my pom.xml:
cxf-api-2.7.7
cxf-rt-bindings-soap-2.7.7
But when I'm trying to run my application, I'm getting the following error.
Default Executor-thread-7] ([ ]) Controllerclass - org.apache.cxf.bus.extension.ExtensionException
at org.apache.cxf.bus.extension.Extension.load(Extension.java:222)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(ExtensionManagerImpl.java:199)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.initialize(ExtensionManagerImpl.java:118)
at org.apache.cxf.bus.extension.ExtensionManagerBus.doInitializeInternal(ExtensionManagerBus.java:147)
at org.apache.cxf.bus.CXFBusImpl.initialize(CXFBusImpl.java:191)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createBus(LibertyApplicationBusFactory.java:119)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createClientScopedBus(LibertyApplicationBusFactory.java:86)
at com.ibm.ws.jaxws.metadata.JaxWsClientMetaData.<init>(JaxWsClientMetaData.java:28)
at com.ibm.ws.jaxws.metadata.JaxWsModuleMetaData.getClientMetaData(JaxWsModuleMetaData.java:123)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:84)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:123)
at com.ibm.ws.jaxws.client.LibertyProviderImpl.createServiceDelegate(LibertyProviderImpl.java:56)
at javax.xml.ws.Service.<init>(Service.java:57)
Caused by: java.lang.InstantiationException:org.apache.cxf.bus.osgi.OSGIBusListener
at java.lang.Class.newInstance(Class.java:427)
at org.apache.cxf.bus.extension.Extension.load(Extension.java:218)
Caused by: java.lang.NoSuchMethodException:org.apache.cxf.bus.osgi.OSGIBusListener.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
The server where your WAS9 has been deployed has different version of the above jar file. You need to have same version of jar files both in your eclipse where you have developed your codes and the server where you are deploying the war or ear.
mavan dependency file pom.xml is used during your project compilation. It might add the jar in your binary under lib folder as well. But WAS9 might considering the one which is in server's CLASSPATH. Hence check your class path and replace that jar with the one which you have mentioned in your pom.xml file. Hope that will fix your issue.
We can eliminate this exception by adding webProfile-7.0 in our server.xml, but how ever this is not working with javaee-7.0 not sure, if one knows about how to handle this in javaee-7.0 please share your approach.
After deploy custom rule (like https://github.com/SonarSource/sonar-java/blob/master/java-checks/src/main/java/org/sonar/java/checks/UselessImportCheck.java), when I start SonarQube 4.2, following exception is thrown during sonar start:
Caused by: java.lang.ClassNotFoundException: com.sonar.sslr.api.AstAndTokenVisitor
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) ~[plexus-classworlds-2.2.3.jar:na]
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244) ~[plexus-classworlds-2.2.3.jar:na]
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230) ~[plexus-classworlds-2.2.3.jar:na]
... 44 common frames omitted
Above mentioned class should be found in sslr-core-1.19.2.jar, which I found in location sonarqube-4.2/web/deploy/plugins/squidjava/META-INF/lib/sslr-core-1.19.2.jar
Am I missing some step to enhnance default sonar libraries?
Currently installed plugins are(sonarqube-4.2/extensions/plugins):
sonarqube-4.2/extensions/plugins/sonar-checkstyle-plugin-2.1.jar
sonarqube-4.2/extensions/plugins/sonar-web-plugin-2.1.jar
sonarqube-4.2/extensions/plugins/sonar-jacoco-plugin-2.2.1.jar
sonarqube-4.2/extensions/plugins/sonar-java-plugin-2.2.1.jar
sonarqube-4.2/extensions/plugins/sonar-surefire-plugin-2.2.1.jar
sonarqube-4.2/extensions/plugins/sonar-pmd-plugin-2.2.jar
sonarqube-4.2/extensions/plugins/sonar-findbugs-plugin-2.2.1.jar
sonarqube-4.2/extensions/plugins/sonar-squid-java-plugin-2.2.1.jar
What should I do to prevent above mentioned exception(except undeploy mentioned custom plugin)?
Should be necessary libraries bundled directly in to the custom plugin? I expected sonar to have such libraries bundled.
Finally I found solution/explanation for the problem:
sonarqube-4.2/web/deploy/plugins/ directory is dynamically updated during sonar start from the sonarqube-4.2/extensions/plugins directory. Every plugin should have lib directory in his META-INF jar.Such lib directory should contain all necessary libraries.
In my case:
META-INF/lib/asm-5.0.1.jar
META-INF/lib/java-checks-2.2.1.jar
META-INF/lib/java-squid-2.2.1.jar
META-INF/lib/jaxen-1.1.4.jar
META-INF/lib/sslr-core-1.19.2.jar
META-INF/lib/sslr-squid-bridge-2.3.jar
META-INF/lib/sslr-xpath-1.19.2.jar
And META-INF/MANIFEST.MF must besides othet important definitions contain link to these libraries:
Plugin-Dependencies: META-INF/lib/java-checks-2.2.1.jar META-INF/lib/j
axen-1.1.4.jar META-INF/lib/sslr-squid-bridge-2.3.jar META-INF/lib/ss
lr-xpath-1.19.2.jar META-INF/lib/asm-5.0.1.jar META-INF/lib/sslr-core
-1.19.2.jar META-INF/lib/java-squid-2.2.1.jar
After these steps deploy success and plugin is ready to be used.
Above mentioned fact is may be clear for MAVEN users (there is lot of pom files),but gradle users must create such builds on their own and this information may be useful for them.
Good luck!
I am trying to setup Hibernate tools – attaching it to the spring petclinic project. So far the problem is in classpath. My actions:
Click on hibernate on the Hibernate Configuration view
Add
postgresql-9.1.jar located in the root directory of the
spring-petclinic project
The result is the error: [Classpath]: Archive classpath entry doesn't exist [/spring-petclinic/postgresql-9.1.jar] ( see http://jboston.net/HIbernateToolsError.jpg for the image)
See also the log:
java.lang.IllegalArgumentException: Path must include project and resource name: /postgresql-9.1.jar
java.lang.IllegalArgumentException: Path must include project and resource name: /postgresql-9.1.jar
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2170)
at org.eclipse.core.internal.resources.Container.getFile(Container.java:208)
at org.hibernate.eclipse.console.utils.ProjectUtils.findJavaProjects(ProjectUtils.java:308)
at org.hibernate.eclipse.console.workbench.ProjectCompilerVersionChecker.validateProjectComplianceLevel(ProjectCompilerVersionChecker.java:35)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:37)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:100)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
#Craig Ringer answer helped. My workaround was as follows:
Create the user library with a postgresql jdbc jar
From the Hibernate configuration classpath tab select Advanced on the
right menu
Choose "Add library"
It looks like you've attempted to add the JDBC jar as a required project. Don't. Add it as a library dependency instead.
See this list of ways to do it - unverified, as I thankfully no longer have to use Eclipse anymore.