I am running the normal Nutch indexing, it used to work 2 days ago perfectly but today out of nowhere it just stopped working with the previous error. Following the stack error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/retry/RetryCallback
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
at org.apache.nutch.plugin.Extension.getExtensionInstance(Extension.java:161)
at org.apache.nutch.indexer.IndexWriters.<init>(IndexWriters.java:55)
at org.apache.nutch.indexer.IndexingJob.index(IndexingJob.java:121)
at org.apache.nutch.indexer.IndexingJob.run(IndexingJob.java:228)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.nutch.indexer.IndexingJob.main(IndexingJob.java:238)
Caused by: java.lang.ClassNotFoundException: org.springframework.retry.RetryCallback
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more
I ended up seeing that the error occurred at this exact piece of code :
Object object = extensionClazz.newInstance();
Another question on SO but with different project was able to fix the issue by adding the spring-framework-messaging dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
well i am using nutch version 1.12 with ivy for dependency management so in my config is the following:
<dependency org="org.springframework.retry" name="spring-retry" rev="1.2.0.RELEASE">
<exclude module="spring-beans"/>
<exclude module="spring-context"/>
<exclude module="spring-core"/>
<exclude module="spring-aop"/>
</dependency>
and even with adding the spring-messaging dependency it's still not working.
Any ideas?
These kind of errors might come when you have more than one version of same jar (same class) in your classpath, You can see the dependency tree by executing
<report conf="compile" /> for ivy projects
And
mvn dependency:tree for maven projects
Narrow down to the version that you want and you can exclude the other jar by explicitly excluding that jar from the module which is importing it .
No idea what went wrong but this was able to fix the problem
ant clean
ant runtime
Related
I have no idea why this is happening. I tried deleting my m2 repository as well.
I tried with various versions of maven plugins(2.8) as well.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
</dependency>
Here is the complete stacktrace :
Error injecting: org.apache.maven.shared.dependency.graph.internal.Maven3DependencyGraphBuilder
java.lang.NoClassDefFoundError: org/sonatype/aether/version/VersionConstraint
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies
(ConstructorBindingImpl.java:181)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.version.VersionConstraint
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
You can solve by using an older version of the plugin as indicated by the official page recalled by the error log:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:tree
Update Maven version, at least to 3.0.x+ or 3.1.x+ see here
This error is caused by Maven 3.1-alpha-1 migration from Sonatype
Aether to Eclipse Aether (MNG-5354), which is an incompatible change
for some plugins.
Other report here claim to use Maven 3.3.0, so in any case, try with latest stable maven first (you can get it from here)
Side question: are you developing maven plugin? Usually you shouldn't declare dependencies on plugins in your pom.xml
The error I'm getting:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/beam/sdk/transforms/DoFn
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.beam.sdk.transforms.DoFn
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
My pom dependencies:
<dependencies>
<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-hbase-beam</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
<version>2.13.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
I assumed that the issue was coming from the two dependencies using different versions of the beam sdk, so I changed the beam-runners-google-cloud-dataflow-java version to 2.11.0, which uses the same beam sdk version. But I got the same error.
Any help would be greatly appreciated!
How are you running the pipeline? I'm guessing that the issue is that the beam jars are not on your classpath. You either need to use the maven exec plugin to invoke your main() with all of the maven dependencies on the classpath or you need to create a fat jar using something like the maven shade plugin or the maven assembly plugin. Please see here for example of how to use the maven exec plugin to run a pipeline:
https://github.com/GoogleCloudPlatform/cloud-bigtable-examples/blob/a017a237fa8dae764451a658150190743c1b4127/java/dataflow-connector-examples/pom.xml#L146-L161
I am trying simple Maven app with Log4J ver 2-beta 9. In my pom.xml file I have these two dependencies (as is mentioned in Log4J Maven webpage):
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta9</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta9</version>
</dependency>
Eclipse sees Log4J library:
But when I package the app and run it this Exception is thrown:
java -cp target/notification-1.0.0.jar com.example.Sandbox
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
at com.example.Sandbox.<clinit>(Sandbox.java:13)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 1 more
I searched for this Exception and it seems to be related to CLASSPATH variable.
How should be CLASSPATH set for Maven project?
Maven is a build tool. It doesn't help you much running the final application.
You can use mvn exec:java -Dexec.mainClass="com.example.Sandbox" to run your app (see the question Maven Run Project) but this gets tedious when you have to pass arguments to it.
You can get the classpath that Maven used to compile your application with mvn dependency:build-classpath
That will print the classpath to the console. Note that it will be missing target/notification-1.0.0.jar
Another useful tool in this area is the assembly plugin; it will create one very big JAR with all the dependencies rolled into a single file when you specify the descriptor jar-with-dependencies.
I keep getting the following error in my dev environment. I use
Eclipse Mars 4.5.1
Oracle JDK 1.7 (build 1.7.0_79-b15) or 1.8 (build 1.8.0_65-b17)
Apache Ant to run the code as well as Eclipse to run the code
Ivy for dependency management where I include the following
<!-- 3rd party dependencies -->
<dependency org="log4j" name="log4j" rev="1.2.16" conf="test->default"/>
<dependency org="commons-httpclient" name="commons-httpclient" rev="3.1" conf="compile->default"/>
<dependency org="org.jvnet.jaxb2_commons" name="jaxb2-basics-runtime" rev="0.6.4" conf="default->runtime"/>
<dependency org="org.jvnet.jaxb2_commons" name="jaxb2-basics-tools" rev="0.6.4" conf="default->runtime"/>
<dependency org="org.jvnet.jaxb2_commons" name="jaxb2-basics" rev="0.6.4" conf="default->runtime"/>
I've seen the other posts on this topic but their answers don't help much. I tried using a jaxb.properties but that did not change the behavior.
javax.xml.bind.context.factory=com.sun.tools.xjc.runtime.JAXBContextFactory
Exception in thread "main" javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com.ibm.xml.xlxp2.jaxb.JAXBContextFactory]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:227)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.acme.merge.util.ProjectsInformation.unMarshal(ProjectsInformation.java:24)
at com.acme.merge.controller.MergeController.main(MergeController.java:44)
Caused by: java.lang.ClassNotFoundException: com.ibm.xml.xlxp2.jaxb.JAXBContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:563)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:225)
... 5 more
What am I overlooking?
I found the root cause. Some of my dependencies in ivy have transitive dependencies that bring in some IBM WS libraries. These libraries override my settings and force the use of com.ibm.xml.xlxp2.jaxb.JAXBContextFactory. Excluding these resolved my issue.
The conflicting jar is from package com.ibm.ws and is called runtime.jar.
The solution that seem to work for me :
https://java.wekeepcoding.com/article/19606872/Issue+in+creating+an+instance+of+JAX-WS+client+to+access+the+service
The Missing class "com.ibm.xml.xlxp2.jaxb.JAXBContextFactory" is available in the jar "com.ibm.jaxws.thinclient_8.5.0.jar" which will be available in the server runtime directory for Websphere App server : C:\Program Files\IBM\WebSphere\AppServer\runtimes.
Please include this jar for compile purpose only and donot include this in your WAR or EAR as it will conflict with your server runtime library jar.
For server WAS 8.0 the path jar would be "com.ibm.jaxws.thinclient_8.0.0.jar".
I've got Ant and Ivy setup so that I can use Ivy downloaded JARs to run PMD. Trying the same with FindBugs, setting the findbugs.home Ant property to ivy-jars/findbugs, where the Ivy JARs go. I initially got the error that it couldn't find the JAR files under the ${findbugs.home}/lib directory. I fixed that by changing Ivy to download the JAR files into ivy-jars/findbugs/lib. However, this gave rise to the new error:
Executing findbugs FindBugsTask from ant task
Running FindBugs...
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/bcel/classfile/ClassFormatException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.bcel.classfile.ClassFormatException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
This turns out to be caused by three problems:
I retrieved the JAR files using symlink="true". FindBugs dereferences the symlink to findbugs.jar and looks for all of its other JAR files under the same directory, but the way Ivy structures its cache only the findbugs.jar is in that directory. This can be fixed easily enough by not using symlinks.
FindBugs wants its JAR files to sometimes have the filename format [artifact].[ext] and sometimes have the format [artifact]-[revision].[ext], which can be solved by doing <ivy:retrieve> two times with different pattern values.
FindBugs wants the file name for the BCEL JAR file to be exactly bcel-6.0-SNAPSHOT.jar rather than bcel-findbugs.jar or bcel-findbugs-6.0.jar; this can be fixed with a symbolic link.
I consider this to just be a workaround, rather than a true solution, since #2 and #3 can't be how FindBugs is intended to be used under Ivy. So if anyone knows the right way to do it, please provide a better answer.
Contrary to the documentation, the home attribute is not required. Instead, you can provide a nested classpath element, which can be any path-like structure.
The following Ant target works for me:
<target name="findbugs" description="Run findbugs on the code">
<ivy:retrieve/>
<ivy:cachepath pathid="findbugs.classpath" conf="findbugs"/>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.classpath"/>
<findbugs>
<classpath refid="findbugs.classpath"/>
<class location="my-analysis-target.jar"/>
</findbugs>
</target>
Where my ivy.xml is:
<ivy-module version="2.0">
<info organisation="meh" module="meh"/>
<configurations defaultconfmapping="findbugs->default">
<conf name="findbugs"/>
</configurations>
<dependencies>
<dependency org="com.google.code.findbugs" name="findbugs" rev="3.0.1" conf="findbugs"/>
</dependencies>
</ivy-module>