Thursday, December 29, 2011

ADF Faces on Weblogic 12c

Weblogic 12c is released a few weeks ago and now we have a robust, scalable Java EE6 implementation. The ADF seems to be slightly behind because a certified version of ADF Runtime is not yet available for weblogic 12c. You could try to install an older ADF runtime on 12c and I for sure ran into problems.

All I needed out of the ADF Runtime was the ADF Faces technology, so I thought to create a deployment-library of only needed jars that won't break ADF in general and then reference them from my webapp. That way, I could explore CDI and other cool features of Java EE6 bundled in Weblogic 12c, while continuing to use the ADF(faces). Now whenever the ADF Runtime is available, I can simply remove this custom ADF deployment-library from weblogic and update the needed library references in my webapp.

Here is what I did to create this temporal ADF deployment-library:

1. Created a maven web-archive project
$ mvn archetype:generate -DgroupId=com.test.adflib  -DartifactId=My-ADFLib -DarchetypeArtifactId=maven-archetype-webapp

2. Added <proj>/src/main/resources/META-INF/MANIFEST.MF to specify deployment-library name, version etc.
Specification-Title: TEMP-ADF Faces Library
Specification-Version: 1.0
Implementation-Title: TEMP-ADF Faces Library
Implementation-Version: 1.0
Implementation-Vendor: Self
Extension-Name: adf

2. Added following dependencies in the pom.xml and in added needed jars in my local repository.
    <dependency>
      <groupId>oracle.jdeveloper.library</groupId>
      <artifactId>ADF-Faces-Runtime-11</artifactId>
      <version>11.1.2.1.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>oracle.jdeveloper.library</groupId>
      <artifactId>ADF-Common-Runtime</artifactId>
      <version>11.1.2.1.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>oracle.jdeveloper.library</groupId>
      <artifactId>ADF-DVT-Faces-Runtime</artifactId>
      <version>11.1.2.1.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>oracle.jdeveloper.library</groupId>
      <artifactId>ADF-DVT-Faces-Databinding-Runtime</artifactId>
      <version>11.1.2.1.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>oracle.jdeveloper.library</groupId>
      <artifactId>ADF-DVT-Faces-Databinding-MDS-Runtime</artifactId>
      <version>11.1.2.1.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>oracle.jdeveloper.library</groupId>
      <artifactId>Oracle-JEWT</artifactId>
      <version>11.1.2.1.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>


4. Updated the pom.xml create-war plugin to include the custom MANIFEST.MF

  <build>
     <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>


5. Build(mvn clean install) and deploy the artifact as a deployment-library.

6. References this custom adf library by adding following to the weblogic.xml

    <library-ref>
        <library-name>adf</library-name>
        <specification-version>1.0</specification-version>
    </library-ref>

7. The web.xml in the webapp should register all the needed servlets(FacesServlet, ResourceServlet, GraphServlet,MapProxyServlet) as needed for ADF.