About software development for the enterprise. Focus on Java EE and more general Java platforms.
You'll read a lot about Conferences, Java User Groups, Java EE, Integration, AS7, WildFly, EAP and other technologies that hit my road.

Friday, January 21, 2011

WebLogic 10.3.4.0 + OEPE + Maven + Primefaces 2.2RC

14:06 Friday, January 21, 2011 Posted by Markus Eisele
, ,
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 ...