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

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

Related

Can't start RCP application due to OSGi bundle dependency issue

We are using both spring-web and spring-websocket in our RCP application, which are both converted into bundles through the p2-maven-plugin. Below is the MANIFEST.MF file of our application.
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Todo
Bundle-SymbolicName: com.example.e4.rcp.todo;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EXAMPLE
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.apache.commons.logging;bundle-version="1.2.0",
org.springframework.spring-aop;bundle-version="4.3.3",
org.springframework.spring-beans;bundle-version="4.3.3",
org.springframework.spring-context;bundle-version="4.3.3",
org.springframework.spring-core;bundle-version="4.3.3",
org.springframework.spring-expression;bundle-version="4.3.3",
org.springframework.spring-web;bundle-version="4.3.3",
org.eclipse.e4.ui.css.swt;bundle-version="0.12.0",
org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0",
org.eclipse.e4.ui.workbench.addons.swt;bundle-version="1.2.0",
org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.13.0",
org.eclipse.e4.ui.workbench.swt;bundle-version="0.13.0",
org.eclipse.swt;bundle-version="3.104.1",
org.eclipse.e4.ui.di;bundle-version="1.1.0",
org.eclipse.e4.core.services;bundle-version="2.0.100",
org.eclipse.osgi.services;bundle-version="3.5.100",
org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
org.springframework.spring-websocket;bundle-version="4.3.2",
org.springframework.spring-messaging;bundle-version="4.3.2",
javax.inject;bundle-version="1.0.0",
javax.annotation;bundle-version="1.2.0",
org.apache.tomcat.embed.tomcat-embed-core;bundle-version="8.5.4",
org.apache.tomcat.embed.tomcat-embed-websocket;bundle-version="8.5.4"
When I start the application, it popups the following error:
!SESSION 2016-11-10 09:48:03.750 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_101
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product com.example.e4.rcp.todo.product clearPersistedState
Command-line arguments: -product com.example.e4.rcp.todo.product -data > :\Users\wangzen\Console_prototype/../runtime-todo.product -dev > ile:C:/Users/wangzen/Console_prototype/.metadata/.plugins/org.eclipse.pde.core/to> o.product/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog > clearPersistedState
!ENTRY org.eclipse.equinox.app 0 0 2016-11-10 09:48:04.703
!MESSAGE Product com.example.e4.rcp.todo.product could not be found.
!ENTRY com.example.e4.rcp.todo 2 0 2016-11-10 09:48:04.786
!MESSAGE Could not resolve module: com.example.e4.rcp.todo [491]
Bundle was not resolved because of a uses contraint violation.
org.osgi.service.resolver.ResolutionException: Uses constraint violation. nable> to resolve resource com.example.e4.rcp.todo [osgi.identity;> sgi.identity="com.example.e4.rcp.todo"; type="osgi.bundle";> ersion:Version="1.0.0.qualifier"; singleton:="true"] because it is exposed to> ackage 'javax.servlet' from resources rg.apache.tomcat.embed.tomcat-embed-core> [osgi.identity; type="osgi.bundle"; ersion:Version="8.5.4";> sgi.identity="org.apache.tomcat.embed.tomcat-embed-core"] and javax.servlet> osgi.identity; type="osgi.bundle"; version:Version="3.1.0.v201410161800";> sgi.identity="javax.servlet"] via two dependency chains.
Chain 1:
com.example.e4.rcp.todo [osgi.identity; sgi.identity="com.example.e4.rcp.todo";> type="osgi.bundle"; ersion:Version="1.0.0.qualifier"; singleton:="true"]
require:> &(osgi.wiring.bundle=org.apache.tomcat.embed.tomcat-embed-core)(bundle-versio> >=8.5.4))
|
provide: osgi.wiring.bundle: org.apache.tomcat.embed.tomcat-embed-core
org.apache.tomcat.embed.tomcat-embed-core [osgi.identity; ype="osgi.bundle";> version:Version="8.5.4";> sgi.identity="org.apache.tomcat.embed.tomcat-embed-core"]
Chain 2:
com.example.e4.rcp.todo [osgi.identity; sgi.identity="com.example.e4.rcp.todo";> type="osgi.bundle"; ersion:Version="1.0.0.qualifier"; singleton:="true"]
require:> &(osgi.wiring.bundle=org.springframework.spring-web)(bundle-version>=4.3.3))
|
provide: osgi.wiring.bundle; bundle-version:Version="4.3.3.RELEASE";> sgi.wiring.bundle="org.springframework.spring-web"
org.springframework.spring-web [osgi.identity; type="osgi.bundle";> ersion:Version="4.3.3.RELEASE"; osgi.identity="org.springframework.spring-web"]
import: (osgi.wiring.package=javax.servlet)
|
export: osgi.wiring.package: javax.servlet
javax.servlet [osgi.identity; type="osgi.bundle";> ersion:Version="3.1.0.v201410161800"; osgi.identity="javax.servlet"]
!ENTRY org.eclipse.osgi 4 0 2016-11-10 09:48:04.787
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: No application id has been found.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:242)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
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:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
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:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
gogo: InterruptedException: sleep interrupted
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:72)
at java.lang.Thread.run(Thread.java:745)
An error has occurred. See the log file
C:\Users\wangzen\runtime-todo.product\.metadata\.log.
It seems the problem is caused by both org.apache.tomcat.embed.tomcat-embed-core and org.springframework.spring-web have dependency chain to javax.servlet. However after I removed the tomcat libraries, it tells me another error as below:
java.lang.NoClassDefFoundError: org/apache/tomcat/InstanceManagerBindings
at org.apache.tomcat.websocket.WsSession.<init>(WsSession.java:187)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:403)
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:150)
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:147)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.InstanceManagerBindings cannot be found by org.apache.tomcat.embed.tomcat-embed-websocket_8.5.4
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:448)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
UPDATE
What I've tried:
By checking the dependencies from Plug-in Dependencies tool offered by Eclipse, which shows as following screenshot, I found that org.apache.tomcat.embed.tomcat-embed-core and org.apache.tomcat.embed.tomcat-embed-websocket might not be necessary for my application, so I removed these two bundles and restart my application.
However there comes another error message as below:
java.lang.NoClassDefFoundError: org/apache/tomcat/InstanceManagerBindings
at org.apache.tomcat.websocket.WsSession.<init>(WsSession.java:187)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:403)
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:150)
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:147)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.InstanceManagerBindings cannot be found by org.apache.tomcat.embed.tomcat-embed-websocket_8.5.4
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:448)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
Also I tried replacing Require-Bundle with Import-Package when importing these third party libraries as following:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Todo
Bundle-SymbolicName: com.example.e4.rcp.todo;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EXAMPLE
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.e4.ui.css.swt;bundle-version="0.12.0",
org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0",
org.eclipse.e4.ui.workbench.addons.swt;bundle-version="1.2.0",
org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.13.0",
org.eclipse.e4.ui.workbench.swt;bundle-version="0.13.0",
org.eclipse.swt;bundle-version="3.104.1",
org.eclipse.e4.ui.di;bundle-version="1.1.0",
org.eclipse.e4.core.services;bundle-version="2.0.100",
org.eclipse.osgi.services;bundle-version="3.5.100",
org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
javax.inject;bundle-version="1.0.0",
javax.annotation;bundle-version="1.2.0"
Import-Package: org.apache.tomcat,
org.springframework.http,
org.springframework.http.client,
org.springframework.http.client.support,
org.springframework.messaging.converter,
org.springframework.messaging.simp.stomp,
org.springframework.scheduling,
org.springframework.scheduling.concurrent,
org.springframework.util,
org.springframework.web.client,
org.springframework.web.socket.client,
org.springframework.web.socket.client.standard,
org.springframework.web.socket.messaging,
org.springframework.web.socket.sockjs.client
However it still popup the same error notify me that org.apache.tomcat.InstanceManagerBindings cannot be found by org.apache.tomcat.embed.tomcat-embed-websocket_8.5.4
You are facing several problems here. The first one is that you use require bundle all over the place. The problem with require bundle is that you are always exposed to all packages a bundle offers. This will increase the probability of uses chain contraint violations. You should try to use Import-Package instead.
The other problem is that spring does not support OSGi anymore. So using spring libraries in OSGi is very likely to create problems as they simply do not test their code in OSGi.
If you need websocket support then a better choice might be pax web. It runs with tomcat or jetty and wraps them in an OSGi compatbile way.
Unfortunately there is no example for pax-web or plain jetty in eclipse. To see what bundles you need you can start apache karaf and install the http feature. Then you can look into the bundles it installs and use the same in eclipse rcp.
Add a version info to your javax.servlet import package so OSGi can decide wich dependency chain to use.
javax.servlet;version="3.1.0"

Eclipse RCP: Bundle-NativeCode in plugin fragment

Following this question.
I'm using Bundle-NativeCode header to specify native libraries that should be loaded by plugin.
It works fine when the libraries reside in the same plugin as the code that loads them (System.loadLibrary). However, when I try to put the libraries in a separate plugin fragment, System.loadLibrary fails with UnsatisfiedLinkError.
The manifest of the host plugin (when the libraries in the host plugin):
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Jni
Bundle-SymbolicName: com.ebar.workmode.jni
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.ebar.workmode.jni.Activator
Bundle-Vendor: EBAR
Require-Bundle: org.eclipse.core.runtime,
org.slf4j.api,
javax.inject;bundle-version="1.0.0",
com.ebar.workmode.contracts;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: com.ebar.workmode.jni
Eclipse-ExtensibleAPI: true
Bundle-NativeCode: native/ipcs.dll ; native/ipcs_tcpip_plugin.dll ; osname=win32
The manifest of the plugin fragment:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: workmode JNI win x86
Bundle-SymbolicName: com.ebar.workmode.jni.windows.x32;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EBAR
Fragment-Host: com.ebar.workmode.jni;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-NativeCode: native/ipcs_tcpip_plugin.dll ; native/ipcs.dll ; osname=win32
Activator.start of the host plugin:
#Override
public void start(BundleContext bundleContext) throws Exception {
System.loadLibrary("ipcs");
System.loadLibrary("ipcs_tcpip_plugin");
}
The error that I get when I remove the Bundle-NativeCode header from the host plugin:
java.lang.UnsatisfiedLinkError: no ipcs in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.ebar.workmode.jni.Activator.start(Activator.java:34)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)
... 102 more
The plugin fragment is added to the product
The plugin fragment doesn't show any error in target platform state tab
The native folder of plugin fragment is included in binary build (in build.properties)
Why isn't it working and how to make the host plugin to load the native libraries from the plugin fragment? Or alternatively, is there a way to make the plugin fragment to load its libraries?

OSGi bundle's Activator class not found

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>

Can't Export runnable jar from eclipse

i'm trying to export a runnable jar from eclipse, but this is the result:
Exception in thread "main" java.lang.NoClassDefFoundError: neg1
Caused by: java.lang.ClassNotFoundException: neg1
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)
This is the manifest:
Manifest-Version: 1.0
Rsrc-Class-Path: ./ itextpdf-5.4.3.jar itext-pdfa-5.4.3.jar itext-xtra
-5.4.3.jar
Class-Path: .
Rsrc-Main-Class: Negozio.Start
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
And this is how the files are packed into the jar:
http://i.stack.imgur.com/uXEaQ.png
Where Operazioni and Negozio are the my packages and the itext are the external library
Did you forget to include an external jar file?
You must have external jars that you did not include when you exported or were not put in your class path. Right click on your project Properties->Java Build Path and then ensure the "Libraries" tab is selected. Ensure the jars are added here.

Eclipse Plugin Dev: Unable to resolve dependencies

Based on this simple tutorial, I am trying to display pop-ups notifications, as part of the org.eclipse.mylyn.commons.ui dependency. So I have added this dependency to my plugin.xml as such:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Roll and Scroll Recorder
Bundle-SymbolicName: ATF_Recorder_Plugin;singleton:=true
Bundle-Version: 0.0.502
Bundle-Activator: com.jcraft.eclipse.jcterm.JCTermPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.jcraft.jsch;bundle-version="0.1.31",
org.eclipse.core.resources;bundle-version="3.7.101",
org.eclipse.jsch.core;bundle-version="1.1.300",
com.jcraft.eclipse.jsch.core,
org.eclipse.mylyn.commons.ui;bundle-version="3.6.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: OSEHRA
Additionally I clicked compute dependencies within my Feature project and now have this updated into my feature.xml file:
<requires>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="com.jcraft.jsch" version="0.1.31" match="greaterOrEqual"/>
<import plugin="org.eclipse.core.resources" version="3.7.101" match="greaterOrEqual"/>
<import plugin="org.eclipse.jsch.core" version="1.1.300" match="greaterOrEqual"/>
<import plugin="com.jcraft.eclipse.jsch.core"/>
<import plugin="org.eclipse.mylyn.commons.ui" version="3.6.1" match="greaterOrEqual"/>
</requires>
However when I installed my custom plugin, and go to show it's view, the dependency is never being resolved:
java.lang.ClassNotFoundException: org.eclipse.mylyn.internal.provisional.commons.ui.AbstractNotificationPopup
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(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:626)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:601)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:562)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:486)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:459)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:476)
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(Unknown Source)
at com.jcraft.eclipse.jcterm.JCTermView.createPartControl(JCTermView.java:189)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:229)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2245)
...
And the lesson from this question is
Don't ever use non-API classes, unless you don't care if your plug-in breaks in future versions.
I guess you have to build your plug-in twice, if you absolutely need backward compatibility.
But, since
you are targeting Indigo (3.7)
the bug, in the context of which the provisional packages became API, is Bug 360301
this bug fix was included in Mylyn 3.7
you are probably best of requiring org.eclipse.mylyn.commons.ui, version 3.7 and later.
Since you are using Eclipse 3.6 for development, you will have to set up a target platform including a 3.7 installation.
Are you sure you're running the plugin against the same version of mylyn that you built against? In newer versions of mylyn (3.8.0 for example) that class has been moved to package org.eclipse.mylyn.commons.ui.dialog.
Issue: Even though the "same" Indigo SR 2 version of Eclipse is being used, they are not equal. Some of them have 3.6 version of org.eclipse.mylyn.commons.ui other have 3.8 (which is supposed to be in Juno only...).

Categories

Resources