How can I run JFace Application Window through Activation Bundle?
I created new thread in BundleActivator start method, but I get error:
org.osgi.framework.BundleException: Could not resolve module: SomeBundle [7]
Unresolved requirement: Import-Package: org.eclipse.swt
There is my manifest file.
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SomeBundle
Bundle-SymbolicName: SomeBundle
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: mypackage.mybundle.host.Activator
Bundle-Vendor: me
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: mypackage.mybundle.host,
org.eclipse.swt,
org.osgi.framework;version="1.3.0"
Bundle-ActivationPolicy: lazy
Export-Package: mypackage.mybundle.host
Require-Bundle: org.eclipse.swt;bundle-version="3.104.1"
Thanks in advance.
You bundle imports the package org.eclipse.swt, which means you need to install a bundle into your OSGi Framework that exports that package.
The package org.eclipse.swt is exported by a bundle which is also named org.eclipse.swt so it is easy enough to find. Because SWT contains native code you also need to include the platform-specific SWT fragment for your platform, e.g. org.eclipse.swt.cocoa.macosx.x86_64.
Related
I wrote a custom event adapter and I built the jar file. I have placed the jar file in the dropins folder and restarted the CEP engine, but it appears within the event adapter.
The reference url is:
https://docs.wso2.com/display/CEP400/Building+Custom+Event+Receivers#BuildingCustomEventReceivers-ExposingCustomEventReceiverasanOSGIService
but it is not explained in the OSGI bundle.
My MANIFEST.MF is:
Manifest-Version: 1
Build-Jdk: 1.8.0_92
Built-By: wso2-builder
Bundle-Description: org.wso2.event.adaptor.test
Bundle-ManifestVersion: 2
Bundle-Name: org.wso2.event.adaptor.test
Bundle-SymbolicName: org.wso2.event.adaptor.test
Bundle-Vendor: WSO2
Bundle-Version: 5.0.10
Created-By: Apache Maven Bundle Plugin
DynamicImport-Package: *
Private-Package: org.wso2.event.adaptor.test.internal, org.wso2.event.adaptor.test.internal.*
Export-Package: !org.wso2.event.adaptor.test.internal, !org.wso2.event.adaptor.test.internal.*, org.wso2.event.adaptor.test.*,
Import-Package: org.wso2.carbon.event.input.adaptor.core, org.wso2.carbon.event.input.adaptor.core.*, !javax.xml.namespace, javax.xml.namespace; version=0.0.0, *;resolution:=optional,
Service-Component: OSGI-INF/serviceComponents.xml
Tool: Bnd-1.43.0
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?
I tried to do this tutorial : http://ntabakov.wordpress.com/2011/12/
I have a problem in step 4 of the tutorial.
I have downloaded and added in the build path org.restlet.jar
In the manifest file I have this error :
> No available bundle exports package 'org.restlet.resource'
in this line :
in this line :
Import-Package: example.restlet.hello.service, org.restlet.resource
my manifest file is :
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HelloBundleRestService
Bundle-SymbolicName: HelloBundleRestService
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: ntabakov.wordpress.com
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: example.restlet.hello.service,
org.restlet.resource
Service-Component: OSGI-INF/HelloServiceResource.xml
I think you get a jar of Restlet which is not a bundle, just a simple jar.
There is a dedicated edition called "OSGi" for that: http://restlet.com/download/current#release=stable&edition=osgi&distribution=zip
This is my first attempt to make an osgi bundle with servlet inside. Having googled I made this budnle and it was successfully started by glassfish 4. But when in browser I try to open it I get
java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet not
found by ... [299] at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
My manifest file:
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName:
tutu Bundle-Version: 1.0.0 Bundle-ClassPath: WEB-INF/classes
Web-ContextPath: /tutu Import-Package:
javax.servlet,javax.servlet.annotation, javax.servlet.http
As far as I understand osgi doesn't import these packages although I can be wrong. Please, help to fix this problem.
EDIT:
I found the mistake. Order in MANIFEST makes sense. So the final manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: tutu
Bundle-Name: tutut
Bundle-Version: 1.0.0
Import-Package: javax.servlet,javax.servlet.annotation, javax.servlet.http
Bundle-ClassPath: WEB-INF/classes
Web-ContextPath: /tutu
ADD servlet-api.jar in build path and try.
I have a bundle with the following mainfest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HelloCamera
Bundle-SymbolicName: HelloCamera
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: hellocamera.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: cameraservice, cameraserviceimpl, org.osgi.framework
Layout:
HelloCamera
-> hellocamera
-> Activator.java
And a second bundle with this manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CameraService
Bundle-SymbolicName: CameraService
Bundle-Version: 1.0.0.qualifier
Bundle-Localization: plugin
Export-Package: cameraservice, cameraserviceimpl
Import-Package: org.osgi.framework
Bundle-Activator: cameraserviceimpl.Activator
Layout:
CameraService
-> cameraservice
-> CameraService.java
-> cameraserviceimpl
-> Activator.java
-> CameraServiceImpl.java
I can run the first bundle from Eclipse and everything works fine as expected. I then exported both bundles as a CameraService.jar and HelloCamera.jar respectivly
I opened up my OSGI console, java -jar equinox.jar -console and
osgi> install file:CameraService.jar
osgi> install file:HelloCamera.jar
osgi> ss
id State Bundle
17 INSTALLED HelloCamera_1.0.0.qualifier
18 RESOLVED unknown_0.0.0 [18]
then I get
The Bundle could not be resolved. Reason: Missing Constraint: Import-Package: cameraservice; version="0.0.0"
After searching,
I found the problem was with the manifest files. When exporting the jars in my settings I said use the manifest file already in the folder.
I never looked at what the path was pointing to (assuming eclipse would set it correctly) however Eclipse hadn't changed its location so both jars were using the same Manifest file.
Lesson learned. Always check the form before blindly pressing finish.