text: 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:
  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.
  You may need to change the the server103tp_XX.bin file to be executable:
  chmod a+x server103tp_XX.bin
  Execute the install:
  ./server103tp_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.:
  /home/jbalunas/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.3tp
  A Weblogic domain is similar to a JBoss server configuration - it is a self contained server instance. The Weblogic server you just installed has some example domains, but we are going to create one just for the seam examples. You can use the existing domains if you wish (modify the instructions as needed).
  Start up the Weblogic configuration wizard:
  $BEA_HOME/wlserver_10.3tp/common/bin/config.sh
  Choose to create a new domain, configured to support Weblogic Server TP. Note that this is the default domain option.
  Set a username and password for this domain.
  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.
  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 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:
  Select seam-examples on the left hand side of the console.
  Choose the Control tab in the middle of the page.
  Select the check box AdminServer in the table.
  Choose Shutdown just above the table, and select either When work completes or Force shutdown now as appropriate.
  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.
  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: :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.
  A less severe issue is also present in the tech preview version of Weblogic. You can not use any JPA provider with EJB's except for the default kodo or openJPA implementation. As you set up this example you will run into this issue before the varargs problem. Unfortunately using kodo or openJPA does not help with the blocker described above but is important to know.
  Other users have seen this issue with the tech preview and I would hope/expect that it will be fixed in future releases ( BEA Forum). The forum entry has the exact stack trace, and the response from BEA.
  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.
  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
  Start up the server and navigate to the administration console following Section 27.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 button 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 empty.
  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.
  Because the tech preview version will only work with kodo or openJPA as the JPA provider you must change the provider to :
  <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
  Next you need to change the jta-data-source to what you entered above :
  <jta-data-source>seam-jee5-ds</jta-data-source>
  The other properties in the file are hibernate specific and are not used by openJPA but can be left in.
  There are some changes needed to the build script and then we can attempt to deploy the app.
  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: :32: modifier transient not allowed here public transient void scheduleTransactionSuccessEvent(java.lang.String arg0, java.lang.Object[] arg1) ^ :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.
  Step one setup the datasource, step two build the app, step three deploy.
  The Weblogic 10.X version of the example uses the in memory hsql database instead of the built in PointBase database. If you wish to use the PointBase database you must setup a PointBase datasource, and adjust the hibernate setting in persistence.xml to use the PointBase dialect. For reference the jpa/weblogic92 example uses PointBase.
  Configuring the datasource is very similar to the jee5 Section 27.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 -f build-weblogic10.xml
  This will create container specific distribution and exploded archive directories.10/jboss-seam-jpa.war /home/jbalunas/bea/user_projects/domains/seam_examples/autodeploy
  Between the the Weblogic 10.x and 9.2 examples there are several differences:
  META-INF/persistence.xml — The 9.2 version is configured to use the PointBase database and a pre-installed datasource. The 10.x version uses the hsql database and a custom datasource.
  WEB-INF/weblogic.xml — This file and its contents solve an issue with an older version of the ANTLR libraries that Weblogic 10.x uses internally. OC4J have the same issue as well.
  <?xml version="1.0" encoding="UTF-8"?> <weblogic-web-app <container-descriptor> <prefer-web-inf-classes>true</prefer-web-inf-classes> </container-descriptor> </weblogic-web-app>
  This file make Weblogic use classes and libraries in the web application before other libraries in the classpath. Without this change hibernate is required to use a older, slower query factory by setting the following property in the META-INF/persistence.xml file.
  <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
  Between the Weblogic 10.x version and the JBoss version there are more changes. Here is the rundown:
  META-INF/persistence.xml — Except for datasource name the WebLogic version sets:
  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
  WEB-INF/jboss-web.xml — The JBoss version uses this instead of weblogic.xml
  WEB-INF/lib — The Weblogic version requires several library packages because they are not included as they are with JBoss AS. These are primarily for hibernate, JSF-RI support and their dependencies.
  To use Hibernate as your JPA provider you need the following jars:
  Seam requires JSF 1.2 and these are jars needed for that. Weblogic 10.3.TP does not ship JSF libraries installed by default.
  Various third party jars that Weblogic 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 27.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.
  .] weblogic-example [echo] Accepted project name as: weblogic, ) war [input] Enter the Java package name for your session beans [com.mydomain.weblogic_example] [com.mydomain.weblogic_example] org.jboss.seam.tutorial.weblogic.action [input] Enter the Java package name for your entity beans [org.jboss.seam.tutorial.weblogic.action] [org.jboss.seam.tutorial.weblogic.action] 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], ) [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.
  Change the default target to archive.
  <project name="weblogic_example" default="archive" basedir=".">
  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
  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.
  You will need to create this file and populate it following description of WEB-INF/weblogic.xml.
  We want to use JPA transactions so we need to add the following to let Seam know.
  <transaction:entity-transaction
  You will also need to add the transaction namespace and schema location to the top of the document.
  xmlns:transaction=""
  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)
  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 27.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>
  There is currently an issue with the behavior of the seam-gen WAR application when built using the development profile (the default) and deployed to Weblogic. The symptom is that the login page of the application will always show a login failed message.
  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.
  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 27.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_example.war /home/jbalunas/bea/user_projects/domains/seam_examples/autodeploy