Monday, October 29, 2007

Using Dependency Injection from Web Container in OC4J 10.1.3.x

OC4J 10.1.3.1 and later supports dependency injection from web container. I've seen this question from many customers via email or in OTN forum that using dependency injection from web container generates NPE. If you are running into such problems, make sure that you have specified version as "2.5" in your deployment descriptor (web.xml) as follows:


<?xml version = '1.0'?>?
<?web-app version="2.5" 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/web-app_2_5.xsd">?
...