Platinum Partner
java,apache,tomcat,openwebbeans,cdi

Using Apache OpenWebBeans with Apache Tomcat

This article is about how to configure Apache Tomcat 6 or 7 to use OpenWebBeans based dependency injection.

What is Apache  OpenWebBeans?

OpenWebBeans is an ASL 2.0-licensed implementation of the JSR-299, Contexts and Dependency Injection for the Java EE platform. Project's web page can be found at, "http://openwebbeans.apache.org"

 Requirements

Let's says that you have unzipped/untar OpenWebBeans into directroy /owb/ and Tomcat to /tomcat/. You have to copy some libraries to tomcat lib/ folder,

  • Copy /owb/api/geronimo-atinject_1.0_spec-1.0.jar to /tomcat/lib
  • Copy /owb/api/geronimo-jcdi_1.0_spec-1.0.jar to /tomcat/lib
  • Download geronimo-interceptor_1.1_spec-1.0.jar from  http://tiny.cc/4exgy and put into /tomcat/lib
  • Copy /owb/spi/openwebbeans-spi-1.0.0-alpha-1.jar to /tomcat/lib
  • Copy /owb/plugins/openwebbeans-tomcat6-1.0.0-alpha-1.jar to /tomcat/lib (For Tomcat 6)
  • Copy /owb/plugins/openwebbeans-tomcat7-1.0.0-alpha-1.jar to /tomcat/lib/ (For Tomcat 7)
  • Open /tomcat/conf/server.xml, add lifecycle listener as follows under "server" element
<Listener className="org.apache.webbeans.web.tomcat.ContextLifecycleListener" />

That is it! Configuration is ready to deploy your next JSR-299 Web Application to Apache Tomcat.

Sample Applications

Look at OWB SVN for Tomcat samples,

Using Maven

If you wish to use OpenWebBeans with Maven, just put the following entries to your  web application pom.xml for Tomcat 6,

    <dependencies>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_1.1_spec</artifactId>
<version>1.0</version>
</dependency>


<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<scope>provided</scope>
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-ee-common</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
<scope>provided</scope>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<scope>provided</scope>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
<version>1.0.0-alpha-1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-el10</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-resource</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

</dependencies>

 

For Tomcat 7 maven configuration,

    <dependencies>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_1.1_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-ee-common</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
<scope>provided</scope>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<scope>provided</scope>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
<version>1.0.0-alpha-1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-resource</artifactId>
<version>1.0.0-alpha-1</version>
</dependency>


</dependencies>

  That is it!

   Enjoy!

OpenWebBeans User and Development Mailing Lists

Please mail to the user mailing list about any questions or advice
about the OpenWebBeans.

User Mailing List : [users@openwebbeans.apache.org]

You can also join the discussions happening in the dev list

Dev Mailing List  : [dev@openwebbeans.apache.org]

OpenWebBeans JIRA Page
Please logs bugs into the "https://issues.apache.org/jira/browse/OWB".

OpenWebBeans Web Page
You can reach the OpenWebBeans web page at, http://openwebbeans.apache.org
 

Gurkan Erdogdu

ASF Member,http://apache.org

PMC Chair, Apache OpenWebBeans

CTO, MechSoft Mechanical and Software Solutions, http://www.mechsoft.com.tr

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}