OSGI bundle for GF4 javax.servlet.http.HttpServlet - ClassNotFound - java

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.

Related

How to include org.json.jar and org.json.* imports at a MANIFEST.MF file

How can i properly include org.json.jar and org.json.* imports at a MANIFEST.MF file?
I'm using JDeveloper IDE
My PhillPlugin.class java file imports the following:
org.json.JSONObject
org.json.JSONException
I have also imported the org.json.jar file in my Libraries
I'm combining all these to a final .jar file
This is my MANIFEST.MF file
Manifest-Version: 1.0
Bundle-Version: 10
Bundle-Name: PhillPlugin
Bundle-Activator: phillplugin.PhillPlugin
Bundle-ManifestVersion: 2
Import-Package: org.osgi.framework;version="1.3.0",oracle.security.am.plugin,oracle.security.am.plugin.authn,oracle.security.am.plugin.impl,oracle.security.am.plugin.api,oracle.security.am.common.utilities.principal,oracle.security.idm,javax.security.auth
Bundle-SymbolicName: PhillPlugin
Class-Path: felix.jar, identitystore.jar, oam-plugin.jar, utilities.jar, org.json.jar
I have included org.json.jar at Class-Path entry
How do i include the imports at Import-Package entry?
org.json should be imported in Import-Package.
Like so org.json;resolution:= optional,org.json.JSONObject;resolution:=optional
Here is my manifest:
Manifest-Version: 1.0
Bundle-SymbolicName: PhillPlugin
Bundle-Version: 10
Bundle-Name: PhillPlugin
Bundle-Activator: phillplugin.PhillPlugin
Bundle-ManifestVersion: 2
Import-Package: org.osgi.framework;version="1.3.0",oracle.security.am.
plugin,oracle.security.am.plugin.authn,oracle.security.am.plugin.impl
,oracle.security.am.plugin.api,oracle.security.am.common.utilities.pr
incipal,oracle.security.idm,javax.security.auth,org.json;resolution:=
optional,org.json.JSONObject;resolution:=optional

how to Building Custom Event Receivers in WSO2 CEP 4.1.0

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

Equinox with SWT/Jface

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.

No available bundle exports package 'org.restlet.resource'

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

Running OSGI bundle from OSGI command prompt :Import-package missing constraint

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.

Categories

Resources