Getting Started With iControl And Java – Setting Up Eclipse

This is the first article in a series focused on developing iControl applications with the Java language.  I’ve picked Eclipse development platform for this set of platforms.  The goal here is to give you the directions and tools you need to make the most out of iControl when you are involved with Java development. 

For this article, I’m going to assume that you are starting off of a clean system.  In most cases, you will already have one or more of the prerequisites installed so you can feel free to ignore that section.  This article was developed with all the components on a Windows 7 System, but everything should work similarly on other platforms.

The Pieces To The Puzzle

Java Java

The first item you will need to install is Java itself.  This can be downloaded from the Java Website At Oracle.com.  There are a lot of different versions of Java but I always stick to the bare bones “Java SE” JDK distribution. 

I’m not going to walk through the installation of Java as I assume you can figure that one out for yourself.  If you are really stuck, do a Google Search for “How To Install Java” and that should point you in the right direction.

eclipse Eclipse

Eclipse is an open source development platform build with extensible frameworks, tools and runtimes for many different languages – Java being one of them.  The JDT (Java Development Tools) project  provides the tool plug-ins that implement a Java IDE supporting the development of any Java application. 

To install Eclipse for Java, visit the downloads page at http://www.eclipse.org/downloads/ and select the appropriate “Eclipse IDE for Java Developers distribution.  Even though I am running 64-bit windows, I had an issue getting the 64-bit build of Eclipse to work.  This was possibly due to the version of Java I had installed.  So, I picked the “Windows 32 Bit” download and it worked out find. 

The download is just a .zip file containing the product directory.  Just unzip this to a location of your choosing.

iControlAssembly iControl Library For Java

At this point you should have a development environment setup for building Java applications.  The last piece of the puzzle is the iControl libraries for Java.  iControl is a set of Web Services and we have taken the Web Service Description Language (WSDL) files, built client proxy code for them, and packaged them within a nice wrapper class and packed them into a Java library to make it as easy as possible for you to integrate iControl into a new or existing Java application.

To get the libraries, you’ll need to visit the iControl Assembly (we have a .Net version as well) Labs project on DevCentral and click on the “Discussions and Downloads” link.  From there Click into the latest release in the “Downloads” section (as of now it is at iControl v10.2) and download the “Java Binary Distribution” release.  The “Java Source Distribution” is available if you want to see how I built the library.

The binary download will include two directories: Lib and 3rdparty.  The client proxy code was built with Apache Axis so we’ve included those libraries to include in your projects as well so that you don’t have to go hunting elsewhere for all the other dependent libraries.  Unzip this directory somewhere on your disk (ie \iControl\javalib).

Building Your First Project

I figured that a video would be easier to follow than me describing the steps it takes to create a project and import the iControl libraries in it so I make this walkthrough where I:

  • Created a new Java project in Eclipse.
  • Imported the iControl Library for Java and associated 3rd party libraries.
  • Created a class with a Main method to be used as a console application.
  • Created an instance of the iControl.Interfaces object.
  • Initialized the iControl.Interfaces object with the credentials for my BIG-IP.
  • Added logic to query the System information and output that to the console.
  • Debug and demonstrate the application.

I did all that in 5 minutes! …with a little help from cut-and-paste B-).

Conclusion

You should now be able to build a Java application to make use of the automation features of your BIG-IP.  In future articles, I will illustrate other aspects of the iControl API with Java.

Download

The Java class for this example can be downloaded from the iControl CodeShare under JavaSystemInfo.

Related Articles on DevCentral

Technorati Tags: iControl, Java, Eclipse, Joe Pruitt
Published Sep 15, 2010
Version 1.0

Was this article helpful?

6 Comments

  • clazba's avatar
    clazba
    Icon for Nimbostratus rankNimbostratus
    Hiya, the walk-through video (https://devcentral.f5.com/s/articles/f5-programmability-for-eclipse-installation-instructions-20883) does not seem to work -- I can only see a still image of some code for a few seconds. Can you please re-upload as it illustrates a critical part of the process? thanks!!
  • Hi,

     

     

    I am getting exception when I tried to execute your code on my machine. I have given hostname, user id, password.

     

     

    AxisFault

     

    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

     

    faultSubcode:

     

    faultString: java.net.SocketException: java.io.EOFException

     

    faultActor:

     

    faultNode:

     

    faultDetail:

     

    {http://xml.apache.org/axis/}stackTrace:java.net.SocketException: java.io.EOFException

     

    at javax.net.ssl.DefaultSSLSocketFactory.a(SSLSocketFactory.java:7)

     

    at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:11)

     

    at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:118)

     

    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)

     

    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)

     

    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

     

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

     

    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

     

    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

     

    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

     

    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

     

    at org.apache.axis.client.Call.invoke(Call.java:2767)

     

    at org.apache.axis.client.Call.invoke(Call.java:2443)

     

    at org.apache.axis.client.Call.invoke(Call.java:2366)

     

    at org.apache.axis.client.Call.invoke(Call.java:1812)

     

    at iControl.SystemSystemInfoBindingStub.get_system_information(SystemSystemInfoBindingStub.java:1643)

     

    at com.americanexpress.ngi.SystemInfo.getSystemInformation(SystemInfo.java:42)

     

    at com.americanexpress.ngi.SystemInfo.Run(SystemInfo.java:35)

     

    at com.americanexpress.ngi.SystemInfo.main(SystemInfo.java:75)

     

    Caused by: java.io.EOFException

     

    at java.io.DataInputStream.readInt(DataInputStream.java:386)

     

    at com.ibm.crypto.provider.JavaKeyStore.engineLoad(Unknown Source)

     

    at java.security.KeyStore.load(KeyStore.java:414)

     

    at com.ibm.jsse2.uc.a(uc.java:54)

     

    at com.ibm.jsse2.lc.f(lc.java:12)

     

    at com.ibm.jsse2.lc.(lc.java:16)

     

    at com.ibm.jsse2.lc.e(lc.java:17)

     

    at com.ibm.jsse2.SSLSocketFactoryImpl.(SSLSocketFactoryImpl.java:3)

     

    at java.lang.J9VMInternals.newInstanceImpl(Native Method)

     

    at java.lang.Class.newInstance(Class.java:1345)

     

    at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:21)

     

    at org.apache.axis.components.net.JSSESocketFactory.initFactory(JSSESocketFactory.java:87)

     

    at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:105)

     

    ... 16 more

     

     

    {http://xml.apache.org/axis/}hostname:PHXJ04967807

     

     

    java.net.SocketException: java.io.EOFException

     

    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)

     

    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)

     

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

     

    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

     

    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

     

    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

     

    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

     

    at org.apache.axis.client.Call.invoke(Call.java:2767)

     

    at org.apache.axis.client.Call.invoke(Call.java:2443)

     

    at org.apache.axis.client.Call.invoke(Call.java:2366)

     

    at org.apache.axis.client.Call.invoke(Call.java:1812)

     

    at iControl.SystemSystemInfoBindingStub.get_system_information(SystemSystemInfoBindingStub.java:1643)

     

    at com.americanexpress.ngi.SystemInfo.getSystemInformation(SystemInfo.java:42)

     

    at com.americanexpress.ngi.SystemInfo.Run(SystemInfo.java:35)

     

    at com.americanexpress.ngi.SystemInfo.main(SystemInfo.java:75)

     

    Caused by: java.net.SocketException: java.io.EOFException

     

    at javax.net.ssl.DefaultSSLSocketFactory.a(SSLSocketFactory.java:7)

     

    at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:11)

     

    at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:118)

     

    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)

     

    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)

     

    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

     

    ... 13 more

     

    Caused by: java.io.EOFException

     

    at java.io.DataInputStream.readInt(DataInputStream.java:386)

     

    at com.ibm.crypto.provider.JavaKeyStore.engineLoad(Unknown Source)

     

    at java.security.KeyStore.load(KeyStore.java:414)

     

    at com.ibm.jsse2.uc.a(uc.java:54)

     

    at com.ibm.jsse2.lc.f(lc.java:12)

     

    at com.ibm.jsse2.lc.(lc.java:16)

     

    at com.ibm.jsse2.lc.e(lc.java:17)

     

    at com.ibm.jsse2.SSLSocketFactoryImpl.(SSLSocketFactoryImpl.java:3)

     

    at java.lang.J9VMInternals.newInstanceImpl(Native Method)

     

    at java.lang.Class.newInstance(Class.java:1345)

     

    at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:21)

     

    at org.apache.axis.components.net.JSSESocketFactory.initFactory(JSSESocketFactory.java:87)

     

    at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:105)

     

    ... 16 more

     

  • @clazba - not sure what's going wrong with your setup. It looks from the stack trace that apache axis is getting an end of file exception when trying to access your keystore. I'm not a java expert by any means so if anyone has any ideas, I'd love to hear them.

     

     

    What are you using for client code? Are you using the iControl library for Java. Any more details you can provide, will help on our end (client library, calling code, etc).