1
votes

I am new to web development , I want to develop an osgi web bundle to be deployed in jboss AS7 can any one tell me what is the directory structure for that ... I googled a lot but not able to find solution my directory structure is like below

myProject --META-INF ---- manifest.mf --WEB-INF ------ web.xml index.html

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>JbossModule</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

manifest.mf

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: OsgiSample
Bundle-SymbolicName: osgiSample
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Web-ContextPath: /osgiSample
Webapp-Context: osgiSample

I am able to deploy... but getting error 404

1
Which version of JBoss AS exactly? - Harald Wellmann
I am using jboss-as-7.1.1 - Rahul Shukla
Why JBoss? JBoss AS 7 is, in my not-so-humble opinion, HUGE. In your setup, you would effectively get: Tomcat + JBoss enterprise stuff + Apache Felix + Pax Web. Why not just download Felix and Pax Web and get started with that? I am not saying that JBoss is bad. Far from it, it's excellent for enterprise development. But for building your first WAB? If you use Felix + Pax Web standalone you are pretty sure it will work in the end as that is exactly what JBoss uses also. EDIT: Just realized you will also get Jetty. So you get to run TWO webservers inside JBoss... - Stijn de Witt

1 Answers

1
votes

JBoss AS 7.1.1 does not support WABs out of the box. The following information is buried in the User Guide of JBoss OSGi 1.1.1:

To enable OSGi Web Application support in AS7 you would configure these capabilities

<capability name="org.ops4j.pax.web:pax-web-jetty-bundle:1.1.2"/>
<capability name="org.ops4j.pax.web:pax-web-jsp:1.1.2"/>
<capability name="org.ops4j.pax.web:pax-web-extender-war:1.1.2"/>

Add these lines to the osgi subsystem of standalone.xml and change activation to eager:

 <subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="eager">

Then JBoss AS will download and install the additional bundles during startup. Once these bundles are started, copy your own WAB to standalone/deployments and it should be deployed.

See also this forum post. Note that this WAB runs in a separate servlet container (Pax Web) listening on port 8090 (not 8080).

Also note that these extra capabilities seem to get downloaded again on every server restart. To avoid that, you can manually download the extra bundles (and a transitive dependency) and install them under $JBOSS_HOME/bundles:

org/ops4j/pax/web/jetty/main/pax-web-jetty-bundle-1.1.2.jar
org/ops4j/pax/web/extender/war/main/pax-web-extender-war-1.1.2.jar
org/ops4j/pax/web/jsp/main/pax-web-jsp-1.1.2.jar
org/eclipse/jdt/core/compiler/ecj/main/ecj-3.5.1.jar

And then replace the above capabilities by:

<capability name="org.ops4j.pax.web.jetty"/>
<capability name="org.eclipse.jdt.core.compiler.ecj"/>
<capability name="org.ops4j.pax.web.jsp"/>
<capability name="org.ops4j.pax.web.extender.war"/>