Installing Hudson on WebLogic Server

Today I needed to set up a Hudson server and so I decided to put it on WebLogic Server.  Turns out there is a little trick to get it working.  Thanks to Steve Button for sharing the trick with me. 🙂

I installed Hudson 1.396 on WebLogic Server 10.3.4 running on Oracle Linux 5.5 (64-bit).

First you need to download the hudson.war file from the Hudson site.  We need to add a WebLogic deployment descriptor to it so that it wont have any classpath/library  problems.

In the directory where you saved hudson.war create a new directory called WEB-INF and inside that a file called weblogic.xml.  Here is the contents for the file:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
  xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
  <container-descriptor>
    <prefer-application-packages>
      <package-name>org.apache.*</package-name>
      <package-name>org.dom4j.*</package-name>
    </prefer-application-packages>
  </container-descriptor>
</weblogic-web-app>

Now you need to add this file into the hudson.war using the following command:

# jar uvf hudson.war WEB-INF/weblogic.xml

Now we are ready to install Hudson!

Log in to the WebLogic Server adminstration console at http://yourserver:7001/console and start a new edit session (click on Lock and Edit).  Note that you wont have to do this if you are running your server in development mode.

Now click on Deployments in the navigation tree on the left and then click on the Install button.

Click on the link to upload your file(s) and point it to your updated hudson.war.  After it is uploaded, check it is selected and click on Next.

Click Next on the next screen.

Select a managed server to deploy Hudson on.  I used my soa_server1.  Then click on Next.

Click Next on the next screen.

Click on Finish.  After a few moments your application will be installed.

If you are running your server in production mode, you will need to click on the Activate Changes button.  Then return to the Deployments screen, find your newly installed application (hudson), tick the box next to it and click on the Start button and then Servicing all requests.  This will start Hudson on your WebLogic Server.

Now you can open up a browser and visit the Hudson home page at http://yourserver:8001/hudson.  Note that you will have to change the port to match your environment.

More about Hudson later… but for now, enjoy!

Posted in Uncategorized | Tagged , | 4 Comments

Deploying your canonical data model to MDS

Oracle SOA Suite (and Oracle BPM Suite) includes a component called ‘Metadata Services’ or ‘MDS’ which is a good practice to use as the repository for all of your common components that are used across multiple processes and integration artifacts.  One excellent example of such a component is the XML Schemas (XSDs) that define your canonical data model.  This article shows the process to create and deploy XSDs to MDS.

Our XSD defines and holds information of a Customer.  What is a Customer?  What attributes and information can describe a Customer in a particular organization?  These are types of questions organizations start exploring when defining their canonical layer.  Usually this data is already known and stored somewhere, but not publically available, accepted and distributed. XSD could be built using existing structures, e.g. Database, Applications, etc. We build an XSD file from scratch in this example to demonstrate the concept.

This article was written using JDeveloper 11.1.1.4 running on Windows 2008 Server R2 and Oracle SOA Suite 11.1.1.4 running on Oracle Enterprise Linux 5.  The same steps should work in earlier 11.x.x.x versions, however there may be some slight differences in the appearance of some windows.

To start, we create a new application in JDeveloper by selecting Application from the New menu.  In the New Gallery, select Applications under General in the Categories section on the left, and select SOA Application on the right hand side.  If you do not see this option, you may need to select the All Technologies tab at the top.  Then press OK.

image

Enter a name for your application.  I called mine CanonicalModel.  Then click on Next.

image

Enter a name for the SOA project inside your new application.  I gave mine the same name.  Then click on Next.

image

On the Configure SOA settings page, keep the default, Empty Composite, and then click on Finish.

image

Your new application and project will open.  Now, let’s create our canonical data model.  For the purposes of this example, let’s just create a simple ‘customer’ object.  Of course, in your environment, you will have a much more complete canonical data model!

Select New from the File menu.  In the New Gallery select the All Technologies tab, and then select the XML category and XML Schema as shown below.  Then click on OK.

image

Enter a name for your schema, I called mine customer.xsd.  You should put it in the xsd directory of your project.  Set the Target Namespace to something meaningful and provide a Prefix as shown.  Then click on OK.

image

Now you need to create your XSD.  JDeveloper provides a graphical edit for creating XSDs.  For this example, I just created a simple XSD as shown below.

image

To use this same XSD, just copy the code below and paste it into the Source tab of the XSD editor.  You can switch back and forward between the graphical and source views.  Any updates you make in either view will be reflected in the other.

This example follows the ‘best practice’ approach of defining the data structures as types and then the main element, Customer, refers to that type.

<?xml version=”1.0″ encoding=”windows-1252″ ?>
<xsd:schema xmlns:xsd=”
http://www.w3.org/2001/XMLSchema”
xmlns:cc=”http://www.redstack.com/canonical”
targetNamespace=”http://www.redstack.com/canonical”
elementFormDefault=”qualified”>
<xsd:element name=”Customer” type=”cc:CustomerType”>
<xsd:annotation>
<xsd:documentation>
A sample element
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name=”CustomerType”>
<xsd:sequence>
<xsd:element name=”Version” type=”xsd:string”/>
<xsd:element name=”CustomerID” type=”xsd:string”/>
<xsd:element name=”Name” type=”xsd:string”/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

That completes our canonical model!  Well, our simple example anyway.

Now we want to deploy that to our server so that everyone can see it and use it.  To do this, we need to set up a deployment profile.  Select Project Properties from the Application menu.  Then select Deployment in the navigation tree on the left.  You will see one already there.  Click on the New… button to add another deployment profile.

In the Create Deployment Profile dialog, select Jar File as the Archive Type and then enter a name for your deployment profile.  I called mine Metadata.  Then click on OK.

image

In the dialog box, select Jar Options on the left.  Deselect (uncheck) the Include Manifest File option.

image

Move to the Contributors section as shown below.  Unselect all of the options and then click on the Add… button.

image

In the Add Contributor dialog, click on the Browse… button.

image

Navigate to your project directory.  The directory that you choose here will determine the path name that appears in MDS.  If you have a large set of canonical data, you may want to use additional folders to provide some structure.  Click on OK and then OK again.

image

Now select Filters on the left hand side.  On the right hand side, deselect everything except for your XSD file(s), as shown below.  Then click on OK.

image

Now we need to make a ‘SOA Bundle’ containing this deployment profile we just created.  The SOA Bundle is the thing we will actually deploy to the server.  It will contain the jar file with our XSDs in it.

Select Application Properties from the Application menu.  Navigate to the Deployment section on the left, and then click on the New… button.  In the Create Deployment Profile dialog, select SOA Bundle as the Archive Type and enter a name.  I called mine CanonicalModelBundle.  Then click on OK.

image

In the SOA Bundle Deployment Profile Properties dialog, open the Dependencies section and select both of the Java EE Modules as shown below.  Then click on OK.

image

Now we can deploy our canonical data model to MDS.  Select your deployment profile from the Deploy submenu under Application as shown below.

image

The deployment wizard will appear.  On the first page, select Deploy to Application Server and click on Next.

image

You can accept the defaults on the Deploy Configuration page.  Click on Next.

image

Select your server, then click on Next.  If you have not deployed to your server before, you will need to create a connection first.  You can do that by clicking on the green plus icon in the top right corner of this page – you don’t have to leave the deployment wizard.

image

Select the correct managed server and SOA partition to deploy to.  If you don’t know which one to use, you should probably take the default.  Then click on Next.

image

Review the information on the Summary page and then click on Finish to start the deployment.

image

You can review the progress of the deployment by watching the Deployment tab at the bottom of the screen.  If you cannot see it, you can open it from the View menu.  You should see a deployment log something like this:

[02:51:22 PM] —-  Deployment started.  —-
[02:51:22 PM] Target platform is  (Weblogic 10.3).
[02:51:22 PM] Running dependency analysis…
[02:51:22 PM] Building…
[02:51:29 PM] Deploying 3 profiles…
[02:51:29 PM] Wrote Archive Module to C:\JDeveloper\mywork\CanonicalModel\CanonicalModel\deploy\Metadata.jar
[02:51:29 PM] Updating revision id for the SOA Project ‘CanonicalModel.jpr’ to ‘1.0’..
[02:51:29 PM] Wrote Archive Module to C:\JDeveloper\mywork\CanonicalModel\CanonicalModel\deploy\sca_CanonicalModel_rev1.0.jar
[02:51:29 PM] Wrote Archive Module to C:\JDeveloper\mywork\CanonicalModel\deploy\CanonicalModelBundle.zip
[02:51:29 PM] Deploying CanonicalModelBundle.zip to partition “default” on server soa_server1 [
http://ofm1.au.oracle.com:8001]
[02:51:29 PM] Processing sar=/C:/JDeveloper/mywork/CanonicalModel/deploy/CanonicalModelBundle.zip
[02:51:29 PM] Processing zip file – C:\JDeveloper\mywork\CanonicalModel\deploy\CanonicalModelBundle.zip
[02:51:29 PM] Adding shared data file – C:\Users\ADMINI~1\AppData\Local\Temp\deploy_client_1295495489829\Metadata.jar
[02:51:29 PM] Adding sar file – C:\Users\ADMINI~1\AppData\Local\Temp\deploy_client_1295495489829\sca_CanonicalModel_rev1.0.jar
[02:51:29 PM] Preparing to send HTTP request for deployment
[02:51:29 PM] Creating HTTP connection to host:ofm1.au.oracle.com, port:8001
[02:51:29 PM] Sending internal deployment descriptor
[02:51:29 PM] Sending archive – sca_CanonicalModel_rev1.0.jar
[02:51:29 PM] Sending archive – Metadata.jar
[02:51:30 PM] Received HTTP response from the server, response code=200
[02:51:30 PM] Successfully deployed archive CanonicalModelBundle.zip to partition “default” on server soa_server1 [
http://ofm1.au.oracle.com:8001]
[02:51:30 PM] Elapsed time for deployment:  8 seconds
[02:51:30 PM] —-  Deployment finished.  —-

That completes our deployment.  Our canonical data model is now available on the server and everyone will be able to use it.

Let’s take a look at how a developer can view the data model.  To do this, you need to create a connection to the MDS from JDeveloper.  Select New from the File menu.  Select Connections on the left and SOA-MDS-Connection on the right, as shown below.  Then press OK.

image

In the Create SOA-MDS Connection dialog, enter a name for your connection, I called mine ofm1MDS.  Select DB Based MDS as the Connection Type.  You will always use a database based MDS in your server environment.  Then select which database connection to use.  You probably wont have one set up yet, so click on the green plus icon to create one.

image

You need to enter the database connection details and give your connection a name, as shown below.  Once you have entered all the details, press the Test Connection button to check you have everything correct.  When you see the Success! message, click on OK to continue.

image

Select the connection you just created and then select the correct MDS partition to use.  If you don’t know which one to use, choose soa-infra.  Click on the Test Connection button to check you have everything correct.  When you see the Success! message, click on OK to continue.

image

Now you will be able to browse the MDS and view the artifacts in there.  You do this in the Resource Pallette.  If you don’t see it, you can open it from the View menu.  The diagram below shows our customer object in MDS.

image

Developers could now easily access and use the canonical data model from MDS.  Doing so will ensure that everyone is using the same versions of you data definitions and dramatically reduce testing and maintenance effort.  Enjoy!

Posted in Uncategorized | Tagged , , , , | 1 Comment

Finding which JAR contains a class – again!

I posted a few days ago about finding which JAR file contains a class file – something I often want to do.  My friend Chris Johnson promptly posted a better version here with caching – thanks Chris!

Chris said I inspired him to finish his script 🙂 and in return he has inspired me to improve it further.  As I often work with JAR files in a development environment, and often a lot of them, the search can take a while, so the caching is great.  But – those files can change over time, so I need the cache to be kept up to date.

Here is an updated version of Chris’ version that will update the cache if a JAR file is newer than the cache:

#!/bin/sh
TARGET="$1"

CACHEDIR=~/.jarfindcache

# prevent people from hitting Ctrl-C and breaking our cache
trap 'echo "Control-C disabled."' 2

if [ ! -d $CACHEDIR ]; then
    mkdir  $CACHEDIR
fi

for JARFILE in `find $PWD -name "*jar"`
do
  CACHEFILE=$CACHEDIR$JARFILE

  if [ ! -s $CACHEFILE ]; then
      mkdir -p `dirname $CACHEFILE`
      nohup jar tvf $JARFILE > $CACHEFILE
  # if the jar file has been updated, cache it again
  elif [ $JARFILE -nt $CACHEFILE ]; then
      nohup jar tvf $JARFILE > $CACHEFILE
  fi

  grep $TARGET $CACHEFILE > /dev/null
  if [ $? == 0 ]
  then
    echo "$TARGET is in $JARFILE"
  fi
done

P.S.  If you are running this on Ubuntu (or Debian), like me, you better make that first line a bit more explicit:

#!/bin/bash

Enjoy!

Posted in Uncategorized | Tagged | 1 Comment

Finding which JAR contains a class

I often want to search through a large number of JAR files looking for a particular class, and every time I do this I wish I had some utility to make it easier.  So I finally made one:

#!/bin/sh

TARGET="$1"

for i in `find . -name "*jar"`
do
  jar tvf $i | grep $TARGET > /dev/null
  if [ $? == 0 ]
  then
    echo "$TARGET is in $i"
  fi
done

Update: My colleague Chris Johnson just posted a better version of this, with some caching over at the Fusion Security Blog.

Posted in Uncategorized | Tagged | 2 Comments

Improving JMS Performance on WebLogic

WebLogic Server includes a feature called the ‘JMS Wrapper’ that you can take advantage of to dramatically improve the performance of JMS applications running on WebLogic Server.  Note that this is not for remote JMS clients, this is for JMS programs running on WebLogic Server, like Servlets or EJBs.

In this post, I will demonstrate how to use the JMS Wrapper to improve the performance of a Servlet based JMS application.  On my Mac Book Pro, I was able to process 1,000 messages in about 7 seconds on average without JMS Wrapper, and in about 1 second on average with JMS Wrapper.  That is about seven times faster.

To get this improvement, all that is required is to change the way we lookup the QueueConnectionFactory and Queue.  This means changing two lines of code, and adding some extra information to the deployment descriptors.  Not difficult at all.

So let’s walk through an example.  We will build two separate web applications, which are the same except that one will use the JMS Wrapper and the other will not.  The examples in this post were built using Maven 2, Java 1.6.0_20 and WebLogic 10.3.4 (64-bit) on Mac OS X 10.6.

You can download the completed projects from http://www.samplecode.oracle.com using the following Subversion command:

svn checkout https://www.samplecode.oracle.com/svn/jmswrapper

This will give you a new directory called jmswrapper which contains a directory called trunk which contains the two projects.  Each project has a Maven POM in its root directory so that you can build and test it.  You will need to update the POM to include your WebLogic Server details.  This will be covered below.

If you prefer to create the projects from scratch, you can follow through the instructions here.  In this example, we are using Maven to build, deploy and test the project.  If you don’t want to use Maven, you will need to run the appropriate commands to compile and package your applications and test code and deploy and execute them manually.

First, let’s create a project that does not use the WebLogic JMS Wrapper functionality.  We will use this as our base line, to compare performance against.

Create a new web application using Maven:

mvn archetype:generate

Select the webapp-javaee6 archetype and provide the coordinates to create your project.  I used the following:

groupId:    com.redstack
artifactId: jmsNoWrapper
version:    1.0_SNAPSHOT
package:    com.redstack

Next, we need to set up the Maven POM with the necessary dependencies for JMS and with information so we can deploy to WebLogic.  We will also configure Maven to execute our performance tests automatically for us.  Here is my POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.redstack</groupId>
    <artifactId>jmsNoWrapper</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>jmsNoWrapper Web App</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>com.oracle.soa</groupId>
          <artifactId>wlthinclient</artifactId>
          <version>11.1.1.4</version>
          <type>jar</type>
          <scope>compile</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <skip>true</skip>
                <!-- skip the default run so we dont run test twice -->
              </configuration>
              <executions>
                <execution>
                  <id>unit-tests</id>
                  <phase>test</phase>
                  <goals>
                    <goal>test</goal>
                  </goals>
                  <configuration>
                    <skip>false</skip>
                    <includes>
                      <include>**/*Test.java</include>
                    </includes>
                    <excludes>
                      <exclude>**/*IntegrationTest.java</exclude>
                    </excludes>
                  </configuration>
                </execution>
                <execution>
                  <id>integration-tests</id>
                  <phase>integration-test</phase>
                  <goals>
                    <goal>test</goal>
                  </goals>
                  <configuration>
                    <skip>false</skip>
                    <includes>
                      <include>**/*IntegrationTest.java</include>
                    </includes>
                  </configuration>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>com.oracle.weblogic</groupId>
              <artifactId>weblogic-maven-plugin</artifactId>
              <version>10.3.4</version>
              <configuration>
                <adminurl>t3://localhost:7001</adminurl>
                <user>weblogic</user>
                <password>welcome1</password>
                <name>jmsNoWrapper</name>
                <remote>true</remote>
                <upload>true</upload>
                <targets>myserver</targets>
              </configuration>
              <executions>
                <execution>
                  <id>deploy</id>
                  <phase>pre-integration-test</phase>
                  <goals>
                    <goal>deploy</goal>
                  </goals>
                  <configuration>
                    <source>target/jmsNoWrapper.war</source>
                  </configuration>
                </execution>
              </executions>
          </plugin>
        </plugins>
        <finalName>jmsNoWrapper</finalName>
    </build>

    <distributionManagement>
      <!-- use the following if you're not using a snapshot version. -->
      <repository>
        <id>local</id>
        <name>local repository</name>
        <url>file:///Users/mark/.m2/repository</url>
      </repository>
      <!-- use the following if you ARE using a snapshot version. -->
      <snapshotRepository>
        <id>localSnapshot</id>
        <name>local snapshot repository</name>
        <url>file:///Users/mark/.m2/repository</url>
      </snapshotRepository>
    </distributionManagement>

</project>

The first thing we need to do is add the WebLogic ‘thin client’ as a dependency.  I put it into my local Maven repository so that I can add it to the POM as follows:

        <dependency>
          <groupId>com.oracle.soa</groupId>
          <artifactId>wlthinclient</artifactId>
          <version>11.1.1.4</version>
          <type>jar</type>
          <scope>compile</scope>
        </dependency>

Before this will work, we need to put the JAR file into our local Maven repository using the following commands:

# cd <WL_HOME>/server/lib
# mvn install:install-file
  -Dfile=wlthinclient.jar
  -DgroupId=com.oracle.soa
  -DartifactId=wlthinclient
  -Dversion=11.1.1.4
  -Dpackaging=jar
  -DgeneratePom=true

You may want to choose different coordinates.  I put this in the same group as many of the other JAR files that I commonly use when writing code against SOA Suite or BPM Suite, so I used the same version and groupId I use for those libraries.

Next, we want to configure Maven to run our performance test for us after it has deployed the web application to WebLogic Server.  This is done using the following plugin section in the POM.

Here we are telling Maven that Java source files in our test directory that end with ‘Test’ are unit tests that should be run in the test phase, before packaging and deployment, and that Java source files that end with ‘IntegrationTest’ are integration tests that should be run in the integration-test phase, after deployment.

            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <skip>true</skip>
                <!-- skip the default run so we dont run test twice -->
              </configuration>
              <executions>
                <execution>
                  <id>unit-tests</id>
                  <phase>test</phase>
                  <goals>
                    <goal>test</goal>
                  </goals>
                  <configuration>
                    <skip>false</skip>
                    <includes>
                      <include>**/*Test.java</include>
                    </includes>
                    <excludes>
                      <exclude>**/*IntegrationTest.java</exclude>
                    </excludes>
                  </configuration>
                </execution>
                <execution>
                  <id>integration-tests</id>
                  <phase>integration-test</phase>
                  <goals>
                    <goal>test</goal>
                  </goals>
                  <configuration>
                    <skip>false</skip>
                    <includes>
                      <include>**/*IntegrationTest.java</include>
                    </includes>
                  </configuration>
                </execution>
              </executions>
            </plugin>

Finally, we have the following plugin section that configures deployment to WebLogic.  You will need to have the WebLogic Maven plugin installed to use this.  See this post for details.  The configuration should be reasonably self explanatory.  The name element is the name of the web application on WebLogic server and targets is the name of the server/cluster to deploy the application to.  Note that the name of the target WAR file is listed in the source element.

            <plugin>
              <groupId>com.oracle.weblogic</groupId>
              <artifactId>weblogic-maven-plugin</artifactId>
              <version>10.3.4</version>
              <configuration>
                <adminurl>t3://localhost:7001</adminurl>
                <user>weblogic</user>
                <password>welcome1</password>
                <name>jmsNoWrapper</name>
                <remote>true</remote>
                <upload>true</upload>
                <targets>myserver</targets>
              </configuration>
              <executions>
                <execution>
                  <id>deploy</id>
                  <phase>pre-integration-test</phase>
                  <goals>
                    <goal>deploy</goal>
                  </goals>
                  <configuration>
                    <source>target/jmsNoWrapper.war</source>
                  </configuration>
                </execution>
              </executions>
          </plugin>

You should also add a distributionManagement section as shown in the example above.

To check you have everything set up right, you can run a deploy:

# mvn deploy

This will compile everything, run the tests (if we had any), package up a WAR file, deploy it to WebLogic and then run the integration tests (if we had any – we will write one soon).  You should then be able to see the application deployed on WebLogic.  You can check by looking at the Deployments in the WebLogic Server console.  You should be able to access that on your machine at http://yourmachine:7001/console – you will need to substitute the correct name and port for your machine.  You should also be able to run the web application by going to http://yourmachine:7001/jmsNoWrapper – again substitute in the correct name and port for your environment.  You should see a blank page with the message ‘Hello World!’ on it.  This is the default page created by Maven.

So now we have everything set up, let’s write a Java Servlet that will send a JMS message.  Later we will write an integration test that will run this Servlet 1,000 times and measure the performance.

Here is the code for the Servlet.  This goes in src/main/java/com/redstack/JMSServlet.java:

package com.redstack;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import javax.jms.QueueConnectionFactory;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueSession;
import javax.jms.QueueSender;
import javax.jms.TextMessage;
import javax.jms.JMSException;

public class JMSServlet extends HttpServlet {

  @Override
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
  }

  public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html><head><title>JMSServlet</title></head><body><h1>JMS Wrapper Demo</h1>");

    QueueConnection conn = null;

    try {
      InitialContext ctx = new InitialContext();
      QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("jms/QCF");
      Queue queue = (Queue) ctx.lookup("jms/myQueue");
      ctx.close();
      conn = qcf.createQueueConnection();
      QueueSession session = conn.createQueueSession(false, 0);
      QueueSender sender = session.createSender(queue);
      TextMessage msg = session.createTextMessage("this is a test message");
      sender.send(msg);
    } catch (Exception ignore) {}
    try {
      conn.close();
    } catch (Exception ignore) {}

    out.println("</body></html>");
    out.close();
  }

  public void destroy() {}

}

This is a simple, standard Java Servlet that implements the doGet() method, which will be executed when WebLogic receives a request the Servlet’s URL – we will set that up shortly.

The Servlet just prints out some HTML and sends a JMS message.  You can see in there the bare essential code to send a JMS message.  This code is based on the JMS client found in this post.  In order to run this, we will need to set up some JMS resources on WebLogic Server – we will come to that shortly.

Notice that we create the QueueConnectionFactory, Queue, QueueSender, etc. every time and then close the QueueConnection when we are finished.  This is standard JMS practice, nothing specific to WebLogic.

We need to register our Servlet in the application’s standard Java deployment descriptor, web.xml.  This file is located in src/main/webapp/WEB-INF/web.xml.  Here is mine:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="worklist" version="2.5">
  <display-name>JMS Wrapper Example</display-name>

  <servlet>
    <servlet-name>JMSServlet</servlet-name>
    <servlet-class>com.redstack.JMSServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>JMSServlet</servlet-name>
    <url-pattern>/JMSServlet</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>

</web-app>

Here we map the Servlet to the URL /JMSServlet inside the web application, i.e. http://yourmachine:7001/jmsNoWrapper/JMSServlet.

If you like, you can put a link on the web application’s home page, stored in src/main/webapp/index.jsp, so that you can manually run the Servlet from a browser.  I added the following to the HTML BODY:

<h1>JMS Wrapper Demo</h1>
<a href="JMSServlet">Send some messages</a>

Finally, we need to write our Integration Test to measure the performance of the Servlet.  Create a new file src/test/java/com/redstack/PerformanceIntegrationTest.java.  Here is the code for this class:

package com.redstack;

import junit.framework.TestCase;
import java.net.URL;
import java.net.URLConnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class PerformanceIntegrationTest extends TestCase {

  public void testHandleRequestView() throws Exception {

    System.out.println("+++ This is the performance test +++");

    long start = System.nanoTime();
    // hit the page 1000 times
    for (int i = 0; i < 1000; i++) {
      URL thePage = new URL("http://localhost:7001/jmsNoWrapper/JMSServlet");
      URLConnection conn = thePage.openConnection();
      BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
      String inputLine;
      while ((inputLine = in.readLine()) != null) {
        // read the whole page
      }
      in.close();
    }
    long end = System.nanoTime();

    System.out.println("Hit the page 1000 times, sending 1000 messages with full open/close\n"
      +"of JMS objects, taking " + (end - start) / 1000000 + " milliseconds.");
    assertEquals("hello", "hello");

  }

}

This class will be run in the integration-test phase of the build, after the deployment of the application to WebLogic.  It will run the Servlet 1,000 times and print out the time taken in milliseconds to process the 1,000 messages.  We will see this in the output from Maven when we do a deployment.

Now let’s set up the JMS resources we need on WebLogic Server.  I used the ZIP distribution (discussed in this post).  Depending how you installed WebLogic, you may already have some of these resources.  If they are already there, go ahead and use the ones you have, otherwise create new ones.

Log in to the WebLogic Server console using your administrative user (probably weblogic) and go to the JMS Servers page by clicking on the link under Services or using the navigation tree on the left hand side.

Click on the New button to create a JMS Server.

Enter a name for your JMS Server.  I called mine JMSServer1.  Then click on Next.

Choose the server that you want this JMS Server deployed on.  If you are using the ZIP distribution like me, you will only have one to choose from.  Then click on Finish.

Now we need to create a JMS Module.  Go back to the Home page and click on the link for JMS Modules under Services or use the navigation tree on the left hand side.

Click on the New button to create a new JMS Module.  Enter a name for your JMS Module and then click on Next.  I called mine JMSModule1.

Select the server you want to target this JMS Module to then click on Next.

Now click on Finish.

Navigate to your new JMS Module – which will now be listed on the JMS Modules page – and click on the link to view the settings, as shown below.  Then click on the New button to create a new resource.

We need to create a Connection Factory first.  Select Connection Factory from the list and click on Next.

Enter a name and JNDI name for the Connection Factory.  These need to match the code.  You should use the same names as shown here, or update your Servlet code if you use different names.  I called mine QCF and jms/QCF as shown below.  Click on Next.

Select the target and click on Finish.  You should only have the one target listed.

We also need to create the Queue.  Return to the setting pages for your JMS Module again and click on New.  Choose Queue from the list and click on Next.  Enter a name and JNDI name for your queue as shown.  These also need to match the Servlet code.  I used myQueue and jms/myQueue.  Click on Next.

Click on the Create a New Subdeployment button (you only need to do this the first time – if you create additional queues later on you will not need to repeat this step).

Enter a name for your new subdeployment and click on OK.  I called mine subdeployment1.

Now choose the subdeployment and target for the queue and click on Finish.

If you return to the settings page for your JMS Module, you will now see the new resources listed as shown below.

That’s all the JMS configuration we need to do for this example.  Now we are ready to deploy our application.  From the jmsNoWrapper directory, issue the following command:

# mvn deploy

This will build and deploy our application, and run the performance test.  You will see the results of the performance test in the Maven output.  Here is an example of the relevant part of the output:

[INFO] [surefire:test {execution: integration-tests}]
[INFO] Surefire report directory: /Users/mark/src/jmsNoWrapper/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.redstack.PerformanceIntegrationTest
+++ This is the performance test +++
Hit the page 1000 times, sending 1000 messages with full open/close
of JMS objects, taking 7148 milliseconds.
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.213 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

You can run this a few times to repeat the test.  On my machine I got the following results from four consecutive runs: 7148ms, 8773ms, 5140ms, 6274ms, giving an average of 6834ms.

So now we have a base line to compare against.  Let’s create a project that does use the JMS Wrapper and compare the performance.

If you grabbed the code from our Subversion repository (see above) then just take a look in the trunk/jmsWrapper directory.  If you are building your own from scratch, they could can just copy your whole jmsNoWrapper directory and name the copy jmsWrapper.  There are only a few changes we need to make.

In the POM, we need to update the name of the application.  Here is the new POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.redstack</groupId>
    <artifactId>jmsWrapper</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>jmsWrapper Web App</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>com.oracle.soa</groupId>
          <artifactId>wlthinclient</artifactId>
          <version>11.1.1.4</version>
          <type>jar</type>
          <scope>compile</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <skip>true</skip>
                <!-- skip the default run so we dont run test twice -->
              </configuration>
              <executions>
                <execution>
                  <id>unit-tests</id>
                  <phase>test</phase>
                  <goals>
                    <goal>test</goal>
                  </goals>
                  <configuration>
                    <skip>false</skip>
                    <includes>
                      <include>**/*Test.java</include>
                    </includes>
                    <excludes>
                      <exclude>**/*IntegrationTest.java</exclude>
                    </excludes>
                  </configuration>
                </execution>
                <execution>
                  <id>integration-tests</id>
                  <phase>integration-test</phase>
                  <goals>
                    <goal>test</goal>
                  </goals>
                  <configuration>
                    <skip>false</skip>
                    <includes>
                      <include>**/*IntegrationTest.java</include>
                    </includes>
                  </configuration>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>com.oracle.weblogic</groupId>
              <artifactId>weblogic-maven-plugin</artifactId>
              <version>10.3.4</version>
              <configuration>
                <adminurl>t3://localhost:7001</adminurl>
                <user>weblogic</user>
                <password>welcome1</password>
                <name>jmsWrapper</name>
                <remote>true</remote>
                <upload>true</upload>
                <targets>myserver</targets>
              </configuration>
              <executions>
                <execution>
                  <id>deploy</id>
                  <phase>pre-integration-test</phase>
                  <goals>
                    <goal>deploy</goal>
                  </goals>
                  <configuration>
                    <source>target/jmsWrapper.war</source>
                  </configuration>
                </execution>
              </executions>
          </plugin>
        </plugins>
        <finalName>jmsWrapper</finalName>
    </build>

    <distributionManagement>
      <!-- use the following if you're not using a snapshot version. -->
      <repository>
        <id>local</id>
        <name>local repository</name>
        <url>file:///Users/mark/.m2/repository</url>
      </repository>
      <!-- use the following if you ARE using a snapshot version. -->
      <snapshotRepository>
        <id>localSnapshot</id>
        <name>local snapshot repository</name>
        <url>file:///Users/mark/.m2/repository</url>
      </snapshotRepository>
    </distributionManagement>

</project>

We also need to update the src/main/webapp/WEB-INF/web.xml to include a resource-ref to point to the JMS resources we want to use.  Here is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="worklist" version="2.5">
  <display-name>JMS Wrapper Example</display-name>

  <servlet>
    <servlet-name>JMSServlet</servlet-name>
    <servlet-class>com.redstack.JMSServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>JMSServlet</servlet-name>
    <url-pattern>/JMSServlet</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>

  <resource-ref>
    <res-ref-name>jms/wrappedQCF</res-ref-name>
    <res-type>javax.jms.QueueConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
  </resource-ref>

  <resource-env-ref>
    <resource-env-ref-name>jms/wrappedQueue</resource-env-ref-name>
    <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
  </resource-env-ref>

</web-app>

Notice that we define a resource called jms/wrappedQCF which is a javax.jms.QueueConnectionFactory, and a resource called jms/wrappedQueue which is a javax.jms.Queue.

We also need to create a WebLogic deployment descriptor that maps these to the real resources.  Create a file called src/main/webapp/WEB-INF/weblogic.xml.  Here are the contents for this file:

<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 9.1//EN"
 "http://www.bea.com/servers/wls810/dtd/weblogic 810-web-jar.dtd">
<weblogic-web-app>
  <context-root>/jmsWrapper</context-root>
  <jsp-descriptor>
    <page-check-seconds>1</page-check-seconds>
  </jsp-descriptor>
  <resource-description>
    <res-ref-name>jms/wrappedQCF</res-ref-name>
    <jndi-name>jms/QCF</jndi-name>
  </resource-description>
  <resource-env-description>
    <res-env-ref-name>jms/wrappedQueue</res-env-ref-name>
    <jndi-name>jms/myQueue</jndi-name>
  </resource-env-description>
</weblogic-web-app>

In this file we define the mappings from the names we just defined in the web.xml to the real resource names.  You can see here we define that jms/wrappedQCF is really jms/QCF and jms/wrappedQueue is really jms/myQueue.

The presence of these settings is what tells WebLogic Server to enable the JMS Wrapper functionality.  So having these settings here in the deployment descriptor, and using the names defined in the web.xml to look up the resources will give you the performance improvements.

You need to change the Servlet code to use the indirect names.  The two lines that need to be changed are the lookups:

      QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("jms/wrappedQCF");
      Queue queue = (Queue) ctx.lookup("jms/wrappedQueue");

Finally, we need to change the URL in our Integration Test to point to the new application.  The line we need to change is as follows:

       URL thePage = new URL("http://localhost:7001/jmsWrapper/JMSServlet");

You can now deploy the new version of the application that uses the JMS Wrapper by executing the following command from the jmsWrapper directory:

# mvn deploy

Again, you will see the results of the performance test in the Maven output.  On my machine I got the following results from four consecutive tests: 1048ms, 1047ms, 1017ms, 1045ms, giving and average of 1039ms.

So by making a couple of simple changes, we improved the performance of our JMS Servlet by around seven times, from 6834ms for 1,000 messages to only 1039ms (on average).

Notice that we need to close the connection in our Servlet.  This is important.  If we don’t do that, WebLogic will not know that that connection is available to be returned to the pool for reuse.

If you want to learn more about JMS on WebLogic, you might like to start with the documentation here or take a look at Chapter 10 of Professional Oracle WebLogic Server by Robert Patrick et al.  Enjoy!

Posted in Uncategorized | Tagged , , , | Leave a comment

Recommended patch for BPM and SOA 11.1.1.3 users

If you are using SOA Suite or BPM Suite 11.1.1.3 and you are not planning to upgrade to 11.1.1.4 just yet, you are strongly encouraged to install “Bundle Patch 2.”  The patch number is 12700861 and you can find information and instructions on My Oracle Support in document number 1288864.1.

Posted in Uncategorized | Tagged , | 1 Comment

Deploying WebLogic applications with Maven

In my last post, I talked about one exciting new feature in WebLogic 11g, support for Mac OS X.  Now, I want to cover another exciting new feature – a Maven plugin which allows you to incorporate deployment of your applications to WebLogic into your Maven builds.

I love this new feature because it makes it so easy to compile all my Java source and web artefacts, build a deployment archive and deploy it WebLogic Server in one easy action!  I hope you like it too!

A big thank you to Steve Button for bringing this to my attention, helping me to get it working on Mac OS X and sharing some helpful hints and tips.

Setting up the plugin

First, let’s set up the Maven plugin.  You will need WebLogic Server 10.3.4 installed to do this.  I used the convenient new ‘ZIP Distribution’ which is built for developers.  I used Maven 2.2.1 and JDK 1.6 on Mac OS X 10.6 to write this article.

First, we need to create the plugin using the wljarbuilder utility.  Execute the following commands from your WebLogic home directory:

# cd <WL_HOME>/wlserver/server/lib
# java -jar wljarbuilder.jar -profile weblogic-maven-plugin

This will create a new file called weblogic-maven-plugin.jar in that same directory.  Next, we need to extract the Maven POM from the jar file, and place it in the same directory.  You may want to extract it into a temporary directory and then move it.

# jar xvf <WL_HOME>/wlserver/server/lib/weblogic-maven-plugin.jar META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml
# mv META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml <WL_HOME>/wlserver/server/lib

Before installing the WebLogic Maven plugin into your local repository, it is important to make sure all of the necessary dependencies have been downloaded.

# cd <WL_HOME>/wlserver/server/lib
# mvn install

Note: before you continue, if you want to use the WebLogic plugin from the command line, you might want to set up a short name so you can type shorter goal names.  You have to do this now, before you continue.  To set up a short name, weblogic, you will need to add the following entries to your ~/.m2/settings.xml Maven configuration file…

<pluginGroups>
  <pluginGroup>com.oracle.weblogic</pluginGroup>
</pluginGroups>

… and add the following to the pom.xml that you just extracted into your <WL_HOME>/wlserver/server/lib directory.

<build>
  <plugins>
    <plugin>
      <artifactId>maven-plugin-plugin</artifactId>
      <version>2.3</version>
      <configuration>
        <goalPrefix>weblogic</goalPrefix>
      </configuration>
    </plugin>
  </plugins>
</build>

Now we can install the plugin.  You must run mvn install first to make sure it downloads the dependencies and recognises the prefix we have defined.

# mvn install
# mvn install:install-file -Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml

The plugin will now be available for use.  We can execute the ‘help’ goal to test it:

# mvn com.oracle.weblogic:weblogic-maven-plugin:help

Or, if you set up the short name:

# mvn weblogic:help

Using the plugin to deploy an application

Probably the most convenient way to use the WebLogic Maven plugin, is to incorporate it into your standard build.  Let’s look at how we can set up a project to compile, test, package and deploy to WebLogic by simply typing mvn deploy.

First, create a new Maven project.  I used mvn archetype:generate, selected the webapp-javaee6 template, and provided the necessary details.  I called my project wldemo.

We need to add a few items to the pom.xml to tell Maven to deploy the application to WebLogic.

<plugin> 
  <groupId>com.oracle.weblogic</groupId>
  <artifactId>weblogic-maven-plugin</artifactId>
  <version>10.3.4</version>
  <configuration>
    <adminurl>t3://localhost:7001</adminurl>
    <user>weblogic</user>
    <password>password</password>
    <name>wldemo</name>
    <remote>true</remote>
    <upload>true</upload>
    <targets>AdminServer</targets>
  </configuration>
  <executions>
    <execution>
      <id>deploy</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
      <configuration>
        <source>target/wldemo.war</source>
      </configuration>
    </execution>
  </executions>
</plugin>
...
<distributionManagement>
  <!-- use the following if you're not using a snapshot version. -->
  <repository>
    <id>local</id>
    <name>local repository</name>
    <url>file:///Users/mark/.m2/repository</url>
  </repository>
  <!-- use the following if you ARE using a snapshot version. -->
  <snapshotRepository>
    <id>localSnapshot</id>
    <name>local snapshot repository</name>
    <url>file:///Users/mark/.m2/repository</url>
  </snapshotRepository>
</distributionManagement>

You will have to update the settings to match your environment, as follows:

Setting      Meaning
-----------  ----------------------------------------
adminurl     WebLogic T3 URL for your Admin Server
user         WebLogic administrative user
password     WebLogic administrative user's password
name         Name of application
remote       Indicates a remote server
upload       Indicates the war file must be uploaded
targets      The server, cluster, etc. to deploy to

In addition to the WebLogic settings in the plugins section, you need to set up the distributionManagement section to point to your local repository so that the deploy phase can run successfully.

Now we are ready to build, test and deploy our application!  In real life, you might want to write some code first – but for this example, we will just use the simple JSP page that comes in the template.

# mvn deploy

After a few moments, you application will be built and deployed.  You can see it right there in the WebLogic Server console:

You can now hit the application at http://yourserver:7001/wldemo.  You should get a clean page with the message ‘Hello World!

Now you can make changes and quickly and easily deploy them to your server for testing with a single, simple command!  The plugin will also let you start and stop applications and undeploy them.

Enjoy!

Where to find more information

You might want to read over the documentation here for more details on the goals and parameters that are available in the plugin.

Posted in Uncategorized | Tagged , | 7 Comments

Installing WebLogic Server on Mac OS X

One of the exciting new features in WebLogic Server 11g is support for Mac OS X.  The new ‘ZIP Distribution’ of WebLogic Server allows developers to run WebLogic Server on Mac OS X.  The download file is much smaller and the install is much faster than downloading JDeveloper, which also includes WebLogic Server that can be used on the Mac.

To install Weblogic Server on your Mac, follow these steps.

First, you need to download WebLogic Server 11g (10.3.4) ZIP Distribution from OTN.

Unzip this into new directory, which we will call MW_HOME.  I created a directory called WebLogic/Middleware in my home directory.

# mkdir ~/WebLogic
# cd ~/WebLogic
# mkdir Middleware
# cd Middleware
# unzip ../Downloads/wls1034_dev.zip 

Run the configuration script to setup WebLogic Server.

# export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
# export MW_HOME=/Users/mark/WebLogic/Middleware
# ./configure.sh
# export USER_MEM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"
# . wlserver/server/bin/setWLSenv.sh

Start WebLogic Server for the first time and create a domain.

# cd ~/WebLogic
# mkdir domain
# cd domain
# java –Xmx1024m –XX:MaxPermSize=256m weblogic.Server

WebLogic will notice this is the first time it has been started and will ask you if you want to create a domain.  Answer ‘y’ to this question, and then provide a username and password when requested.

Would you like the server to create a default configuration and boot? (y/n): y
Enter username to boot WebLogic server: weblogic
Enter password to boot WebLogic server: password
For confirmation, please re-enter password required to boot WebLogic server: password

WebLogic Server will start up.  When it is up you will see a message indicating that the server was started in RUNNING mode.  Once you see this, you can shut it down (type Ctrl-C).

You can now use the startup scripts in your newly created domain.  When you want to start WebLogic Server, enter the following commands (you might want to create a script to do this):

# export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
# export MW_HOME=/Users/mark/WebLogic/Middleware
# export USER_MEM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"
# . /Users/mark/WebLogic/Middleware/wlserver/server/bin/setWLSenv.sh
# /Users/mark/WebLogic/domain/startWebLogic.sh

Note:  If you copy and paste this, you may need to make sure that characters like “ and – are correct – when I pasted into terminal I got some incorrect characters.  You may also want to adjust the memory settings to suit your machine, and you might want to consider some of the other recommended JVM settings here.

You can now log on to the WebLogic Server console at http://yourmac:7001/console

Enjoy!

Posted in Uncategorized | Tagged , | 5 Comments

Changing the default editor/view in JDeveloper

If you work a lot with complex ADF pages in JDeveloper, you may get tired of waiting for it to open your pages in the Design view, I know I do!  Fortunately, there is a simple solution.  You can change the default editor so that they will open in source view (which is very fast) and then you can switch to design view only when you actually want to.

To do this, select Preferences from the Tools menu, then select File Types in the navigation tree on the left hand side.  Open the Default Editors tab on the right, find JSP Source and change the default editor to Source using the drop down box at the bottom.  Then click on OK.

image

You can also do this for other types of files.

Posted in Uncategorized | Tagged , , | 3 Comments

Using Oracle XE with BPM 11.1.1.4

If you want to use the Oracle XE database in your development/test environments with BPM 11.1.1.4, you will need to make sure to follow the advice on the download page:

If you want to use XE you can set the RCU_JDBC_TRIM_BLOCKS environment variable to TRUE *prior* to running RCU.  As a reminder as to support level, when running RCU against XE you will receive a warning stating that the database version is not supported by Oracle.

If you do not follow this advice, you will get a few invalid objects in the database.  Remember that XE will work fine for development environments, but it is not actually a supported database for the BPM repository.  In production, you should use one of the supported databases.

Posted in Uncategorized | Tagged , , | 1 Comment