SeamFramework.orgCommunity Documentation
Weblogic 10.X is BEA's JEE5 server offering, currently 10.0.MP1 is their stable release, and 10.3.TP is their latest tech preview release. Seam applications can be deployed and developed on Weblogic servers, and this chapter will show you how. There are some known issues with the Weblogic servers that will need to be worked around, and configuration changes that are needed.
First step is to get Weblogic downloaded, installed and running (no
small feat). Then we'll talk about Seam's JEE5 example and the hurdles to
getting it running. After that, the JPA example will
be modified and deployed to the server. Then finally we will create a
seam-gen
application and get it up and running to
provide a jump start to your own application.
Weblogic 10.0.MP1
—
Download page
10.0.MP1 has a known issue with EJBs that use
varargs
in their methods (it confuses them
as transient
). This causes exceptions
when Weblogic attempts to compile the Seam EJBs. There is a BEA
support patch available to fix this issue, but BEA is currently
working on a second issue related to the EJBs. See the
jee5/booking
example for more details.
Weblogic 10.3.TP
—
Download page
This version still has not fixed the
varargs
bug, and there is a new issue with
EJBs that do not use kodo
(BEA's
implementation of JPA). BEA has said that the varargs
issue will be resolved in the final version of 10.3,
but the kodo
issue is a blocker for getting
the jee5/booking
working.
jboss-seam.jar
for Weblogic EJB
Support Starting with Seam 2.0.2.CR2 a special Weblogic specific jar has
been created that does not contain the TimerServiceDispatcher
. This is the EJB that uses varargs
and
exposes the second EJB issue. We will be using this jar for the
jee5/booking
example, as it avoids both known BEA
issues.
Here are the quick steps to installing Weblogic 10.1.MP1. For more details or if you are having any issues please check with the BEA docs at the Weblogic 10.0 Doc Center . Here we install the RHEL 5 version using the graphical installer:
Follow the link given above for 10.0.MP1 and download the correct version for your environment. You will need to sign up for an account with BEA in order to do this.
You may need to change the the
server1001_XX.bin
file to be
executable:
chmod a+x server1001_XX.bin
Execute the install:
./server1001_XX.bin
When the graphical install loads, you need to set the BEA
home location. This is where all BEA applications are
installed. This location will be known as
$BEA_HOME
in this document e.g.:
/jboss/apps/bea
Select Complete
as the
installation type. You do not need all the extras of the
complete install (such as struts and beehive libraries), but
it will not hurt.
Then you need to tell it where to install the server components:
$BEA_HOME/wlserver_10.0
Start up the Weblogic configuration wizard:
$BEA_HOME/wlserver_10.0/common/bin/config.sh
Next choose Development Mode
and
the default JDK when given the option.
The next screen asks if you want to customize any setting.
Select No
.
Finally set the name of the domain to
seam_examples
and leave the default
domain location.
In this section we will go over the steps needed to get
the jee5/booking
example to up and running.
Start up the server and navigate to the administration console following Section 34.1.3, “How to Start/Stop/Access your domain”
On the left side tree navigate
seam_examples - Services- JDBC - Data
Sources
.
You must lock the domain configuration using the button in the upper left box.
Then select the New
button at the top of the data source table
Fill in the following:
Name:
seam-jee5-ds
JNDI Name:
seam-jee5-ds
Database Type and Driver:
other
Select Next
button
Select Next
button on the
Transaction Options
page
Fill in the following on the Connection
Properties
page:
Database Name:
hsqldb
Host Name:
127.0.0.1
Port: 9001
Username: sa
will
empty password fields.
Select Next
button
Fill in the following on the Connection
Properties
page:
Driver Class Name:
org.hsqldb.jdbcDriver
URL:
jdbc:hsqldb:.
Username: sa
will
empty password fields.
Leave the rest of the fields as is.
Select Next
button
Choose the target domain for the data source in our
case the only one AdminServer
.
Click Next
.
Finally - apply the changes by selecting the
Apply Changes
button in the
upper left corner.
In the administration console navigate to the
Deployments
page using the left hand
menu.
You must lock the domain configuration using the button in the upper left box.
Then select the Install
button at the top of the deployments table
Then activate the changes by clicking the green button in the upper left.
Shutdown the server following Section 34.1.3, “How to Start/Stop/Access your domain”
Then execute
cp ../../../lib/jsf-api.jar /jboss/apps/bea/user_projects/domains/seam_examples/lib
. Verify the jar was copied correctly.
Start up the server and navigate to the administration console following Section 34.1.3, “How to Start/Stop/Access your domain”
Then verify a clean start up of the server.
resources/META-INF/persistence.xml
Change the
jta-data-source
to what you entered above :
<jta-data-source>seam-jee5-ds</jta-data-source>
Then add these two properties for weblogic support.
<property name="hibernate.dialect"
value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
resources/META-INF/weblogic-application.xml
This file needs to be created and should contain the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<weblogic-application>
<library-ref>
<library-name>jsf</library-name>
<specification-version>1.2</specification-version>
<implementation-version>1.2</implementation-version>
<exact-match>false</exact-match>
</library-ref>
<prefer-application-packages>
<package-name>antlr.*</package-name>
</prefer-application-packages>
</weblogic-application>
resources/META-INF/ejb-jar.xml
Modify the
assembly-descriptor
element to look like this:
<assembly-descriptor>
<interceptor-binding>
<ejb-name>AuthenticatorAction</ejb-name>
<interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>BookingListAction</ejb-name>
<interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>RegisterAction</ejb-name>
<interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>ChangePasswordAction</ejb-name>
<interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>HotelBookingAction</ejb-name>
<interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>HotelSearchingAction</ejb-name>
<interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>EjbSynchronizations</ejb-name>
<interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
resources/WEB-INF/weblogic.xml
This file needs to be created and should contain the following:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app>
<library-ref>
<library-name>jsf</library-name>
<specification-version>1.2</specification-version>
<implementation-version>1.2</implementation-version>
<exact-match>false</exact-match>
</library-ref>
</weblogic-web-app>
resources/WEB-INF/web.xml
There are some changes needed to the build script and the
jboss-seam.jar
then we can deploy the app.
build.xml
<fileset id="war.lib.extras" dir="${seam.dir}">
<include name="lib/richfaces-api.jar" />
</fileset>
Next we need to add the follow so that the
weblogic-application.xml
will be packaged.
<!-- Resources to go in the ear -->
<fileset id="ear.resources" dir="${resources.dir}">
<include name="META-INF/application.xml" />
<include name="META-INF/weblogic-application.xml" />
<include name="META-INF/*-service.xml" />
<include name="META-INF/*-xmbean.xml" />
<include name="treecache.xml" />
<include name="*.jpdl.xml" />
<exclude name=".gpd.*" />
<include name="*.cfg.xml" />
<include name="*.xsd" />
</fileset>
$SEAM/lib/interop/jboss-seam-wls-compatible.jar
This is the change discussed above in Section 34.2.1, “EJB3 Issues with Weblogic” . There are really two options.
Rename this jar and replace the original
$SEAM/lib/jboss-seam.jar
file. This approach does not require any
changes to the packaged
EAR
archive, but overwrites the original
jboss-seam.jar
The other option is the modify the
packaged
EAR
archive and replace the
jboss-seam.jar
in the archive manually. This leaves the
original jar alone, but requires a manual
step when ever the archive is packaged.
Assuming that you choose the first option for handling
the
jboss-seam-wls-compatible.jar
we can build the application by running
ant archive
at the base of the
jee5/booking
example directory.
Because we chose to create our Weblogic domain in development mode we can deploy the application by putting the EAR file in the domains autodeploy directory.
cp ./dist/jboss-seam-jee5.ear /jboss/apps/bea/user_projects/domains/seam_examples/autodeploy
Check out the application at
http://localhost:7001/seam-jee5/
Note that this example assumes that Weblogic's JSF libraries have been configured as described in Section 34.2.2.2, “Setting up Weblogics JSF Support”.
Step one setup the datasource, step two build the app, step three deploy.
Configuring the datasource is very similar to the jee5 Section 34.2.2.1, “Setting up the hsql datasource” . Follow the steps in that section, but use the following entries where needed.
DataSource Name:
seam-jpa-ds
JNDI Name:
seam-jpa-ds
Building it only requires running the correct ant command:
ant weblogic10.xml
This will create a container specific distribution and exploded archive directories.
When we installed Weblogic following Section 34.1.2, “Creating your Weblogic domain” we chose to have the domain in development mode. This means to deploy the application all we need to do is copy it into the autodeploy directory.
cp ./dist-weblogic10/jboss-seam-jpa.war /jboss/apps/bea/user_projects/domains/seam_examples/autodeploy
Check out the application at the following
http://localhost:7001/jboss-seam-jpa/
.
Between the the Weblogic 10.x and 9.2 examples there are several differences:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
<library-ref>
<library-name>jsf</library-name>
<specification-version>1.2</specification-version>
<implementation-version>1.2</implementation-version>
<exact-match>false</exact-match>
</library-ref>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
<property name="hibernate.query.factory_class"
value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>
WEB-INF/components.xml
— In the Weblogic 10.x version JPA entity
transactions is enabled by adding:
<transaction:entity-transaction entity-manager="#{em}"/>
WEB-INF/web.xml
— Because the jsf-impl.jar
is not in the WAR
this listener
need to be configured :
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
Between the Weblogic 10.x version and the JBoss version there are more changes. Here is the rundown:
build.xml
resources/META-INF/persistence-dev.xml
Change the transaction type to
RESOURCE_LOCAL
so that we can use JPA transactions.
<persistence-unit name="weblogic_example" transaction-type="RESOURCE_LOCAL">
Add/modify the properties below for Weblogic support:
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider"/>
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
resource/WEB-INF/weblogic.xml
You will need to create this file and populate it following description of WEB-INF/weblogic.xml.
resource/WEB-INF/components.xml
We want to use JPA transactions so we need to add the following to let Seam know.
<transaction:entity-transaction entity-manager="#{entityManager}"/>
You will also need to add the transaction namespace and schema location to the top of the document.
xmlns:transaction="http://jboss.com/products/seam/transaction"
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd
resource/WEB-INF/web.xml
WEB-INF/web.xml
— Because the
jsf-impl.jar
is not in the
WAR
this listener need to be configured :
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
resources/WEB-INF/jboss-app.xml
You can delete this file as we aren't
deploying to JBoss AS (
jboss-app.xml
is used to enable classloading isolation in
JBoss AS)
resources/*-ds.xml
You can delete these files as we aren't deploying to JBoss AS. These files define datasources in JBoss AS, in Weblogic we will use the administration console.
The seam-gen
application has very
similar library dependencies as the jpa
example above. See Section 34.3.2, “What's different with Weblogic 10.x”.
Below is the changes that are needed to get them in this
application.
build.xml — Now we need to adjust the
build.xml
. Find the target
war
and add the following to the end
of the target.
<copy todir="${war.dir}/WEB-INF/lib">
<fileset dir="${lib.dir}">
<!-- Misc 3rd party -->
<include name="commons-logging.jar" />
<include name="dom4j.jar" />
<include name="javassist.jar" />
<include name="cglib.jar" />
<include name="antlr.jar" />
<!-- Hibernate -->
<include name="hibernate.jar" />
<include name="hibernate-commons-annotations.jar" />
<include name="hibernate-annotations.jar" />
<include name="hibernate-entitymanager.jar" />
<include name="hibernate-validator.jar" />
<include name="jboss-common-core.jar" />
<include name="concurrent.jar" />
</fileset>
</copy>
When the application is built using the development profile
the action
class files are placed in the
WEB-INF/dev
directory. Normally these
class files are hot deployable and managed by Seam. This does not
happen on Weblogic (see
jira JBSEAM-2455 for details and status).
To workaround this you need to modify the
build-dev.properties
file. Simply
remove the property
action.dir=WEB-INF/dev
.
Configuring the datasource is very similar to the jee5 Section 34.2.2.1, “Setting up the hsql datasource”. Except for what is listed here follow that instruction from the link.
DataSource Name:
seam-gen-ds
JNDI Name: seam-gen-ds
When we installed Weblogic following Section 34.1.2, “Creating your Weblogic domain” we chose to have the domain in development mode. This means to deploy the application all we need to do is copy it into the autodeploy directory.
cp ./dist/weblogic_example.war /jboss/apps/bea/user_projects/domains/seam_examples/autodeploy
Check out the application at the following
http://localhost:7001/weblogic_example/
.
.