Sunday, August 28, 2011

WebLogic: NodeManager for Linux Machines

I recently needed to set up Node Manager on a Linux machine.  I was surprised that I wasn’t able to find the documentation that I needed in order to configure it properly, and gave up after a few minutes of searching for the right scripts and articles on the web. 

When I had more time I decided to take another look.  After about an hour of fiddling and searching I got it working as an xinetd service on my Linux machine.  However, I still couldn’t find a good online reference so I decided to create one Smile

What is the Node Manager?

The Node Manager is a process that can be configured to run on machines where WebLogic is installed.  It serves the purpose of starting and stopping Managed Servers of WebLogic domains.  The goal of this process is to ease management of WebLogic domains by allowing you to remotely start and stop Managed Servers.  With the Node Manager you can log into the Admin Console for the domain and select the instances you want to start and stop:

SNAGHTML2e7639

 

One of the great things about the Node Manager is that you can change the classpath and startup (Java) options for your managed servers from the Admin Console as well.  This can be useful when you are troubleshooting a node and adding debug flags, temporary server options, etc:

image

How does it work?

The NodeManager for WebLogic operates in one of two ways:

  • Java Node Manager – This blog post is focused on the Java Node Manager.  This runs as a JVM process on the machine(s) where you have WebLogic Managed Servers or Coherence Cache Servers you want to use with Node Manager.  It defaults to listen on port 5556 and receives requests from the Admin Server to start and stop Managed Servers and Coherence Cache Servers.  This should be set up to run as a System Service such that when the machine is rebooted the service will be restarted as well.
  • Script Based Node Manager – The Script-based node manager uses SSH and shell scripts to start server processes on Machines.  The script-based node manager is not the focus of this article.

 

Making it work on Linux

I had a challenge making the Node Manager work on Linux.  It required a fair amount of troubleshooting and manual steps to get it to work.  Here’s what I did:

1. Investigate the Windows scripts to install the Java Node Manager as a service:

I had gotten the Node Manager to work on Windows several times in the past and it was easy & straightforward.  In order to get it to work on Linux I decided to see how it worked on Windows.

The Windows installation of WebLogic includes scripts to install the Node Manager as a service.  You can find them here: <WL_HOME>/server/bin (C:\Oracle\Middleware\wlserver_10.3\server\bin).  I observed these key lines:

image

Here you can see the listen address & port being set as well as the Java startup class for the Node Manager. 

2. This seemed simple enough, so I translated this to a Linux/Unix shell script:

#!/bin/sh
export NODEMGR_HOME=${WL_HOME}/common/nodemanager
export NODEMGR_OUT=${NODEMGR_HOME}/nodemanager.out
#export NODEMGR_HOST=localhost
export NODEMGR_PORT=5556
export MEM_ARGS="-Xms32m -Xmx200m"
export JAVA_OPTIONS="-Djava.security.policy=${WL_HOME}\server\lib\weblogic.policy\ -Dweblogic.nodemanager.javaHome=${JAVA_HOME}"
. ${WL_HOME}/common/bin/commEnv.sh
export CLASSPATH=${WEBLOGIC_CLASSPATH}
if [ "${JAVA_VENDOR}" = "BEA" ] ; then
  export JAVA_VM="-jrockit"
fi
if [ "${JAVA_VENDOR}" = "Sun" ] ; then
  export JAVA_VM="-server"
fi
if [ "${NODEMGR_HOST}" != "" ] ; then
  JAVA_OPTIONS="${JAVA_OPTIONS} -DListenAddress=${NODEMGR_HOST}"
fi
if [ "${NODEMGR_PORT}" != "" ] ; then
  JAVA_OPTIONS="${JAVA_OPTIONS} -DListenPort=${NODEMGR_PORT}"
fi
COMMAND_LINE="${JAVA_HOME}/bin/java ${MEM_ARGS} -classpath ${CLASSPATH} ${JAVA_OPTIONS} weblogic.NodeManager"
echo "Starting Node Manager in directory=${NODEMGR_HOME} with command line=[${COMMAND_LINE}]"
cd ${NODEMGR_HOME}
nohup ${COMMAND_LINE} >${NODEMGR_OUT}   2>&1 &
echo "Node Manager Output written to ${NODEMGR_OUT}"

I ran this and it worked, but it did not use <WL_HOME>/common/nodemanager as the home directory so it didn’t find nodemanager.domains or nodemanager.properties, so I added the ‘cd ${NODEMGR_HOME} line and then it worked fine.  At this point I was able to test that it was working by starting and stopping my servers (WebLogic and Coherence) from the admin console.  Success!  Only one problem, though, it wasn’t configured as a service.


3. Configure Node Manager as an xinetd service


You may be thinking “but xinetd doesn’t use scripts like the one you created”, and you’re correct!  After looking through the documentation I found this example on setting up an xinetd service:



image


Not knowing anything about xinetd (clearly) I set out to learn how to make this work.  Since its in the documentation, this must be the recommended way to do it, right?  It is here that I noticed the ‘NodeManagerHome’ Java option so I could run my command from anywhere and have Node Manager find the right configuration files.  This also makes the nodemanager.log file wind up in the NodeManager Home directory as well.


I started out replacing the things that seemed obvious. Clearly ‘server’ is referring to the Java executable and I knew what the CLASSPATH was supposed to be based on my investigation with the script I created above. I didn’t know why I needed the LD_LIBRARY_PATH so I just took that out (mistake, and we’ll see why later).  I created a file with the following path: /etc/xinetd.d/nodemgrsvc.  I configured it as follows, but it didn’t work:


# default: off
# description:nodemanager as a service
service nodemgrsvc
{
  type = UNLISTED
  disable = no
  socket_type = stream
  protocol = tcp
  wait = yes
  user = oracle
  port = 5556
  flags = NOLIBWRAP
  log_on_success += DURATION HOST USERID
  server = /labs/wls1035/jrockit_160_24_D1.1.2-4/jre/bin/java
  env = CLASSPATH=/labs/wls1035/patch_wls1035/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/labs/wls1035/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/labs/wls1035/jrockit_160_24_D1.1.2-4/lib/tools.jar:/labs/wls1035/wlserver_10.3/server/lib/weblogic_sp.jar:/labs/wls1035/wlserver_10.3/server/lib/weblogic.jar:/labs/wls1035/modules/features/weblogic.server.modules_10.3.5.0.jar:/labs/wls1035/wlserver_10.3/server/lib/webservices.jar:/labs/wls1035/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/labs/wls1035/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar
  server_args = -DNodeManagerHome=/labs/wls1035/wlserver_10.3/common/nodemanager/ -Xms32m -Xmx200m -DListenPort=5556 -Djava.security.policy=/labs/wls1035/wlserver_10.3/server/lib/weblogic.policy -Dweblogic.nodemanager.javaHome=/labs/wls1035/jrockit_160_24_D1.1.2-4 weblogic.NodeManager -v
}

In order to see what was going on here, I looked at the <NODEMGR_HOME>/nodemanager.log file and found this exception:


<Aug 21, 2011 10:21:39 AM> <SEVERE> <Fatal error in node manager server>
weblogic.nodemanager.common.ConfigException: Native version is enabled but nodemanager native library could not be loaded
        at weblogic.nodemanager.server.NMServerConfig.initProcessControl(NMServerConfig.java:249)
        at weblogic.nodemanager.server.NMServerConfig.<init>(NMServerConfig.java:190)
        at weblogic.nodemanager.server.NMServer.init(NMServer.java:182)
        at weblogic.nodemanager.server.NMServer.<init>(NMServer.java:148)
        at weblogic.nodemanager.server.NMServer.main(NMServer.java:375)
        at weblogic.NodeManager.main(NodeManager.java:31)
Caused by: java.lang.UnsatisfiedLinkError: no nodemanager in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1737)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1029)
        at weblogic.nodemanager.util.UnixProcessControl.<init>(UnixProcessControl.java:25)
        at weblogic.nodemanager.util.ProcessControlFactory.getProcessControl(ProcessControlFactory.java:22)
        at weblogic.nodemanager.server.NMServerConfig.initProcessControl(NMServerConfig.java:247)
        ... 5 more

Hmmm… perhaps the LD_LIBRARY_PATH has something to do with this?  Not being a Linux guy, I had to do some investigation.  I Googled “LD_LIBRARY_PATH weblogic node manager” and found this old link to configuring Node Manager for WebLogic 8.1: http://download.oracle.com/docs/cd/E13222_01/wls/docs81/adminguide/confignodemgr.html.  Looking through my installation folder I found the .so libs in /labs/wls1035/wlserver_10.3/server/native/linux/i686, so I added this to my nodemgrsvc for xinetd giving me the following (final) configuration:


  1: # default: off
  2: # description:nodemanager as a service
  3: service nodemgrsvc
  4: {
  5:   type = UNLISTED
  6:   disable = no
  7:   socket_type = stream
  8:   protocol = tcp
  9:   wait = yes
 10:   user = oracle
 11:   port = 5556
 12:   flags = NOLIBWRAP
 13:   log_on_success += DURATION HOST USERID
 14:   server = /labs/wls1035/jrockit_160_24_D1.1.2-4/jre/bin/java
 15:   env = LD_LIBRARY_PATH=/labs/wls1035/wlserver_10.3/server/native/linux/i686 CLASSPATH=/labs/wls1035/patch_wls1035/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/labs/wls1035/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/labs/wls1035/jrockit_160_24_D1.1.2-4/lib/tools.jar:/labs/wls1035/wlserver_10.3/server/lib/weblogic_sp.jar:/labs/wls1035/wlserver_10.3/server/lib/weblogic.jar:/labs/wls1035/modules/features/weblogic.server.modules_10.3.5.0.jar:/labs/wls1035/wlserver_10.3/server/lib/webservices.jar:/labs/wls1035/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/labs/wls1035/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar
 16:   server_args = -DNodeManagerHome=/labs/wls1035/wlserver_10.3/common/nodemanager/ -Xms32m -Xmx200m -DListenPort=5556 -Djava.security.policy=/labs/wls1035/wlserver_10.3/server/lib/weblogic.policy -Dweblogic.nodemanager.javaHome=/labs/wls1035/jrockit_160_24_D1.1.2-4 weblogic.NodeManager -v
 17: }
 18: 

Next it was time to test this configuration, so I logged in and started one of my servers.  Unfortunately, watching the STDOUT of the process I found this:



<Aug 21, 2011 10:39:15 AM HKT> <Warning> <NodeManager> <BEA-300043> <Node manager native library not found - server process id not saved.>


Knowing now that I needed to add the native libraries into what becomes the java.library.path I went into the ‘Server Start’ configuration for the managed server and added “-Djava.library.path=/labs/wls1035/wlserver_10.3/server/native/linux/i686” to the startup options.  After restarting the Managed Server, this error was gone.  Success! 


You can also set the LD_LIBRARY_PATH in the setDomainEnv.sh script or in the user environment to have it take affect for all servers you start in the domain which is likely the preferred method.


Hope this helps getting the Node Manager to work on Linux!

Thursday, July 14, 2011

WebLogic/Java Developer Webcast Series

 
We ran a Webcast series earlier this year for Java Developers using WebLogic that showcases the Java EE6 APIs that are supported in the most recent version of WebLogic.  We have posted the webcasts to be viewed offline and they can be found here: http://www.oracle.com/technetwork/middleware/weblogic/learnmore/weblogic-javaee6-webcasts-358613.html.  This webcast series was very popular with developers in EMEA (Europe, Middle East and Africa) and we are tweaking it a bit before running the series in North America.  Stay tuned for updates!

At the same time we were running this series we were building out the Oracle Parcel Service example application that uses these API’s.  The example code can be found here: https://www.samplecode.oracle.com/sf/projects/oracle-parcel-svc/.  If you are interested in the project please let me know.  Thanks!

Please find a summary of the sessions below.

 

Developing a Data Access Layer with JPA

The Java Persistence API is the standard persistence API for Java.  JPA and draws upon the best ideas from persistence technologies such as Hibernate, TopLink, & JDO and simplifies the development of Java EE and Java SE applications using data persistence.  Learn how to use JPA to develop enterprise-class JEE applications utilizing WebLogic’s Industry leading Transaction Manager!

 

Distributed Grid Data Cache – Design for Scale-out, Build for the Cloud

Distributed Data Caches are critical in developing horizontally scalable applications.  By utilizing this technology in the right way you are able to achieve high availability, performance and scalability.  Learn how to utilize this technology to build enterprise-class applications for WebLogic!

 

Web & JMS Services with Spring on WebLogic

Spring is a popular framework for building Web Services & other messaging services and WebLogic has the best messaging performance and transaction management in the industry.  Learn how to build Spring applications utilizing advanced WebLogic features and experience the best platform for Spring!

 

Web Apps with JAX-RS and JQuery

REST is a simple, lightweight yet full-featured alternative to RPC and SOAP.  With JAX-RS you can quickly build REST clients and create rich, dynamic web apps with frameworks like JQuery.  Learn how to use these exciting technologies to create a scalable shared services architecture running on WebLogic!

 

WebLogic Troubleshooting & Performance Tuning

Performance Tuning and Troubleshooting methodologies share many similar tenants.  Behind every bottleneck is yet another bottleneck and every piece software has defects.  Learn how to use Oracle’s JRockit Flight Recorder and WebLogic Diagnostic Framework to quickly identify and resolve issues in your application and WebLogic Grid!

Slides from WebLogic Developer Webcasts on SlideShare

James Bayer and I have uploaded slides from the WebLogic Developer Webcast series to SlideShare.  Please find the links below:

You can find the video recording of the webcast here:http://www.oracle.com/technetwork/middleware/weblogic/learnmore/weblogic-javaee6-webcasts-358613.html

DICE.com has 30% More Job Listings for WebLogic than JBoss

I was curious today about Job Listings for WebLogic so I did some investigation.  What I found was that, on average, job sites have around 30% more job listings that contain ‘WebLogic’ than ‘JBoss’.  There are literally thousands of job listings for ‘WebLogic’, ‘WebLogic Developer’ and ‘WebLogic Architect’. 

Which skill would you rather have?

Here are some direct links to Dice and Monster:

Dice:

'WebLogic': 2,161 jobs, 1,201 full time

‘WebLogic Architect’: 412 jobs, 258 full time

‘WebLogic Developer’: 1,125 jobs, 584 full time

Monster:

'WebLogic': Over 1,000 jobs, 998 full time

'WebLogic Architect': 176 jobs:

'WebLogic Developer': 428 jobs, 403 full time

Detailed Data

image

RESTful Web Services in WebLogic

WebLogic 11gR1 PS3 (10.3.4) now supports RESTful Services with Java (JAX-RS).  This support is provided through Jersey, which is the reference implementation for JAX-RS.  I didn’t care much about RESTful services until they were supported directly in WebLogic and included in the EE6 specification.  I came from a SOA/SOAP background and REST had too much of a ‘hype’ factor, plus SOAP was giving me everything that I needed at the time, so why change?  Nonetheless, I have started learning about JAX-RS & REST and its quite interesting!  Not only is the programming model fun to play with, the architectural questions that arise on when/how to use it are also enlightening. 

To throw my opinion into the ring, I firmly stand behind the principle that REST should be used for exposing RESOURCES while SOAP should be used for exposing BUSINESS LOGIC.  However, you can choose to blur the lines as much as you want, for example, what does ‘PUT’ really mean?  Is ‘PUT’ a valid action on a Message Queue?  If so, then I should be able to expose a message queue via REST, but that’s quite different from doing a ‘GET’ on a Customer resource, no?

Both SOAP and REST have their rightful places in the toolbox of an Enterprise Architect.  REST doesn’t replace SOAP – they compliment each other…

Here is an excerpt of a webcast where I discuss RESTful vs. SOAP Web Services on our YouTube Channel:

WebLogic 10.3.4 Zip Distribution

I had a chance today to download and play with the WebLogic ZIP Distribution that was introduced in version 10.3.4.  I have been curious about this for a while, and after hearing some complaints on Twitter about the installation and startup time I figured I would give it a shot.

I have to say, I was pretty (pleasantly) surprised about the installation and usage of the ZIP distribution.  I was able to get it downloaded, installed and running in about 5 minutes!  I think its fair to say that you have to see it to believe it yourself, so I recorded a video (link below). 

I was able to get it installed and running on my 2010 MacBook Pro 15”, logged into the Admin Console in about 2 minutes.  Granted, not everyone has access to a fast development machine so I decided to try it on a different machine.  I’ve got a DELL XPS 400 which has a Core 2 DUO (first version of the multi-core CPU) where I’m running vSphere and Windows XP in a Virtual Machine.  In this scenario I was able to get WebLogic installed and running in 3 MINUTES!

Check it out:

WebLogic 10.3.4 ClassLoader Analysis Tool

I recently did some investigation into the WebLogic Filtering ClassLoader, and the larger ClassLoader picture for WebLogic and put together a presentation on it.  I also included a demo of the ClassLoader Analysis Tool (CAT) that is a very useful tool for looking under the covers of the WebLogic ClassLoader operation.

The CAT analyzes class conflicts and shows you the conflicting library/JAR in your application that is in conflict with the WebLogic-packaged libraries.  You can see in the screenshot from the CAT below:

CAT_Conflict

 

Not only does CAT analyze conflicts it also provides the XML needed to add to the WebLogic Deployment descriptors (weblogic.xml and weblogic-application.xml):

CAT_Suggestion

 

Check out the presentation and demo below:

New YouTube Video: WebLogic 11gR1 PS3 (10.3.4) New Features

When I gave my presentation about WebLogic 10.3.4 at The Server Side Java Symposium there were a few people that were surprised about the new features in the latest release WebLogic.  I have broken the presentation up into a few different pieces, and you can find a link to the video below.  You can also visit our WebLogic YouTube channel to learn more about WebLogic.

image

YouTube Video: WebLogic 11gR1 PS3 (10.3.4) New Features