Rahul Shukla
Rahul Shukla

Reputation: 505

Simple OSGI web application for jboss AS7

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

Upvotes: 1

Views: 441

Answers (1)

Harald Wellmann
Harald Wellmann

Reputation: 12855

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"/>

Upvotes: 1

Related Questions