Getting 404 when hitting OSGi WAB servlet deployed on JBoss AS7 - osgi

I am very new to OSGi.I am doing a POC for my project. I am able to develop normal OSGi bundles,deploy them on JBoss AS 7 platform, consume other bundle's services etc. But when it comes to the web part I'm stuck. I wanted to create a web app bundle for my POC. I created a normal web app with just one servlet ( with url-mapping /test in web.xml). And below is my MANIFEST file
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-ClassPath: .,WEB-INF/classes/
Bundle-SymbolicName: TestWab
Export-Package: com.ctl.osgi.servlets
Web-ContextPath: /TestWab
Import-Package: org.osgi.framework,javax.servlet,javax.servlet.http
But when I hit the URL http://localhost:8080/TestWab/test its giving me a 404 error. I followed the below link when creating the app and I had followed it religiously. Most of the links for OSGi WAB follows the same process.
link : https://community.jboss.org/message/647106
Even the fully functional sample application war in the above link produces the same result for me (a 404 error!!). So I believe there is something wrong with configuration/setup rather than code. Could some one please throw some light on this?
Thanks in Advance!!

I have started a discussion thread on JBoss Community for this.
As per the replies OSGi WABs can be deployed in this way (described by David) only for JBoss AS 7.0. For other versions you need to do some other configuration tweaks.Not ready with a solution yet, just following the thread hoping I will get soon.

Related

Can Spring Boot + Gradle generate a war file compatible with Servlet 2.4?

I've been reading about using Spring Boot and Gradle to quickly build RESTful services: https://spring.io/guides/gs/rest-service/. I'd like to give it a try but I need to build a war that's compatible with servlet 2.4 (I know.. life in the 1970's).
The error I get when attempting to deploy the war generated by following the guide above to Sun App Server 8.1 is:
Unknown deployable object type specified: "Cannot determine the J2EE
component type"
The generated war has no web.xml and there may be other expected artifacts.
Configuring a spring-boot application using web.xml seems to suggest that a web.xml can be packaged with a Spring Boot application but doesn't explain how.
Is Spring Boot compatible with older servlet specs? How can Spring Boot and Gradle be used to generate a war that works on older web containers?
Thanks.
The answer to the question you linked to didn't actually go as far as saying that you could easily create a fully-leaded Boot application with Servlet 2.4. I consider that quite a hard, but probably achievable, target if you are prepared to do some legwork, and accept some compromises. You might find this stuff useful: https://github.com/scratches/spring-boot-legacy (I managed to use it to push an app to GAE). But there are some limits to what can be supported for such old technology, and we aren't officially supporting anything other than Servlet 3.0.1 right now.

deploy Apache ServiceMix 4 application into JBoss Application Server 7

I have an standalone Apache ServiceMix 4.4 application, it works nicely. Now, I want to deploy this application inside a JBoss Application Server 7. I use Maven as project and dependency management tool.
My objective is deploying the application not touching any line of code, only maven POM files. I can add new dependencies, change some versions (minor) and use different tools. I want, as a second objective, integrate all the Apache CXF DOSGi container features into JBoss AS ones seamlessly.
I think it is possible, but I found information for old releases of JBoss and ServiceMix or incomplete guides like this.
Can someone provide more information about that?
EDIT
I have found some issues in JBoss issue tracker:
Initial runtime support for Karaf based products
And some JBoss forum topics:
Migrating osgi bundles running in Karaf to JBoss 7 as OSGI container
I forgot to mention that my application is using Apache Karaf OSGi runtime.
Well Servicemix is "pre-"setup of a Container (Apache Karaf) and lot's of other Apache Projects like ActiveMq and Camel plus some ServiceMix specialties. So why would you want to deploy this setup in another Container?
If you want to do something like this, try to deploy std. Apache Camel, ActiveMQ and CXF and your own app in JBoss.

Example using Jersey (REST resource), OSGi (Apache Felix), and Maven (build and deploy)?

I seem to be really struggling here. What I want to do (in this order) is:
1) Build a RESTful resource using a Jersey application and resource w/annotations (this is not the issue).
2) Package, install, and start that bundle into the Felix OSGi container, as an HTTP service, including dependencies.
3) Package, install, and start a WAR in the OSGi container that may incorporate #2 as a dependency.
And I would like to be able to do all of this using Maven.
I cannot seem to find a working example of even the individual steps, especially involving Maven, that work let alone the combination of those steps. I have tried cobbling together various q&a from across the web with varying levels of success but not an end-to-end working example yet.
Any pointers would be appreciated...
I do not have an example for Jersey but I have a tutorial for CXF with Apache Karaf (which uses Felix). It shows how to create a Rest service and build it with maven. Using Apache Karaf you can then deploy the bundle directly from the maven repo. Moving this to Jersey probably just means to exchange the lib and use another blueprint config to initialize the rest service.
Apache Karaf also allows to deploy wars and wabs but I have not yet tested them.
Apache Stanbol does most or all of this (not sure if the war packaging is included out of the box) to implement its RESTful services.
You'll have to dig through its codebase but searching for Jax-RS annotations in there should point you to the right places.
I also am really struggling with exactly what you are attempting to do. So far, I seem to be really close but alas not quite there, here's what I've been doing:
creating a War with Maven that defines my Jersey Resource's
bundling it with maven bundle plugin ( see section Adding OSGi metadata to existing projects without changing the packaging type ). Which allows me to run the restlets in Tomcat and test.
define a target in Eclipse that includes resources from my locally defined p2 site which I create with the p2-maven-plugin plugin. In this way I can gather up any of the dependencies from the WAR project into a p2 site, which I can deploy to an Eclipse defined target
Where I am stuck is trying to register the Jersey Resource's as services, for which I've tried:
using the JAX-RS OSGI connector, for which I eventually gave up on because it uses glassfish jersey which seems to export a version 2 API of Jersey when Jersey hasn't even defined a version 2 API yet. This caused package resolution problems when I wanted to use version 1.17 of Jersey libs.
registering the Resources using a Whiteboard a la Apache Felix HTTP Service, my current approach which doesn't seem to work yet.
And, finally, if the preceding doesn't work I'll try Amdatu
Another route I might try is from the Jersey project OSGI chapter
I tried this combination and made it up and running -
1- Modularity Specification-->OSGi specification
2- OSGi implementation-->Apache Felix 4.4.0
3- OSGi Runtime-->Apache Karaf 3.0.3
4- Software Architecture Specification of REST – JAX-RS
5- JAX-RX implementation-->Apache CXF – 2.7.5
You can refer this nice tutorial - http://java.dzone.com/articles/building-cxf-rest-service-osgi
Now, I am also planning to move to Jersey from CXF as the Jersey is the light wait reference implementation of JAX-RS. Now I am planning to use Jersey with Apache Felix/Apache Karaf. You can install Jersey in Karaf and deploy your Jersey Rest Web Services as Bundle. You can refer this tutorial - https://vzurczak.wordpress.com/2014/09/30/web-applications-with-osgi-working-with-jersey/
Here's a good example on github : https://github.com/ddragosd/jax-rs-on-karaf

How to deploy and access a Jersey REST OSGi bundle into Adobe CQ?

I have an OSGi bundle (running under Felix) using Jersey and providing a RESTful resource. This all works fine and I can invoke the service through my browser and get back a JSON response.
Now, what I would like to do is deploy that same bundle into Adobe CQ and through CQ access the resource (i.e. /mycq/services/my-service) similarly.
Any pointers on how to deploy an existing OSGi bundle(s) into CQ and more specifically 'access' the Jersey REST resource in the bundle?
The Maven Sling Plugin allows you to deploy an OSGi bundle to a local or remote running instance of CQ.
Source: Deploying an OSGi Bundle
Apache Stanbol is using Jersey in an OSGi environment that's fairly similar to Apache Sling's on which CQ5 is based. Looking at how Jersey is integrated there might help.
https://issues.apache.org/jira/browse/SLING-2192 also has some experimental code that might help.
Note that Sling expects to take over the whole URI space, which is needed especially for access control, so some bridging code is probably needed.

Tomcat + OSGi : No Catalina Service found

While trying to enable Spring DM with web support on virgo-tomcat-server-3.0.2.RELEASE, I get the exception:
ERROR WebExtender-Init
org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer
No Catalina Service found, bailing out
org.springframework.osgi.service.ServiceUnavailableException:
service matching filter=[(objectClass=org.apache.catalina.Service)] unavailable
These are the bundles I added to the server:
catalina.osgi-5.5.23-SNAPSHOT.jar
catalina.start.osgi-1.0.0.jar
spring-osgi-web-1.2.1.jar
spring-osgi-web-extender-1.2.1.jar
Has anybody had this error before?
Thank you.
You don't need to add catalina jar's in the pickup directory, since Tomcat Virgo Server has support for tomcat by default. You have to add catalina jar files to run Tomcat on Equinox OSGI server.
Spring dynamic modules has become a Eclipse Gemini Blueprint project in late 2009. All new development (including for 2.x) is now hosted and released through the Eclipse foundation
Eclipse Gemini Blueprint can be considered Spring DM 2.x, the successor of Spring DM 1.x.
Tomcat Virgo Server has all the Blueprint Services(Spring DM) jar files inbuilt. You can refer here on how to use Spring MVC with Gemini Blueprint Services.
The same issue is discussed in this forum.

Resources