JBoss.org Community Documentation

Chapter 33. Seam on BEA's Weblogic

33.1. Installation and operation of Weblogic
33.1.1. Installing 10.3.TP
33.1.2. Creating your Weblogic domain
33.1.3. How to Start/Stop/Access your domain
33.2. The jee5/booking example
33.2.1. EJB Blockers with Weblogic
33.2.2. The jee5/booking example
33.3. The jpa booking example
33.3.1. Building and deploying jpa booking example
33.3.2. What's different with Weblogic 10.x
33.4. Deploying an application created using seam-gen on Weblogic 10.x
33.4.1. Running seam-gen setup
33.4.2. What to change for Weblogic 10.X
33.4.3. Building and Deploying your application

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, and what blockers exist. After that the JPA example will be modified and deployed to the server. Then finally we will create seam-gen application and get it up and running to provide a jump start to your application.

First things first we need to get the server installed - and there is a choice to be made. Weblogic 10.0.MP1 is the most recent stable release, while 10.3.TP is a technical preview version that fixes some things and breaks others.

  • 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 as varargs are used. There seems to be no work around to this issue in 10.0.MP1. Because of this only the jpa and WAR based seam-gen examples work with this version. 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). See the jee5/booking example for more details. However if the varargs issue is going to get fixed it will most likely be an update to this version.

For the reasons listed above, and the fact that 10.3.TP gets us closer to the goal of Seam EJB3 support on Weblogic, 10.3.TP will be used for the examples below.

Here are the quick steps to installing Weblogic 10.3.TP. For more details or if you are having any issues please check with the BEA docs at the Tech Preview Doc Center . Here we install the RHEL 5 version using the graphical installer:

  1. Follow the link given above for 10.3.TP and download the correct version for your environment. You will need to sign up for an account with BEA in order to do this.

  2. You may need to change the the server103tp_XX.bin file to be executable:

    chmod a+x server103tp_XX.bin
  3. Execute the install:

    ./server103tp_XX.bin
  4. 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.:

    /home/jbalunas/bea
  5. 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.

  6. Then you need to tell it where to install the server components:

    $BEA_HOME/wlserver_10.3tp

Now that the server is installed and the domain is created you need to know how to start and stop it, plus how to access its configuration console.

  • Starting the domain:

    This is the easy part - go to the $BEA_HOME/user_projects/domains/seam_examples/bin directory and run the ./startWeblogic.sh script.

  • Accessing the configuration console:

    Launch http://127.0.0.1:7001/console in your web browser. It will ask for your username and password that you entered before. We won't get into this much now, but this is the starting point for a lot of the various configurations that are needed later.

  • Stopping the domain:

    There are a couple of options here:

    • The recommended way is through the configuration console:

      1. Select seam-examples on the left hand side of the console.

      2. Choose the Control tab in the middle of the page.

      3. Select the check box AdminServer in the table.

      4. Choose Shutdown just above the table, and select either When work completes or Force shutdown now as appropriate.

      5. Then finally confirm that you want to shut this server down.

    • Hitting Ctrl-C in the terminal where you started the domain.

      No negative effects have been seen, but we would not recommend doing this while in the middle of configuration changes in the console.

  • A note on Weblogic classloading

    When using the @DOMAIN/autodeploy directory as described in this chapter you may see NoClassDefFound exceptions. If you see this try restarting the Weblogic server. If you still see it remove the auto-deployed EAR/WAR files, restart the server, and redeploy. We could not find a specific reason for this, but others seem to be having this issue as well.

Do you want to run Seam using EJB's on Weblogic? If so there are some blockers that keep it from working. This section describes what changes are needed to the jee5/booking example to get it as close to deploying as possible. First we'll talk about the blockers and what they effect.

For several releases of Weblogic there has been an issue with compiling EJB's that use variable arguments in their methods. This is confirmed in the Weblogic 9.X and 10.X versions. We had hoped that the issue would be resolved in the tech preview release, but it is not. Seam uses variable arguments in its internal EJB's and so until this is fixed Seam with EJB's will not work.

The gist of the issue is that the Weblogic EJB compiler believes that methods that use varargs are transient and the deployment will fail with exceptions like below:

java.io.IOException: Compiler failed executable.exec: 
/home/jbalunas/bea/wlserver_10.3tp/user_projects/domains/seam_examples/servers/AdminServer
/cache/EJBCompilerCache/5yo5dk9ti3yo/org/jboss/seam/async/
TimerServiceDispatcher_qzt5w2_LocalTimerServiceDispatcherImpl.java:194: modifier transient 
not allowed here
  public transient javax.ejb.Timer scheduleAsynchronousEvent(java.lang.String arg0,
  java.lang.Object[] arg1)
                                   ^
/home/jbalunas/bea/wlserver_10.3tp/user_projects/domains/seam_examples/servers/AdminServer
/cache/EJBCompilerCache/5yo5dk9ti3yo/org/jboss/seam/async/
TimerServiceDispatcher_qzt5w2_LocalTimerServiceDispatcherImpl.java:275: modifier transient
not allowed here
  public transient javax.ejb.Timer scheduleTimedEvent(java.lang.String arg0, 
  org.jboss.seam.async.TimerSchedule arg1, java.lang.Object[] arg2)

BEA says that this is a bug with Java specification. Sun admits the issue, and provides a work around, and will not fix the core issue.

  • BEA forum — Discusses the issue and suggests waiting for a new release of 10.X

  • BEA forum — Discusses response from BEA support and that BEA is saying it is an issue with the spec with links to the bug.

  • Sun bug report — Describes details of the issue, but says that it will not be fixed.

So what does that mean to us? At least for now EJB's with variable arguments will not run on Weblogic.

In this section will will quickly go over the steps needed to get the jee5/booking example to the point that blocker shows itself.

This example uses the in memory hypersonic database, and the correct data source needs to be set up. The admin console uses a wizard like set of pages to configure it.

  1. Copy hsqldb.jar to weblogic domain's shared library directory: cp ../../seam-gen/lib/hsqldb.jar /home/jbalunas/bea/user_projects/domains/seam_examples/lib

  2. Start up the server and navigate to the administration console following Section 33.1.3, “How to Start/Stop/Access your domain”

  3. On the left side tree navigate seam_examples - Services- JDBC - Data Sources.

  4. You must lock the domain configuration using the button in the upper left box.

  5. Then select button New button at the top of the data source table

  6. Fill in the following:

    1. Name: seam-jee5-ds

    2. JNDI Name: seam-jee5-ds

    3. Database Type and Driver: other

    4. Select Next button

  7. Select Next button on the Transaction Options page

  8. Fill in the following on the Connection Properties page:

    1. Database Name: hsqldb

    2. Host Name: 127.0.0.1

    3. Port: 9001

    4. Username: sa will empty password fields.

    5. Select Next button

  9. Fill in the following on the Connection Properties page:

    1. Driver Class Name: org.hsqldb.jdbcDriver

    2. URL: jdbc:hsqldb:.

    3. Username: sa will empty password fields.

    4. Leave the rest of the fields empty.

    5. Select Next button

  10. Choose the target domain for the data source in our case the only one AdminServer. Click Next.

  11. Finally - apply the changes by selecting the Apply Changes button in the upper left corner.

There are some changes needed to the build script and then we can attempt to deploy the app.

build.xml

Weblogic does not ship with a default JSF implementation so we need to add the JSF libraries to the WAR. Add the following to the build.xml and this will add the needed jars. Note that richfaces-api.jar is only needed if using the admin console to deploy. For some reason Weblogic needs it in the WAR when it scans the application.


<fileset id="war.lib.extras" dir="${seam.dir}">
   <include name="lib/jsf-api.jar" />
   <include name="lib/jsf-impl.jar" />
   <include name="lib/richfaces-api.jar" />
</fileset>

Now we can build the application by running ant archive at the base of the 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 
    /home/jbalunas/bea/user_projects/domains/seam_examples/autodeploy

Here is where we see the varargs issue. In the console output you will some Kodo warnings, then exceptions and compile errors like the one below.

<Error> <EJB> <BEA-012036> <Compiling generated EJB classes produced 
                            the following Java compiler error message:

/home/jbalunas/bea/user_projects/domains/seam_examples/servers/AdminServer/cache/
EJBCompilerCache/5yo5dk9ti3yo/org/jboss/seam/async/
TimerServiceDispatcher_qzt5w2_LocalTimerServiceDispatcherImpl.java:32:
                modifier transient not allowed here
  public transient void scheduleTransactionSuccessEvent(java.lang.String arg0,
  java.lang.Object[] arg1)
                        ^
/home/jbalunas/bea/user_projects/domains/seam_examples/servers/AdminServer/cache/
EJBCompilerCache/5yo5dk9ti3yo/org/jboss/seam/async/
TimerServiceDispatcher_qzt5w2_LocalTimerServiceDispatcherImpl.java:113:
                modifier transient not allowed here
  public transient javax.ejb.Timer scheduleAsynchronousEvent(java.lang.String arg0,
  java.lang.Object[] arg1)

...

This is as far as we can go with Weblogic using EJB's with seam until the varargs issue is resolved.

This is the Hotel Booking example implemented in Seam POJO and Hibernate JPA and does not require EJB3 support to run. The example already has a breakout of configurations and build scripts for many of the common containers including Weblogic 10.X

First we'll build the example for Weblogic 10.x and do the needed steps to deploy. Then we'll talk about what is different between the Weblogic versions, and with the JBoss AS version.

seam-gen is a very useful tool for developers to quickly get an application up and running, and provides a foundation to add your own functionality. Out of box seam-gen will produce applications configured to run on JBoss AS. These instructions will show the steps needed to get it to run on Weblogic.

seam-gen was build for simplicity so, as you can imagine, deploying an application generated by seam-gen to Weblogic 10.x is not too hard. Basically it consists of updating or removing some configuration files, and adding dependent jars that Weblogic 10.x does not ship with.

We still need to live within the constraints imposed to us by Weblogic, and because of that this example will generate a WAR based application instead of an EAR. See Section 33.2.1, “EJB Blockers with Weblogic” for details.

This example will cover the basic seam-gen WAR deployment. This will demonstrate Seam POJO components, Hibernate JPA, Facelets, Drools security, RichFaces, and a configurable DataSource.

The first thing we need to do it tell seam-gen about the project we want to make. This is done by running ./seam setup in the base directory of the Seam distribution. Note the paths here are my own, feel free to change for you environment.

./seam setup
Buildfile: build.xml

init:

setup:
     [echo] Welcome to seam-gen :-)
    [input] Enter your Java project workspace (the directory that contains your 
Seam projects) [C:/Projects] [C:/Projects]
/home/jbalunas/workspace
    [input] Enter your JBoss home directory [C:/Program Files/jboss-4.2.2.GA] 
[C:/Program Files/jboss-4.2.2.GA]
/home/jbalunas/jboss/jboss-4.2.2.GA
    [input] Enter the project name [myproject] [myproject]
weblogic-example
     [echo] Accepted project name as: weblogic_example
    [input] Select a RichFaces skin (not applicable if using ICEFaces) [blueSky]
 ([blueSky], classic, ruby, wine, deepMarine, emeraldTown, sakura, DEFAULT)

    [input] Is this project deployed as an EAR (with EJB components) or a WAR 
(with no EJB support) [ear]  ([ear], war, )
war
    [input] Enter the Java package name for your session beans [org.jboss.seam.
tutorial.weblogic.action] [org.jboss.seam.tutorial.weblogic.action]
org.jboss.seam.tutorial.weblogic.action
    [input] Enter the Java package name for your entity beans [org.jboss.seam.
tutorial.weblogic.model] [org.jboss.seam.tutorial.weblogic.model]
org.jboss.seam.tutorial.weblogic.model
    [input] Enter the Java package name for your test cases [org.jboss.seam.
tutorial.weblogic.action.test] [org.jboss.seam.tutorial.weblogic.action.test]
org.jboss.seam.tutorial.weblogic.test
    [input] What kind of database are you using? [hsql]  ([hsql], mysql, oracle,
 postgres, mssql, db2, sybase, enterprisedb, h2)

    [input] Enter the Hibernate dialect for your database [org.hibernate.
dialect.HSQLDialect] [org.hibernate.dialect.HSQLDialect]

    [input] Enter the filesystem path to the JDBC driver jar [lib/hsqldb.jar] 
[lib/hsqldb.jar]

    [input] Enter JDBC driver class for your database [org.hsqldb.jdbcDriver] 
 [org.hsqldb.jdbcDriver]

    [input] Enter the JDBC URL for your database [jdbc:hsqldb:.] [jdbc:hsqldb:.]

    [input] Enter database username [sa] [sa]

    [input] Enter database password [] []

    [input] Enter the database schema name (it is OK to leave this blank) [] []

    [input] Enter the database catalog name (it is OK to leave this blank) [] []

    [input] Are you working with tables that already exist in the database? [n] 
 (y, [n], )

    [input] Do you want to drop and recreate the database tables and data in 
import.sql each time you deploy? [n]  (y, [n], )

    [input] Enter your ICEfaces home directory (leave blank to omit ICEfaces) [] []

[propertyfile] Creating new property file: 
/rhdev/projects/jboss-seam/cvs-head/jboss-seam/seam-gen/build.properties
     [echo] Installing JDBC driver jar to JBoss server
     [copy] Copying 1 file to /home/jbalunas/jboss/jboss-4.2.2.GA/server/default/lib
     [echo] Type 'seam create-project' to create the new project

BUILD SUCCESSFUL

Type ./seam new-project to create your project and cd /home/jbalunas/workspace/weblogic_example to see the newly created project.

First we change and delete some configuration files, then we update the libraries that are deployed with the application.

build.xml
  • Change the default target to archive.

    
    <project name="weblogic_example" default="archive" basedir=".">
resources/META-INF/persistence-dev.xml
  • Alter the jta-data-source to be seam-gen-ds (and use this as the jndi-name when creating the data source in Weblogic's admin console)

  • 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"/>
  • Remove the JBoss AS specific method of exposing the EntityManagerFactory:

    
    <property 
     name="jboss.entity.manager.factory.jndi.name" 
     value="java:/weblogic_exampleEntityManagerFactory">
  • You'll need to alter persistence-prod.xml as well if you want to deploy to Weblogic using the prod profile.

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
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 33.3.2, “What's different with Weblogic 10.x”. Below is the changes that are needed to get them in this application.

  • Missing jars — There are two libraries that seam-gen does not provide by default. These need to be copied into your projects lib directory manually.

    • jboss-archive-browsing.jar — can be found in the @SEAM_DIST/examples/jpa/lib directory.

    • el-ri.jar — is also found in the @SEAM_DIST/examples/jpa/lib directory.

  • 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}">
                         <!--JSF implementation -->
                         <include name="jsf-api.jar" />
                         <include name="jsf-impl.jar" />
                         
                         <!-- 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-archive-browsing.jar" />
                         
                         <!-- Needed for Drools -->
                         <include name="core.jar"/>
                      </fileset>
                  </copy>

Finally all that's left is deploying the application. This involves setting up a data source, building the app, and deploying it.

Configuring the datasource is very similar to the jee5 Section 33.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 33.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 /home/jbalunas/bea/user_projects/domains/seam_examples/autodeploy

Check out the application at the following http://localhost:7001/weblogic_example/ .