Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using Apache OpenWebBeans with Apache Tomcat

DZone's Guide to

Using Apache OpenWebBeans with Apache Tomcat

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

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

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}