Sunday Nov 15, 2015

Deploying Java EE 7 Applications to Partitions from Eclipse

The new WebLogic Server 12.2.1 Multi-tenant feature enables partitions to be created in a domain that are isolated from one another and able to be managed independently of one another. From a development perspective, this isolation opens up some interesting opportunities - for instance it enables the use of a single domain to be shared by multiple developers, working on the same application, without them needing to worry about collisions of URLs or cross accessing of resources.

The lifecycle of a partition can be managed independently of others so starting and stopping the partition to start and stop applications can be done with no impact on other users of the shared domain. A partition can be exported (unplugged) from a domain, including all of it's resources and application bits that are deployed, and imported (plugged) into a completely different domain to restore the exact same partition in the new location. This enables complete, working applications to be shared and moved between between different environments in a very straightforward manner.

As an illustration of this concept of using partitions within a development environment, the YouTube video - WebLogic Server 12.2.1 - Deploying Java EE 7 Application to Partitions - takes the Java EE 7 CargoTracker application and deploys it to different targets from Eclipse.

  • In the first instance, CargoTracker is deployed to a known WebLogic Server target using the well known "Run as Server" approach, with which Eclipse will start the configured server and deploy the application to the base domain.
  • Following that, using a partition that has been created on the same domain called "test", the same application code-base is built and deployed to the partition using maven and the weblogic-maven-plugin. The application is accessed in its partition using its Virtual Target mapping and shown to be working as expected.
  • To finish off the demonstration the index page of the CargoTracker application is modified to mimic a development change and deployed to another partition called "uat" - where it is accessed and seen that the page change is active.
  • At this point, all three instances of the same application are running independently on the same server and are accessible at the same time, essentially showing how a single domain can independently host multiple instances of the same application as it is being developed.

Tuesday Nov 03, 2015

Using Eclipse with WebLogic Server 12.2.1

With the installation of WebLogic Server 12.2.1 now including the Eclipse Network Installer, which enables developers to  download and install Eclipse including the specific features of interest, getting up and running with Eclipse and WebLogic Server has never been easier.

The Eclipse Network Installer presents developers with a guided interface to enable the custom installation of an Eclipse environment through the selection of an Eclipse version to be installed and which of the available capabilities are required - such as Java EE 7, Maven, Coherence, WebLogic, WLST, Cloud and Database tools amongst others.  It will then download the selected components and install them directly on the developers machine

Eclipse and the Oracle Enterprise Pack for Eclipse plugins continue to provide extensive support for WebLogic Server enabling it to be used to throughout the software lifecycle; from develop and test cycles with its Java EE dialogs,  assistants and deployment plugins; through to automation of configuration and provisioning of environments with the authoring, debugging and running of scripts using the WLST Script Editor and MBean palette.

The YouTube video WebLogic Server 12.2.1 - Developing with Eclipse provides a short demonstration on how to install Eclipse and the OEPE components using the new Network Installer that is bundled within the WebLogic Server installations.  It then shows the configuring of a new WebLogic Server 12.2.1 server target within Eclipse and finishes with importing a Maven project that contains a Java EE 7 example application that utilizes the new Batch API that is deployed to the server and called from a browser to run.

Tuesday Feb 10, 2015

Oracle Maven Repository - Viewing Contents in Eclipse

Our own Steve Button has published a great blog on using the new Oracle Maven Repository with Eclipse.
Get started here, and then read the full entry.

With the Oracle Maven Repository now accessible one way to have explore its contents is to use the Maven Repositories viewer feature available in most development tools. I've seen the repository contents displayed easily in NetBeans so I decided to take a look at what it looks like in Eclipse as well.

I had to make a few minor setting changes to get it to work so decided to document them here.  If you've gotten it to work with less setting changes, let me know!

As initial setup, I configured my local maven environment to support access to the Oracle Maven Repository.  This is documented here  I also installed maven-3.2.5 that includes the updated Wagon module that supports authentication.

Next I downloaded and used the new network installer that the Oracle Eclipse team has published on OTN to install the latest version of Oracle Enterprise Pack for Eclipse.

This network installer lets developers select the version of Eclipse to install and the set of Oracle extensions --  Weblogic, GlassFish and other stuff -- to add in to it.

 Once Eclipse is installed, you can add the Maven Repository viewer by selecting   Window > Show View > Other > Maven Repositories from the Eclipse toolbar.

I also added a Console > Maven viewer to see what was happening under the covers and arranged them so they were visible at the same time:

With the Maven views ready to go, expand the Global Repositories node. This will show Maven Central (any other repositories you may have configured) and the Oracle Maven Repository if you have configured it correctly in the settings.xml file.

The initial state of the Oracle Maven Repository doesn't show any contents indicating that its index hasn't been downloaded to display.

Right mouse clicking on it and selecting the Rebuild Index option causes an error to be shown in the console output indicating that the index could not be accessed.

To get it to work, I made the following changes to my environment.  

Configure Eclipse to Use Maven 3.2.5

Using the Eclipse > Preferences > Maven > Installation dialog, configure Eclipse to use Maven 3.2.5.  This is preferred version of Maven to use to access the Oracle Maven Repository since it automatically includes the necessary version of the Wagon HTTP module that supports the required authentication configuration and request flow.

Configure Proxy Settings in Maven Settings File

** If you don't need a proxy to access the Internet then step won't be needed **

If you sit behind a firewall and need to use a proxy server to access public repositories then you need to configure a proxy setting inside the maven settings file.

...Read the rest on Steve's blog!

Friday May 17, 2013

Troubleshooting Tools Part 3 - Heap Dumps

A Heap Dump is a snapshot of the Java process heap memory at a given time.  It's a useful tool to troubleshoot memory leaks and other memory related issues.  Heap dumps are to memory what thread dumps are to java threads.

There are different ways to dump the java heap used by a Java application such as WebLogic Server.  Heap dumps can be triggered automatically by JVMs such as HotSpot or JRockit when an OutOfMemory event occurs.


java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\myApp\hprof-dumps myApp  

This command will generate a heap dump file in the defined heap dump directory when an OOM is thrown.  

The file will be in HPROF binary format (*.hprof).  If no path is defined the file will be created in the directory from which the java process was launched.  The format of the file with JRockit is jrockit_pid,hprof, pid being the process ID of this JVM instance.  With HotSpot the format of the file will be java_pidpid.hprof.


java.lang.OutOfMemoryError: Java heap space

Dumping heap to D:\java_pid4148.hprof ...

Heap dump file created [24921731 bytes in 1.400 secs]

For WebLogic Server these properties, HeapDumpOnOutOfMemoryError and HeapDumpPath (optional), can be added directly to the startup script that contain the Java command that launches WLS.  On Windows the script (with default name startWebLogic.cmd) lives in the domain bin directory and the parameters can be directly added to the existing JAVA_OPTIONS.

With a JRockit VM process the following command can also be used to generate a heap dump.


jrcmd pid hprofdump filename=name_of_dump_file

However if you are using this command against a non JRockit process the following error will come up: Command failed in target VM

You can also manually generate a heap dump with tools such as jmap or VisualVM.


jmap -heap:live,format=b,file=filename pid

This command will generate a heap dump file in binary format and will only count live objects (the live option is optional). Live objects are used by applications and generally reside in the Young Generation part of the heap.

As illustrated in the screenshot below, generating a heap dump with VisualVM is very simple.  VisualVM is shipped as part of the HotSpot JVM  (/bin/jvisualvm.exe).  However, VisualVM can connect to java processes that started with other JVM such as JRockit.

Once generated, the heap dump will be parsed as shown below:

VisualVM enables you to browse heap dumps as shown above with the Classes view where you can easily identify the number and percentage of instances referred by each class.

jhat can also be used to analyze heap dump files.


jhat dumpfile

Reading from dumpfile...
Dump file created Fri May 17 15:25:41 PDT 2013
Snapshot read, resolving...
Resolving 580390 objects...
Chasing references, expect 116 dots.............................................
Eliminating duplicate references................................................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.

Then you can open http://localhost:7000/ to navigate through the content of the dump file to identify objects with high number of occurrences.

Finally, as shown below, the OpenSource Eclipse MAT offers a very rich GUI that includes histograms and leak hunter actions, overview and leak suspect reports and much more.

Previous posts on troubleshooting tools:

Troubleshooting Tools Part 1 - VisualVM

Troubleshooting Tools Part 2 - jstack

Friday Jan 18, 2013

Troubleshooting Tools Part 1 - VisualVM

A variety of free troubleshooting and debugging tools exist but which ones are really useful when analyzing issues with WebLogic Server?  In this new blog post series, I will talk about some of the best tools that are available, easy to use, free, and very effective in identifying a bunch of issues.  In this first post I will cover VisualVM.

VisualVM most recent version, or 1.3.5, was released on 11/13/2012.  This tool consists of an user-friendly visual interface for monitoring running JVMs.  Multiple instances of WLS or Java can be monitored at the same time by just connecting to running local or remote JVMs.  VisualVM needs to run on Oracle Sun JDK 6+, the JDK, not the JRE. VisualVM can be started as follow to specify the JDK to run it it on.

visualvm --jdkhome "JDK_location", or visualvm --jdkhome "d:\jdk160_24"

Alternatively, /etc/visualvm.conf can be modified to specify a desired JDK.  After launch, the list of local running Java instances will be displayed on the left panel under applications.  In Remote, you can define the host of other running Java instances.  By selecting a running server and clicking on open, you should get a screen similar to the following:

In Start Page, online documentation of VisualVM can be easily accessed.  Tags next to Start Page are specific to open JVM instances.  In my case, you will find a Weblogic Server instance with its process id (pid).

Underneath, Overview reports all JVM settings as well as many system properties including Weblogic specific properties.

Monitor gives access to realtime monitoring of CPU, Heap, Classes and Threads.  You can also force a garbage collection (GC) or issue a heap dump for further analysis.

Threads reports all threads activity in realtime but also allows to take thread dumps.  All thread dumps will be attached to the relevant application process on the left panel and saved in C:\Users\<user_name>\AppData\Local\Temp\visualvm.dat.  Example: C:\Users\lgoldszt\AppData\Local\Temp\visualvm.dat\localhost_6352\threaddump-1358534350679.tdump.  Thread dumps can be further diagnosed with ThreadLogic.

In Samplers, you can record CPU or memory usage activity.  This is neat to debug potential memory leak and high CPU usage threads.

Finally, Profiler allows to identify where most of the time is being spent and which objects consume most of the memory.

Snapshots of memory can be taken and compared with others, see File - Compare Memory Snapshots.  

Also VisualVM comes with a bunch of easy to install plugins as you can see below:

VisualVM doesn't have an MBeans tab like JConsole.  However, this can be very easily changed by installing the available VisualVM-MBeans plugin.  

With its extensive features, especially including those offered by individual plugin, VisualVM is the tool of choice and combine characteristics of tools such as JConsole, jstat, jmap, or jstack.

Among other choices, the download page gives you the opportunity to use the VisualVM Eclipse launcher plugin.

For further information and demos please visit VisualVM demo and features


The official blog for Oracle WebLogic Server fans and followers!

Stay Connected


« November 2015