Beware of StringUtils.containsIgnoreCase method in weblogic10.3

In one of the web applications we use Apache commons-lang API version 2.3. We have put this library as part of web-inf/lib of the web application. But Weblogic10.3 also has it own version(2.1.0) under $BEA_home\module folder. So there was a conflict but weblogic would not throw any error :) We use StringUtils.containsIgnorecase() in one of the java classes. When this method is getting called weblogic simply hung.

So we had to tell weblogic to load classes from web-inf not from original class loader. So in weblogic.xml we need to set prefer-web-inf-classes flag to true. This tells weblogic to load classes from web-inf folder first.

weblogic.xml:

    <container-descriptor>
      <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>   

This fixed the issue. I will take that.

P.S:  For some web applications doing the above change might not help. In that case, commons-lang-2.4.jar needs to be added to PRE_CLASSPATH in domain's setDomainEnv.cmd. This should fix the issue.
set PRE_CLASSPATH=C:\temp\commons-lang-2.4.jar;
If you are running as a windows service, the jar needs to be added to beginning of the classpath.

Create weblogic as a windows service

By making entry in windows registry we can create weblogic server instance as windows service. To do this, we need to create a script which will have weblogic server-specific variables like domain name, server name, etc. This script calls master script called installSvc.cmd(${bea_dir}\wlserver_10.3\server\bin).

Here are the steps:
1. Go to${bea_dir}\wlserver_10.3\server\bin where bea_dir is home directory of weblogic installation.

2. Create a file called createSvc.cmd with following values: please make sure you mention the right domain name, path and admin server instance name. Also check the path of installSvc.cmd it varies from one version to other.
    echo off
    SETLOCAL
    set DOMAIN_NAME=sampleDomain
    set USERDOMAIN_HOME=c:\bea\user_projects\domains\sampleDomain
    set SERVER_NAME=Adminserver_name
    set PRODUCTION_MODE=false

    set JAVA_VENDOR=Sun
    set JAVA_HOME=C:\bea\jdk160_05
    set MEM_ARGS=-Xms256m -Xmx512m
    call "c:\bea\wlserver_10.3\server\bin\installSvc.cmd"
    ENDLOCAL


3. Execute createSvc.cmd script from same folder c:\bea\wlserver_10.3\server\bin\

4. This should create service with name of "beasvc sampleDomain_Adminserver_name" in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

5. Also, if you go to services under Control panel, you should see the service with above name. Click the service to start. If you don't see it, there is some problem or sure. Check the path of domain and other variables in createSvc script.

6. Also if there is an issue with start up, you may check the Admin server logs under domain.
Good luck. Let me know  if you are running into any issues.

How to change the default service name?
As you know this script internal calls installSvc.cmd to create a windows service, this will prefix default "beasvc domain_name Adminserver....". To remove this prefix and have a custom service name, edit installSvc.cmd and look for beasvc and change the name you wanted to.
"%WL_HOME%\server\bin\beasvc" -install -svcname:"beasvc %DOMAIN_NAME%_%SERVER_NAME%" -javahome:"%JAVA_HOME%" -execdir:"%USERDOMAIN_HOME%" -maxconnectretries:"%MAX_CONNECT_RETRIES%" -host:"%HOST%" -port:"%PORT%" -extrapath:"%EXTRAPATH%" -password:"%WLS_PW%" -cmdline:%CMDLINE%

How to remove server instance as a windows service:
Create a script called removeSvc.cmd and copy the following lines. Make sure adminServer name & domain name values are correctly set. And execute from the same place(c:\bea\wlserver_10.3\server\bin) where you created window service before.

echo off
SETLOCAL
set DOMAIN_NAME=sampleDomain
set SERVER_NAME=AdminServer
call "c:\bea\wlserver_10.3\server\bin\uninstallSvc.cmd"
ENDLOCAL

P.S: The name should be matching with the name given at the time of creating service in installSvc.cmd.

Applet throwing class not found exception in Weblogic

I was getting some weird error (only in) weblogic when I try to load home page(applet) of web application. Home page was nothing but index.jsp which uses tag to load an applet. This applet needs a lot of libraries as part of archive values.

<jsp:plugin  type="applet" name="CDApplet" code="com.cd.applet.Applet.class" codebase="." width="100" height="100" align="middle" jreversion="1.5">
  <jsp:param name="id" value="CDApplet"/>
  <jsp:param name="code" value="com.cd.applet.Applet"/>
  <jsp:param name="codebase" value="."/>
  <jsp:param  name="archive" value="crimson.jar,commons-lang-2.3.jar,jdom.jar,jfreechart-0.9.16.jar,picocontainer-1.0-beta-5.jar,commons-collections-3.2.jar,jaxen-core.jar,saxpath.jar,jaxen-jdom.jar" />
</jsp:plugin>


The above code was NOT working as you see the archive values are sent as parameter. This seems to be okay with Tomcat but somehow weblogic 10.3 could not recognize that. It was throwing Applet Class Not Found Exception. It was really freaking me out. Then I tried this, instead of passing as an argument, I set archive values as part of the tag itself. Example given below:

<jsp:plugin  type="applet" name="CDApplet" code="com.cd.applet.Applet.class" codebase="." width="100" height="100" align="middle" jreversion="1.5" archive="cd-applet.jar, commons-collections-3.2.jar,jaxen-core.jar,saxpath.jar,jaxen-jdom.jar">
  <jsp:param name="id" value="CDApplet"/>
  <jsp:param name="code" value="com.cd.applet.Applet"/>
  <jsp:param name="codebase" value="."/>
 </jsp:plugin>


This worked. What a relief! By the way,  this code change worked in Tomcat as well.

Adios.

Xdoclet on Maven2 NOT generating Struts Config XML

I have recently involved in a migrating existing projects from maven1.2 to maven2. We used maven-xdoclet-plugin for generating struts config xml file. This plug-in used to work OK in maven1.x but failed in maven2. It was not generating those actions & forms properly in struts config xml file.

I recently found a fix (thanks to Google) for this (and it is working) in the form of maven antrun plug-in.

For more info or to see the actual code snippet, please do visit this blog

Difference between DEV and PROD mode in Weblogic 10.3

Development mode:
The default JDK for development domain is Sun Hotspot
You can use the demo certificates for SSL
Auto deployment is enabled
Server instances rotate their log files on startup
Admin Server uses an automatically created boot.properties during startup
The default maximum capacity for JDBC Datasource is 15
The debugFlag which is used to start the WebLogic Workshop Debugger is enabled

Production mode:
The default JDK for production domain is JRockit
If you use the demo certificates for SSL a warning is displayed
Auto deployment is disabled
Server instances rotate their log files when it reaches 5MB
Admin Server prompts for username and password during startup
The default maximum capacity for JDBC Datasource is 25
The debugFlag which is used to start the WebLogic Workshop Debugger is disabled.

If you would like to know how to change to weblogic start up mode from DEV to PROD or vice versa. please visit this entry.