Wednesday, March 28, 2012

Arun Gupta, Java EE6, Spring and James Bayer

 

It has been entertaining to see the exchange between the Java EE and Spring zealots, as it always is.  Recently Arun Gupta, a Java EE Champion and Evangelist, posted a blog on why he thought Java EE6 is better than Spring: https://blogs.oracle.com/arungupta/entry/why_java_ee_6_is.  This stirred the pot and got some interesting comments on the post.

One such comment was from Previous Oracle WebLogic PM James Bayer who now works at VMWare: http://www.iamjambay.com/2012/03/arun-gupta-java-ee-6-and-spring.html

I have posted the comments below on Arun’s blog, but the text is too long for James’s blog as a comment, and it would be good to have my opinion stated on my blog, not in someone else’s comments.  Here we go:

This has definitely been an enlightening and entertaining stream of comments!

Disclaimer: I too am employed by Oracle. Draw whatever conclusions you must from that. I thought Spring was a pain in the arse before I joined Oracle and I still hold that opinion. It just so happens that I am now paid by Oracle *while* sharing that opinion Smile

Let’s agree to one thing up front - both the JCP and SpringSource seek to serve the Java community.

In addition to attempting to serve the Java Community, SpringSource needs to continue to serve its own interests.

There is value in developing standards and there is value in breaking away from the standard in the vein of innovation to create something new. Our society definitely rewards individuals who take this approach. Does SpringSource innovate and help advance the Java platform? Absolutely! Innovation helps drive the standards forward and the standard provides a base for innovation. I think we can all assume that neither Java EE nor Spring will die any time soon and that we will never be without defined standards.

One thing I find interesting in the ‘competition’ between Java EE and Spring is that since the JCP is public, SpringSource is able to view the process and take their own tack on how to implement the JSR’s included in the Java EE spec and do so before the community has finalized a new version of the spec. Rightfully so, larger corporations like IBM and Oracle would not begin working on implementing the spec before it was final. How long is ‘acceptable’ for vendors to start releasing implementations of the new spec, anyway? It is not just the spec that they have to implement - it is implementing the spec in conjunction with value-added features, backwards compatibility and testing cycles. SpringSource has the flexibility to watch the process and deliver their proprietary interpretation of things very soon after an Java EE spec is released without being encumbered by any other agenda or process – all while putting their own spin on how things should be instead of influencing the JCP and the Java EE Standard for the greater good.

It would be interesting to see the state of affairs with Java in an alternate universe where Rod Johnson worked through the JCP to improve Java instead of inventing Spring. It was clearly an opportunistic move, and it has served him well. However, I believe that Java would be in a better state if we could have kept the focus on improving Java through the JCP.

As Arun has stated, and what should be common knowledge by now, Java EE 5/6 did a great deal to improve the original problems and perceptions with J2EE. The original reasons for adopting the Spring framework are no longer valid in many cases. For new development EE6 offers a great deal of productivity for developers. Its designed for this and it delivers. Of course – we can all say that we want people to come to their own conclusions (only after we’ve had a chance to influence them). If we agree not to try to influence the decision process then we should take down java.net and springsource.org ASAP.

Let’s be clear about one thing - there are developers who most definitely do NOT want to use Spring. This is a fact. They have been forced into it and don’t like it. Let’s not try to paint a picture where every developer in the world is dying to use Spring but is held back by an evil dictator making them stay on J2EE 1.3.

They are tired of working with XML files and struggling with getting things wired correctly. Sure, 3.0 and 3.1 help with less XML required but that doesn’t help someone who is stuck on 2.5 and can’t upgrade. It also doesn’t appease the frustrations they have had dealing with XML which make them want to switch – just like the argument for EJB 3.0 being simple doesn’t alone make people want to switch back from Spring if their reason for adopting it was EJB 1.1 tribulation. This is only one point, and my goal here is not to provide an exhaustive list. This is one example of a point that is driving some Spring developers to look for other options.

Also, developers in corporate IT shops do not always get a choice of what they can use. They are often directed what to use by the Team Lead or Architect. You could soundly argue that in order to be a Team Lead or Architect in a large(ish) organization that you need a few years of experience – lets say 5-6. This being the case, when these individuals were ‘coming up’ from being an entry-level developer during the time where Spring was gaining momentum and probably wound up going down the Spring path instead of Java EE. They have learned it and used it for years now and they can be very effective with it – we all use the tools we can be most effective with. I feel this is a major reason for much of Spring’s ongoing success.

One final ‘content’ note - the Oracle Public Cloud is not released, and there is more to test in OPC than the WebLogic implementation. James, you know this – you were here.

It’s easy to be a Monday Morning Quarterback on this because we can look back and see the path history has taken. To be honest, the point of these discussions seems lost in posturing and personal defense/offense. What’s the point of this, seriously? There is nothing to be gained from this aside from putting on a show for the masses. Both Spring and Java EE have their champions. Neither side is innocent of not making things personal or bashing the other side – both sides do it regularly and often. Pointing out individual incidents of bashing is neither productive nor conducive to a peaceful existence – assuming that’s what we want… Smile

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: