Tutorial covering JSP 2.2 and Servlets 3.0 with OpenSource Resin Servlet Container: Part 1
Setting up CDI
To setup CDI, you need to create a beans.xml file and put it in META-INF. META-INF is a special directory for jar files and Java classpath entries. It contains meta information. The beans.xml can be completely blank, i.e., you could create it like this:
$ pwd ~/workspace/javaee-tutorial/notes/src/META-INF $ touch beans.xml
To get Eclipse to quit complaining about the blank file not having the right format, I went ahead and created boiler plate beans.xml file as follows:CDI META-INF/beans.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> </beans>
Note: the @Inject Java dependency injection will not work without this file.
Bill Digman is a Java EE / Servlet enthusiast and Open Source enthusiast who loves working with Caucho's Resin Servlet Container, a Java EE Web Profile Servlet Container.
Caucho's Resin OpenSource Servlet Container
Java EE Web Profile Servlet Container
|Tutorial covering JSP 2.2 and Servlets 3.0 with OpenSource Resin Servlet Container - Part 1.pdf||849.79 KB|
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)