I was recently involved in setting up the infrastructure for deploying web applications into Websphere App Server(WAS) v6.1. As a "weblogic bee", this is was something new to me. But over all, the experience was really great.
The tasks involved in the whole process is given below:
1) Installation of WAS6.1
2) Creating profile called appProfile using Profile Management Tool (in weblogic we create "domains" using domain config wizard)
3) Started the profile
4) Created connection pools, data sources
5) Resource reference mapping.
6) Implement custom user registry.
7) Deploy Web applications.
8) Map security role to user/group mapping.
After doing all of the above tasks, application would not connect to Data base using data source connection. It was throwing exceptions in the logs. It took couple of days to figure it out Websphere needs user name/password while creating connection. So login credentials can be passed
a) programmatically but this is a bad idea as hard coding user id/password in the application code.
b) create authentication alias mapping to a user name/password in websphere admin console
So this alias name must be mapped while creating data source itself..
ooooph! Finally it worked.
P.S:
If you don't create an alias while establishing connection using data source in Websphere 6.1 you may end up getting this error below:
Authentication Alias Websphere JNDI Data source Exception Connection Failed SQLException null userid is not supported. errorcode 4461
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.
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.
Labels:
Weblogic
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
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.
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\Services5. 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.
Labels:
Weblogic
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.
<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.
Labels:
Weblogic
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
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
Labels:
Maven 2
Subscribe to:
Posts (Atom)
