Karaf OSGi: JAX-RS with CXF: ClassNotFoundException: org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl - maven

When installing a CXF web service bundle in Karaf OSGi (built with maven), the following error is logged:
2013-03-18 15:08:29,050 | ERROR | rint Extender: 2 | BlueprintContainerImpl | container.BlueprintContainerImpl 393 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Unable to start blueprint container for bundle service-server
org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor <name: serviceBeans, getter: null, setter: [class org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setServiceBeans(interface java.util.List)]
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:941)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:907)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:888)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[7:org.apache.aries.blueprint.core:1.1.0]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_41]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_41]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)[7:org.apache.aries.blueprint.core:1.1.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)[:1.6.0_41]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_41]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_41]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[7:org.apache.aries.blueprint.core:1.1.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)[:1.6.0_41]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_41]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_41]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)[:1.6.0_41]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)[:1.6.0_41]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)[:1.6.0_41]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)[:1.6.0_41]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_41]
Caused by: java.lang.ExceptionInInitializerError
at org.apache.cxf.jaxrs.utils.JAXRSUtils.<clinit>(JAXRSUtils.java:107)
at org.apache.cxf.jaxrs.model.ClassResourceInfo.getConsumeMime(ClassResourceInfo.java:239)
at org.apache.cxf.jaxrs.model.OperationResourceInfo.checkMediaTypes(OperationResourceInfo.java:171)
at org.apache.cxf.jaxrs.model.OperationResourceInfo.<init>(OperationResourceInfo.java:74)
at org.apache.cxf.jaxrs.utils.ResourceUtils.createOperationInfo(ResourceUtils.java:354)
at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:221)
at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:207)
at org.apache.cxf.jaxrs.JAXRSServiceFactoryBean.setResourceClassesFromBeans(JAXRSServiceFactoryBean.java:218)
at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setServiceBeans(JAXRSServerFactoryBean.java:295)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_41]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_41]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_41]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_41]
at org.apache.aries.blueprint.utils.ReflectionUtils$MethodPropertyDescriptor.internalSet(ReflectionUtils.java:628)
at org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.set(ReflectionUtils.java:378)
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:939)
... 26 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:122)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:91)
at javax.ws.rs.core.MediaType.<clinit>(MediaType.java:44)
... 42 more
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)[:1.6.0_41]
at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_41]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)[:1.6.0_41]
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)[:1.6.0_41]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)[:1.6.0_41]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_41]
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:37)
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:133)
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:105)
... 44 more
This changed from the previous Caused by: java.lang.ClassNotFoundException: com.sun.rs.ws.ext.RuntimeDelegateImpl when, based on the suggestion from several locations, I added the following line my ext/system.properties file:
javax.ws.rs.ext.RuntimeDelegate=org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl
I'm also explicitly importing this package in my pom with:
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.6</version>
<extensions>true</extensions>
<configuration>
<instructions>
...
<Import-Package>org.apache.cxf.jaxrs.impl,*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
The only bundles exporting anything related (as far as I can tell) are:
Apache ServiceMix :: Specs :: JSR-311 API 1.1.1(org.apache.servicemix.specs.jsr311-api-1.1.1)
Exporting:
javax.ws.rs,version=1.1.1
javax.ws.rs.core,version=1.1.1
javax.ws.rs.ext,version=1.1.1
Apache CXF Bundle Jar(org.apache.cxf.bundle)
Exporting
~25 org.apache.cxf.jaxrs.____ or so packages (including impl)
Can anyone help? I haven't managed to find any fixes that resolve the issue.

Not really an answer, but my solution was to drop CXF entirely. Now using simple servlets (javax.servlet)

Related

How can I run JDK 19 with Structured Concurrency? (ERROR: java.lang.NoClassDefFoundError: jdk/incubator/concurrent/StructuredTaskScope)

Note: this post somehow related with this question; however, the error is different. So I am posting as another question.
I want to try the new Project Loom feature defined in: JEP 428: Structured Concurrency (Incubator)
I created a library project that uses class StructuredTaskScope, which can compile right.
Then I created a test project to demonstrate the use of library project, which can compile right too.
In pom.xml, both projects use:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>19</release>
<compilerArgs>
<arg>--enable-preview</arg>
<arg>--add-modules=jdk.incubator.concurrent</arg>
</compilerArgs>
</configuration>
</plugin>
However, When i try to run the test project, it returns error below:
C:\me\codes\com.tugalsan\tst\com.tugalsan.tst.thread>java -jar target/com.tugalsan.tst.thread-1.0-SNAPSHOT-jar-with-dependencies.jar --enable-preview --add-modules jdk.incubator.concurrent
Exception in thread "main" java.lang.NoClassDefFoundError: jdk/incubator/concurrent/StructuredTaskScope
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.tugalsan.api.thread.server.TS_ThreadFetchAll.<init>(TS_ThreadFetchAll.java:44)
at com.tugalsan.api.thread.server.TS_ThreadFetchAll.of(TS_ThreadFetchAll.java:85)
at com.tugalsan.tst.thread.Main.main(Main.java:13)
Caused by: java.lang.ClassNotFoundException: jdk.incubator.concurrent.StructuredTaskScope
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 12 more
I also tried adding '=' character, but no luck: java -jar target/com.tugalsan.tst.thread-1.0-SNAPSHOT-jar-with-dependencies.jar --enable-preview --add-modules=jdk.incubator.concurrent
As Joachim Sauer answered:
Everything after the -jar filename.jar will be passed as an argument.
Hence to run an app with jdk.incubator.concurrent, one should use below order:
java --enable-preview --add-modules jdk.incubator.concurrent -jar JARFILENAME.jar argument0 argument1 argument2...

felix maven-bundle-plugin error (&(osgi.wiring.package=com.a.b.c)(version>=xx.0.0)(!(version>=yy.0.0)

i use Apache Felix to implement osgi bundle and use it as embedded Felix framework to call boundle
here is my maven plugin to build MANIFEST.MF :
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.5.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Bundle-Activator>a.b.c.osgi.activator.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
i build project and then use jar file in embeded felix like this
BundleContext bundleContext = f.getBundleContext();
Bundle bundle = bundleContext.installBundle(
"file:/home/eclipse_workSpace/my-module/target/abc-1.1.0.jar");)
String bName = bundle.getLocation();
bundle.getRegisteredServices();
bundle.getState();
/* Bundle[] bls = bundleContext.getBundles(); */
System.out.println("starting bundle " + bName);
bundle.start();
when i start boundle i got this exception
Exception in thread "main" org.osgi.framework.BundleException: Unable to resolve a.b.c [1](R 1.0): missing requirement [a.b.c [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=com.google.common.base)(version>=21.0.0)(!(version>=22.0.0))) Unresolved requirements: [[a.b.c [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=com.google.common.base)(version>=21.0.0)(!(version>=22.0.0)))]
what should i do to solve this problem?
This error message means that your bundle depends on Google Guava, version 21. Specifically this line:
missing requirement [a.b.c [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=com.google.common.base)(version>=21.0.0)(!(version>=22.0.0)))
... means that your bundle "a.b.c" imports the package com.google.common.base with version greater-than-or-equal to 21 and not-greater-than-or-equal to 22. Since your bundle imports this package, there must be another bundle in your OSGi Framework that exports the package.
The solution is to ensure that Guava 21 is installed into your OSGi Framework.

OSGI bundle is not getting started in Apache Servicemix

I am developing http client application as a OSGI bundle project, i have used apache maven to create project folder structure used below command.
mvn archetype:generate -DarchetypeGroupId=org.apache.karaf.archetypes -DarchetypeArtifactId=karaf-blueprint-archetype -DarchetypeVersion=2.3.7 -DgroupId=com.techiyhub -DartifactId=integration.sms -Dversion=1.0-SNAPSHOT -Dpackage=com.techiyhub.integration.sms
The above command created project folder structure, as i am using httpclient based application. i have added dependencies in pom.xml as below.
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
<groupId>com.techiyhub</groupId>
<artifactId>integration.sms</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>integration.sms Blueprint Bundle</name>
<description>integration.sms OSGi blueprint bundle project.</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>
com.techiyhub.integration.sms*;version=${project.version}
</Export-Package>
<Import-Package>
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
I executed below command,
mvn install
it created desired jar file in local maven repository.
Problem started here. i tried to deploy the bundle in apache servicemix it has installed the bundle but while starting bundle it gave an error
i have executed below commands in servicemix shell
osgi:install mvn:com.techiyhub/integration.sms/1.0-SNAPSHOT
it got installed with bundle id, then i executed below command
osgi:start 302
It gave below error
Error executing command: Error starting bundles:
Unable to start bundle 302: Unresolved constraint in bundle integration.sms [302]: Unable to resolve 302.0: miss
ing requirement [302.0] osgi.wiring.package; (osgi.wiring.package=org.apache.http)
Full error stack trace as below
2015-10-26 14:33:12,551 | ERROR | l Console Thread | Console | 22 - org.apache.karaf.shell.cons
ole - 2.4.3 | Exception caught while executing command
org.apache.karaf.shell.console.MultiException: Error starting bundles:
Unable to start bundle 302: Unresolved constraint in bundle integration.sms [302]: Unable to resolve 302.0: miss
ing requirement [302.0] osgi.wiring.package; (osgi.wiring.package=org.apache.http)
at org.apache.karaf.shell.console.MultiException.throwIf(MultiException.java:91)
at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:43)
at org.apache.karaf.shell.osgi.BundlesCommand.doExecute(BundlesCommand.java:37)
at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_80]
at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)[16:org.apache.aries.proxy.impl:1.0.4]
at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)[16:org.apache.aries.proxy.impl:1.0.4]
at org.apache.karaf.shell.console.commands.$BlueprintCommand22803378.execute(Unknown Source)[22:org.apache.karaf
.shell.console:2.4.3]
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[22:org.apache.karaf.shell.console:2.
4.3]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[22:org.apache.karaf.shell.console:2.4.3]
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[22:org.apache.karaf.shell.console:2.
4.3]
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[22:org.apache.karaf.shell.console:2.4.3]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[22:org.apache.karaf.shell.console:2.4.3]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[22:org.apache.karaf.shell.console:2.4.3]
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)[22:org.apache.karaf.shel
l.console:2.4.3]
at org.apache.karaf.shell.console.jline.Console.run(Console.java:195)[22:org.apache.karaf.shell.console:2.4.3]
at org.apache.karaf.shell.console.jline.DelayedStarted.run(DelayedStarted.java:79)[22:org.apache.karaf.shell.con
sole:2.4.3]
Caused by: java.lang.Exception: Unable to start bundle 302: Unresolved constraint in bundle integration.sms [302]: Unabl
e to resolve 302.0: missing requirement [302.0] osgi.wiring.package; (osgi.wiring.package=org.apache.http)
at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:39)
... 18 more
Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle integration.sms [302]: Unable to resolve
302.0: missing requirement [302.0] osgi.wiring.package; (osgi.wiring.package=org.apache.http)
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963)
at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:37)
... 18 more
Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle : Unable to resolve: missing requirement [302.0] osgi.wiring.package;(osgi.wiring.package=org.apache.http)
Please help me out on this.
When you create a bundle the maven bundle plugin scans the class files of your project for all used packages. It creates Import-Package statements for these in the Manifest.
Then at runtime you have to make sure you also install all necessary libraries you need to run your bundle. The error message helps you in finding the correct bundles to install. So in your case you have to install a bundle that exports the package org.apache.http.
In your case these are:
mvn:org.apache.httpcomponents/httpcore-osgi/4.3.3
mvn:org.apache.httpcomponents/httpclient-osgi/4.3.6

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/util/Tool

I get below error when i package (jar) and run my defaulthadoopjob.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/util/Tool
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.Tool
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 12 more
Could not find the main class: DefaultHadoopJobDriver. Program will exit.
Commands used to build Jar.
# jar -cvf dhj.jar
# hadoop -jar dhj.jar DefaultHadoopJobDriver
The above command gave me error "Failed to load Main-Class manifest attribute from dhj.jar"
rebuilt jar with manifest using below command
jar -cvfe dhj.jar DefaultHadoopJobDriver .
hadoop -jar dhj.jar DefaultHadoopJobDriver -- This returned the original error message that I reported above.
My Hadoop job has single class "DefaultHoopJobDrive" that extends Configures and implements Tool, and run method as only code for Job creation and inputpath,outpurpath set.
Aslo I.m using new API.
I'm running hadoop 1.2.1 and the Job works fine from eclipse.
This might be something to do with the classpath. Please help.
For executing that jar you don't have to give hadoop -jar. The command is like so:
hadoop jar <jar> [mainClass] args...
If this jar again gets the java.lang.ClassNotFoundException exception then can you use the:
hadoop classpath
command to see whether hadoop-core-1.2.1.jar is present in your hadoop installations classpath?
FYI, and if it's not present in this list you have to add this jar to the hadoop lib directory.
Try building your hadoop java code with all hadoop jars available in hadoop's lib folder.
In this case you are missing the hadoop util class which is present in the hadoop-core-*.jar
Classpath can be specified while building the code within the jar or you can externalise it using the following command
hadoop -cp <path_containing_hadoop_jars> -jar <jar_name>
In case anyone is using Maven and lands here: Dependency issues can be resolved by asking Maven to include any jars it requires within the parent project's jar itself. That way, Hadoop doesn't have to look elsewhere for dependencies -- it can find them right there itself. Here's how to do this:
1. Go to pom.xml
Add a section to your <project> tag, called <build>
Add the following to your <build></build> section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>junit:junit</exclude>
<exclude>jmock:jmock</exclude>
<exclude>xml-apis:xml-apis</exclude>
<exclude>org.testng:testng</exclude>
<exclude>org.mortbay.jetty:jetty</exclude>
<exclude>org.mortbay.jetty:jetty-util</exclude>
<exclude>org.mortbay.jetty:servlet-api-2.5</exclude>
<exclude>tomcat:jasper-runtime</exclude>
<exclude>tomcat:jasper-compiler</exclude>
<exclude>org.apache.hadoop:hadoop-core</exclude>
<exclude>org.apache.mahout:mahout-math</exclude>
<exclude>commons-logging:commons-logging</exclude>
<exclude>org.mortbay.jetty:jsp-api-2.1</exclude>
<exclude>org.mortbay.jetty:jsp-2.1</exclude>
<exclude>org.eclipse.jdt:core</exclude>
<exclude>ant:ant</exclude>
<exclude>org.apache.hadoop:avro</exclude>
<exclude>jline:jline</exclude>
<exclude>log4j:log4j</exclude>
<exclude>org.yaml:snakeyaml</exclude>
<exclude>javax.ws.rs:jsr311-api</exclude>
<exclude>org.slf4j:jcl-over-slf4j</exclude>
<exclude>javax.servlet:servlet-api</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/jruby.home</exclude>
<exclude>META-INF/license</exclude>
<exclude>META-INF/maven</exclude>
<exclude>META-INF/services</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Now build your project again, and run with the normal hadoop java my.jar ... command. It shouldn't cry about dependencies now. Hope this helps!

merging two war files with overlays

I have to merge two war files. I use eclipse indigo and maven 2. So I put one war as a dependency in the others pom.xml and added the overlay option as well:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<overlays>
<overlay>
<groupId>org.mydomain</groupId>
<artifactId>myproject</artifactId>
</overlay>
</overlays>
...
I use this to add all dependencies as jar's to my lib folder:
...
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<outputDirectory>${project.build.directory}/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</plugin>
...
So if I perform maven install a proper war file is build with everything in it. The problem is when I deploy this on the glassfish server (3.1) there are no classes deployed (I looked in the eclipseApps folder in my glassfish folder). The jar's are there, the folders are there but empty. So it does not work on the server.
Anyone an idea?
Update:
As proposed in the comments I put the war file in the autodeploy folder and got the following errors:
INFO: Initializing Mojarra 2.1.0 (FCS 2.1.0-b11) for context ''
INFO: Unsanitized stacktrace from failed start...
com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'bundle://237.0:1/com/sun/faces/jsf-ri-runtime.xml': null
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:675)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:322)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:364)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
Caused by: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'bundle://237.0:1/com/sun/faces/jsf-ri-runtime.xml': null
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:673)
... 19 more
Caused by: com.sun.faces.config.ConfigurationException: Unable to parse document 'bundle://237.0:1/com/sun/faces/jsf-ri-runtime.xml': null
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:923)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:868)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:659)
... 19 more
Caused by: java.lang.NullPointerException
at java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
at java.util.Arrays.asList(Arrays.java:2828)
at com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings.addRecognizedFeatures(ParserConfigurationSettings.java:115)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.<init>(DocumentBuilderImpl.java:182)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:76)
at com.sun.faces.config.ConfigManager$ParseTask.getBuilderForSchema(ConfigManager.java:1133)
at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1002)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:914)
... 23 more
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:379)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:364)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
Caused by: java.lang.NullPointerException
at java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
at java.util.Arrays.asList(Arrays.java:2828)
at com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings.addRecognizedFeatures(ParserConfigurationSettings.java:115)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.<init>(DocumentBuilderImpl.java:182)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:76)
at com.sun.faces.config.ConfigManager$ParseTask.getBuilderForSchema(ConfigManager.java:1133)
at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1002)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:914)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:868)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:659)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:322)
... 18 more
SEVERE: PWC1306: Startup of context failed due to previous errors
SEVERE: PWC1305: Exception during cleanup after start failed

Resources