OSGi bundle's Activator class not found - java

I have an OSGi bundle, which has an activator class. I embedded Equinox in my webapp, and installed my bundle in it. The installation goes well, but when I try to start the bundle, the following error comes:
org.osgi.framework.BundleException: The activator com.rr.fr.base.barcode.activator.Activator for bundle fr-base-barcode is invalid
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:171)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:291)
at com.rr.fr.base.osgi.BundleStarter.launch(BundleStarter.java:43)
at com.rr.fr.base.osgi.OsgiInitServletContextListener.contextInitialized(OsgiInitServletContextListener.java:41)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.rr.fr.base.barcode.activator.Activator
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:345)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:164)
... 21 more
I can see that my activator class was not found. I searched for a solution and find some interesting thing here in SO, but none of them helped me.
Here is my manifest:
Manifest-Version: 1.0
Bnd-LastModified: 1431100911346
Build-Jdk: 1.6.0_45
Bundle-Activator: com.rr.fr.base.barcode.activator.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: fr-base-barcode;singleton:=true
Bundle-Version: 0.1.2.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Import-Package: com.rr.fr.base.barcode.qrcode.interfaces,com.rr.fr.base.
exception,com.rr.fr.base.messages,com.rr.fr.base.system,com.rr.fr.base.
types,com.rr.fr.interfaces,com.rr.fr.interfaces.eb.rms,com.rr.fr.ui.htt
p,hu.posta.rsaqrgen,javax.servlet,javax.servlet.http,org.apache.avalon.
framework.configuration,org.apache.commons.logging,or
g.krysalis.barcode4j,org.krysalis.barcode4j.output,org.krysalis.barcode
4j.output.bitmap,org.krysalis.barcode4j.output.eps,org.osgi.framework,org.osgi.service.http,org.osgi.util.
tracker
I can include my Activator, but I don't think it would help since it isn't even found so I don't think its source has anything to do with the error.
My bundle's library structure inside the JAR is the following:
META-INF
/MANIFEST.MF
target
/classes
/com
/rr
/fr
/base
/barcode
...
fr-base-barcode.jar
plugin.xml
I create my bundle with Eclipse PDE: Export.../Deployable Plug-ins and fragments
My build.properties includes the META-INF and target libraries, a JAR and plugin.xml as it can be seen in the bundle structure.
Any help would be appreciated.

I'm going to restate bkail's suggestion as the answer. When your packages are included in the "target/classes" folder, they are essentially in that package:
target.classes.com.rr.fr.base.barcode.*
The root of your package structure (com) should be a peer of META-INF and/or OSGI-INF, etc.

From : https://netbeans.org/kb/docs/javaee/maven-osgiservice-cdi.html#Exercise_3
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Bundle-ClassPath>WEB-INF/classes/</Bundle-ClassPath>
</manifestEntries>
</archive>
</configuration>
</plugin>

Related

java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook

I was getting this exception but I am not able to understand what is happening there.
Because on compilation time my class able access apache POI classes but on runtime my classes throws exception that he is not able find
org.apache.poi.xssf.usermodel.XSSFWorkbook.
Till now whatever solution is provided on net I have tried everything but not understanding what I am missing.
And weird thing is same code and same Apache POI library working on my friend's eclipse. We both have identical projects. Don't understand what is going on there.
I checked all folder's access where I am referring libraries.
Please share if you have any suggestion.
I am getting the following exception.
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
at com.herzog.pmide.mergedconfigxml.ui.editors.DocumentGenerator.prepareScadaIOListExcel(DocumentGenerator.java:94)
at com.herzog.pmide.mergedconfigxml.ui.editors.DocumentGenerator.scadaIOList(DocumentGenerator.java:77)
at com.herzog.pmide.mergedconfigxml.ui.actions.DocumentGeneratorAction.run(DocumentGeneratorAction.java:47)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:331)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:331)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at com.herzog.pmide.application.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbook cannot be found by com.herzog.pmide.mergedconfigxml.ui_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
MANIFEST.MF as follow
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: com.herzog.pmide.mergedconfigxml.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.herzog.pmide.mergedconfigxml.ui.Activator
Bundle-Vendor: Example
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.edit.ui,
com.herzog.pmide.machinelib.model.edit,
org.eclipse.ui.forms,
org.eclipse.ui.workbench,
org.eclipse.ui.ide,
com.herzog.pmide.mergedconfigxml.model.edit,
org.eclipse.gef,
com.herzog.pmide.tools.importutility,
com.herzog.pmide.machinelib.model,
org.eclipse.swt,
org.eclipse.emf.query,
com.herzog.pmide.mergedconfigxml.model,
org.eclipse.ui.editors,
org.eclipse.emf.validation,
org.eclipse.emf.validation.ui,
org.slf4j.api,
org.junit,
org.eclipse.emf.compare,
org.eclipse.emf.compare.edit,
org.eclipse.emf.compare.ide.ui,
org.eclipse.compare,
org.apache.commons.io,
org.eclipse.core.filesystem,
de.vonloesch.pdf4Eclipse,
de.vonloesch.pdf4eclipse.help,
com.herzog.pmide.routingline.model
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Export-Package: com.herzog.pmide.mergedconfigxml.ui,
com.herzog.pmide.mergedconfigxml.ui.editors.unitconfig,
com.herzog.pmide.mergedconfigxml.ui.views
Bundle-Localization: OSGI-INF/l10n/message
build.properties as follow
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/,\
OSGI-INF/l10n/message.properties
A plugin can only access classes in other plugins or in jars included in the plugin which are included in the bundle class path. Setting the Java Build Path properties does not configure the plugin correctly.
Add all the jars you need to the plugin, usually these are put in a 'lib' directory.
Update the build.properties to include these jars in the 'bin.includes' section. For example:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
plugin.xml,\
lib/,\
lib/jogg-0.0.7.jar,\
lib/jorbis-0.0.15.jar,\
lib/vorbisspi1.0.2.jar
Here I have 3 jars in a lib directory (these are not the POI jars, this is just an example from one of my projects).
Update the MANIFEST.MF and set the Bundle-Classpath to include the jars. You can do this in the MANIFEST.MF editor in the 'Runtime' tab in the 'Classpath' section (use the Add... button to the right of the list and choose the libraries in the plugin). Be sure to leave the entry for '.'. Your MANIFEST.MF should end up containing a `Bundle-Classpath' entry like this:
Bundle-ClassPath: .,
lib/jogg-0.0.7.jar,
lib/jorbis-0.0.15.jar,
lib/vorbisspi1.0.2.jar

org.springframework.web.context.ContextLoaderListener classnotfoundexception

I get the below error when I run my Spring project..I followed multiple SO links and implemented everything but still I have the same problem.
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
I have attached my project Maven depedencies, deployment assembly and wtpwebapps lib folder to show all the dependencies..
Not sure what else Im missing.
Stack
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4153)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
You should have this in your pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
Also you can try:
Right click on your project
"Propeties"
Deployment Assembly
Add
Java Build Path Entries
Maven Dependencies (Selected them all)
Finish
Your project setup shows there is jar file missing or your are pointing to missing jar file in your project build path.
Right click on your project ==> Go to Build Path ==> In Libraries tab..
You can see the jar files missed with red color cross mark delete them (if you need them add those missing jars in your path)
And re-build the project.

NoClassDefFoundError in OSGi bundle on accessing standard java classes

I' m trying to access an OSGI Bundle from my main application. But if a class in the bundle is accessed that uses javax.xml.* package. A NoClassDefFoundError is thrown.
java.lang.NoClassDefFoundError: javax/xml/transform/Source
at de.foo.bar.test.Builder.<init>(Builder.java:46) ~[test-bundle-1.4.0.jar:1.4.0]
at de.foo.bar.test.request.Factory.createRequest(Factory.java:99) ~[?:?]
at de.foo.bar.test.request.Request.prepareRequest(Request.java:93) ~[?:?]
at de.foo.bar.test.request.Request.process(Request.java:60) ~[?:?]
at de.foo.bar.test.TestClass.execute(TestClass.java:74) ~[?:?]
at de.foo.bar.test.TestClass.execute(TestClass.java:1) ~[?:?]
at de.foo.bar.service.system.OsgiTransactionHandler.handleTransaction(OsgiTransactionHandler.java:71) ~[bin/:?]
at de.foo.bar.service.system.TransactionRequestService.processTransaction(TransactionRequestService.java:110) ~[bin/:?]
at de.foo.bar.service.system.TransactionRequestService.runService(TransactionRequestService.java:72) ~[bin/:?]
at de.foo.bar.service.model.InfiniteService.run(InfiniteService.java:57) ~[bin/:?]
at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:60) [guava-16.0.1.jar:?]
at com.google.common.util.concurrent.Callables$3.run(Callables.java:93) [guava-16.0.1.jar:?]
at java.lang.Thread.run(Thread.java:662) [?:1.6.0_43]
Caused by: java.lang.ClassNotFoundException: javax.xml.transform.Source not found by test-bundle [1]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) ~[org.apache.felix.framework-4.2.1.jar:?]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) ~[org.apache.felix.framework-4.2.1.jar:?]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) ~[org.apache.felix.framework-4.2.1.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ~[?:1.6.0_43]
... 13 more
I've checked the imported packages in the MANIFEST.MF and can see, that the package javax.xml.transform is stated (I've shortend it a bit):
Import-Package: com.fasterxml.jackson.core;resolution:=optional,com.fast
...
500;resolution:=optional,javax.servlet;resolution:=optional,javax.sql;r
esolution:=optional,javax.swing;resolution:=optional,javax.xml.bind;res
olution:=optional,javax.xml.bind.annotation;resolution:=optional,javax.
xml.bind.annotation.adapters;resolution:=optional,javax.xml.parsers;res
olution:=optional,javax.xml.transform;resolution:=optional,javax.xml.tr
ansform.stream;resolution:=optional,javax.xml.validation;resolution:=op
tional,org.bson;resolution:=optional,org.lightcouch;resolution:=optiona
l,org.osgi.framework;resolution:=optional;version="[1.5,2)",org.osgi.fr
amework.wiring;resolution:=optional,org.w3c.dom;resolution:=optional,or
g.xml.sax;resolution:=optional,sun.misc;resolution:=optional
I'm using apache felix in version 4.2.1 as an embedded framework and the maven-bundle-plugin is configured as follows:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>Test Bundle</Bundle-Name>
<Bundle-Activator>de.foo.bar.test.activator.TestActivator</Bundle-Activator>
<Service-Component>OSGI-INF/component.xml</Service-Component>
<Export-Package>de.foo.bar.test</Export-Package>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Dependency>*;scope=compile|runtime;inline=false;artifactId=!org.osgi.core</Embed-Dependency>
<_failok>true</_failok>
<_nouses>true</_nouses>
<_nodefaultversion>true</_nodefaultversion>
<_snapshot>${osgi-version-qualifier}</_snapshot>
</instructions>
</configuration>
</plugin>
I tried to export the missing packages by using FRAMEWORK_SYSTEMPACKAGES_EXTRA property. But that seems to result in exporting all Java packages. I've stopped it on the 7th package.
Is there a way to provide these java standard packages without exporting them explicitly?
The cause of this problem was located in the framework configuration. Based on an online tutorial I had added following parameter to my config:
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.5.0");
This caused that the default system packages have been replaced and only org.osgi.framework has been available besides the extra packages I exported.
After I'd removed this line the default packages where available again and so javax.xml.transform.

java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub

I've added a Web Service using Axis2 to my project and now I can't run my application.
This is the classpath I am using:
<property name="classpath" location="bin:EventReservationCore/bin:EventReservationCore/db:EventReservationCore/lib/*:EventReservationCore/lib/util_iso2.jar:EventReservationCore/lib/sqlitejdbc-v056.jar:AuthorizationRMI/lib/AuthorizationService.jar:EventReservationCore/lib/activemq-all-5.4.3.jar:/home/ander/axis2-1.6.1/webapp/axis2.war"/>
And this is the target that runs until I add the Axis2 Web Service.
<target name="run.besocial">
<java classname="eventReservationServer.ReservationEventServer" classpath="${classpath}" fork="true">
<jvmarg value="-Djava.rmi.server.codebase=file:EventReservationCore/bin/ file:EventReservationCore/lib/util_iso2.jar"/>
<jvmarg value="-Djava.security.policy=EventReservationCore/java.policy" />
</java>
</target>
As a result I get this error:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub
[java] at java.lang.ClassLoader.defineClass1(Native Method)
[java] at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
[java] at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
[java] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
[java] at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
[java] at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[java] at eventReservationServer.eventServerGateway.WSEventServerGateway.getEvents(WSEventServerGateway.java:19)
[java] at eventReservationServer.ReservationEventServer.<init>(ReservationEventServer.java:101)
[java] at eventReservationServer.ReservationEventServer.main(ReservationEventServer.java:130)
[java] Caused by: java.lang.ClassNotFoundException: org.apache.axis2.client.Stub
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[java] ... 15 more
If you are using tomcat, copy all the jar files located under axis2/lib folder to the tomcat/lib folder and also add them to the classpath like this D:\axis2-1.6.2\lib*
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub
Above error can be removed by adding axis2-kernel-1.6.2 to the class path, but you might start getting other errors after you have generated the stubs with wsdl2java.bat.
So you better add all the axis2-jars to classpath while compiling the client.
Hope this helps
None of the answers helped me. Here is then what I did.
I used eclipse to generate Runnable Jar(right click->Export->Runnable Jar) with all the libraries added as package.
It gave me a JAR that I could run from command line.
Then I did diff between Jar from eclipse and Jar that my build created. I was able to find the missing dependencies that my build was not putting in Jar.
If you faced the same issue for JBoss class loader, follow the tips on here and here.
The most important part is to define a new module in JBoss module configurations, and also locate the module in you MANIFEST.MF file.
Maven will help you to do the later part. Following is a sample configuration to add axis module to your Manifest file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<archive>
<manifestEntries> <!--Manually added JBoss Modules (that are not found by JBoss class loader) must be loaded here-->
<Dependencies>axis.axis</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
Depending to your packaging type, you would use other maven plugins like maven-jar-plugin or maven-war-plugin.
The dependency package name must match the name that you have specified to your module name in JBoss modules. The above axis module is defined in JBoss models as explained in the links above.
<module xmlns="urn:jboss:module:1.1" name="axis.axis">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<!-- ... -->
</module>

executing jar file: Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext

I have created a maven project. After I type: mvn clean package everything works fine and I see my jar file inside target. But if I click the file I get the follwing error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/c
ontext/ApplicationContext
Caused by: java.lang.ClassNotFoundException: org.springframework.context.Applica
tionContext
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: comt.test.Test. Program will exit
I can run the project under Eclipse and works ok, but the jar file doesnt work.
This is the content of Manifest:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.6.0_23
Main-Class: com.stlpo.App
Class-Path: commons-httpclient-3.1.jar commons-codec-1.2.jar h2-1.2.138.jar
commons-lang-2.5.jar spring-core-3.0.3.RELEASE.jar spring-asm-3.0.3.RELEASE.jar co
mmons-logging-1.1.1.jar spring-context-3.0.3.RELEASE.jar spring-beans
-3.0.3.RELEASE.jar spring-expression-3.0.3.RELEASE.jar spring-orm-3.0
.3.RELEASE.jar spring-tx-3.0.3.RELEASE.jar spring-aop-3.0.3.RELEASE.j
ar aopalliance-1.0.jar spring-jdbc-3.0.3.RELEASE.jar spring-test-3.0.
3.RELEASE.jar cglib-nodep-2.2.jar logback-core-0.9.24.jar logback-cla
ssic-0.9.24.jar slf4j-api-1.6.0.jar hibernate-annotations-3.5.4-Final
.jar hibernate-core-3.5.4-Final.jar antlr-2.7.6.jar commons-collectio
ns-3.1.jar jta-1.1.jar hibernate-commons-annotations-3.2.0.Final.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar hibernate-entitymanager-3.5.4-F
inal.jar cglib-2.2.jar asm-3.1.jar javassist-3.9.0.GA.jar opencsv-2.1
.jar jfreechart-1.0.13.jar jcommon-1.0.16.jar commons-beanutils-1.8.3
.jar beansbinding-1.2.1.jar poi-3.6.jar log4j-1.2.13.jar
poi-ooxml-3.6.jar poi-ooxml-schemas-3.6.jar xmlbeans-2.3.0.jar stax-
api-1.0.1.jar geronimo-stax-api_1.0_spec-1.0.jar dom4j-1.6.1.jar xml-
apis-1.0.b2.jar commons-dbcp-1.4.jar commons-pool-1.5.4.jar TableLayo
ut-20050920.jar
Thanks in advance for your help.
When you build a JAR, it only has your classes in it. It doesn't contain all the other libraries that your project depends on. (Doing that is possible, but it's not common and mostly inadvisable.) To run a class in your JAR that depends on Spring, you have to be sure Spring is on the classpath, either by passing a classpath to the java executable (doesn't work if using the -jar argument) or by putting a "Class-Path" attribute in the JAR's manifest file. Of course, it's not just Spring. You'll have to include a classpath entry for every jar your project depends on.
see another post regarding the same problem
you need to create a classPath (the eclipse is dong it automatically for you, and this is why you have no problem ruining the project from the eclipse) for the dependencies (in your case the spring)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
<addClasspath>true</addClasspath>
<!-- use class path prefix if your dependencies are out side the jar)
<classpathPrefix>lib/</classpathPrefix> -->
</manifest>
<manifestEntries>
<Class-Path>conf/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>

Categories

Resources