WebLogic 10.3.4.0 + OEPE + Maven + Primefaces 2.2RC

Markus Eisele
10
The new WebLogic is there since a few days and we are right in front of another new release of another component: Primefaces 2.2 has RC state at the moment and we are all waiting for a final release happening hopefully the next time. If you are willing to give the existing RC a test drive you can follow this short blog in which I try to shortly summarize the steps necessary to take to get one of my favorite development setups up an running with WebLogic and Primefaces.

What you need
You need the latest WebLogic 10.3.4.0, Maven 3.0 and Primefaces 2.2RC. The first two get installed by the WebLogic installer and you can head over to install the m2eclipse plugin next. You also should install m2eclipse Extras which makes live a lot easier if you are working with web apps and maven. Everything is finished by restarting the OEPE. Now go and grep Apache Maven and install it to a location of your choice.

Creating and configuring your project
Fire up the OEPE. Go to preferences and add your Maven installation to the configured Maven / Installations. Right click "New > Other", select "Maven > Maven Project". Click "Next >". Select the "org.apache.maven.archetypes.maven-archetype-webapp". Click "Next". Enter a valid Group Id, Artifact Id and a package. Click "Finish". You now have a Dynamic Webproject in your Workspace (thanks to m2eclipse Extras). Open the pom and add two repositories:

<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr</url>
<layout>default</layout>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>

After that you have to add the following two dependencies:

<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.RC2</version>
</dependency>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
.
Done with maven. Next is to configure the webapplication. Oben the WEB-INF/web.xml and add the jsf servlet:

<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

Now create a WEB-INF/weblogic.xml and add the JSF 2.0 library references to your project.

<library-ref>
<library-name>jsf</library-name>
<specification-version>2.0</specification-version>
<implementation-version>1.0.0.0_2-0-2</implementation-version>
<exact-match>false</exact-match>
</library-ref>


Creating and configuring your WebLogic Domain
Go ahead and configure your local WebLogic Server instance with OEPE. Goto "Server View" and select "New". Select the Oracle WebLogic Server 11gR1 PatchSet 3 server adapter and select or add a Server runtime environment. Click "Next >". Select an existing or create a new Domain Directory. Right click the server entry and "Start" the server. Visit http://localhost:7001/console, select "Deployments > Install". Navigate to WL_HOME/wlserver_10.3/common/deployable-libraries and select the jsf-2.0.war. Click "Next". Accept the "Install this deployment as a library" selection and click "Next". review the settings (nothing to do here for us today) and click "Finish". Now you should see a jsf(2.0,1.0.0.0_2-0-2) deployed on your instance. Fine. Done.

Writing some code
Create an index.xhtml file in your WebContent folder and add some functionality:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<p:panel header="Hello From">
<p:button outcome="test" value="Next"/>
</p:panel>
</h:body>
</html>

Fine. Don't forget to add another page called test.xhtml with some more content, if you are copying this example :)
Now build and install your application. If you are using the WebLogic 10.3.4.0 Maven Plug-In for Deployment simply type mvn weblogic:deploy to get your primefaces app up and running (or better use m2eclipse ;) and define a new Run as... target).
And that's what the nice stuff is looking like:


What's left?
If you are running without any further changes, you probably see some warnings in your logfiles about missing mime-types like the following.
<Notice> <StdErr> <BEA-000000>: com.sun.faces.context.ExternalContextImpl getMimeType
WARNING: JSF1091: No mime type could be found for file skins/sam/images/ui-default.png. To
resolve this, add a mime-type mapping to the applications web.xml.


In order to avoid this, you have to add the mime type mapping to your web.xml configuration.

<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>


Thats's all. Now your are running the latest Primefaces 2.2RC on you JSF 2.0 based WebLogic Server. Congratulations!
For those of you, interested: Here is the complete primefaces.zip (4KB) with the configuration. Have fun ...

Post a Comment

10Comments

  1. I wonder, if Primefaces may become RI for the next JSF release? (likely 2.1) especially after Apache Foundation has left the JCP to a large extent.

    ReplyDelete
  2. Hi Werner,

    thanks for the comment. I can't speak for Cagatay but I expect them to not invest into another RI. Even if Apache left the JCP they will stick to MyFaces, at last for the near future and the Mojarra is there and will be there.

    Rgds
    M

    ReplyDelete
  3. I cant create this example. The file web.xml does not exists (maven not create it).

    ReplyDelete
  4. @Jassa:

    Try generating the archetype from the cmd line:
    mvn archetype:generate
    - select 110
    - select 5
    - enter properties (groupid, artifactiId) of your choice
    - enter Y

    And look at artifactiId\src\main\webapp\WEB-INF\ there you can find your web.xml

    Thanks,
    M

    ReplyDelete
  5. Hi Markus

    I presume that the steps are same for primefaces 3.1 with WLS 10.3.4.

    ReplyDelete
  6. Another question I have is do I need to have the following jars inside WEB-INF/lib folder?

    jstl-1.0.2.jar
    jsf-impl-2.0.3.jar
    jsf-api-2.0.3.jar
    primefaces-3.1.jar

    ReplyDelete
  7. Hi Jacob,

    not exactly. you need to use the JSF 2.0 shared library (jsf-2.0.war).

    Rgds,
    M

    ReplyDelete
  8. Again hi Jacob,

    you only need the primefaces-3.1 dependency (which in fact is packaged by maven to your WEB-INF/lib directory). So, you don't have to add nothing else. Let maven do the work and keep the fingers away from the js*.jars. They are contained with the shared library.

    Thanks,
    M

    ReplyDelete
  9. Hi
    Could you be kind enough to suggest how to create new Run as target using m2eclipse?

    Thanks

    ReplyDelete
  10. Hi Jacob,

    please look here: http://kb.sonatype.org/entries/20900471.html

    Thanks,
    M

    ReplyDelete
Post a Comment