Jmeter custom build.

JMeter provides almost all functionalities which are needed for load-testing. But sometimes functionalities do not match exactly with our requirement and code changes are required to get the custom JMeter build. This post is going to describe about my experience of building JMeter and fixing build error.

First thing was required to get the source code. After little googling, I figured out that the source code can be cloned from the Apache repository. I used the following command to clone the source code.

/>git clone git://git.apache.org/jmeter.git --recursive

Once looking into the source root directory I noticed build.xml which is clear indication of requirement of ant build system. Since I didn’t have ant on Ubuntu, so used the following command to install ant.

/> sudo apt-get install ant

I was almost one step behind the custom build. Before issuing the build command I was curious to see what all targets are available. So I ran the following command.

/> ant -p
Buildfile: /home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml


  N.B. To build JMeter from a release you need both the binary and source archives,
  and these must be unpacked into the same directory structure.

  To download additional jars needed for building the code and documentation:

      ant download_jars


    To build JMeter from source:
      ant [install]

    To rebuild:
      ant clean install

    To update documentation
      ant docs-site
      ant docs-printable
    To build API documentation (Javadoc)
      ant docs-api
    To build all the docs
      ant docs-all

    To build all and package up the files for distribution
      ant distribution -Djmeter.version=vvvv [-Dsvn.revision=nnnnn]
  	
    Add -Ddisable-svnCheck=true to disable svn check, if you build from src archive or offline
  	Add -Ddisable-check-versions=true to disable matching current svn revision and JMeterVersion.java,
  	  if you want build your own custom JMeter package.

    To create a nightly build (separate bin/src/lib jars):
      ant nightly [-Dsvn.revision=nnnnn]

    To create tar and tgz of the web-site documentation (docs and api)
      ant site [ -Djmeter.version=vvvv ]


    For more info:
      ant -projecthelp

    To diagnose usage of deprecated APIs:
      ant -Ddeprecation=on clean compile
  
Main targets:

 RC_publish          Publish release candidate from svnpubsub area
 RC_upload           Upload release candidate to svnpubsub area
 batchtest           Run the batch test and compare output files
 batchtestserver     Run the batch test using client-server mode
 check_jars          Check that all required jar files are present
 clean               Clean up to force a build from source.
 clean-dist          Clean up dist directory.
 compile             Compile everything.
 compile-components  Compile generic (protocol-independent) components.
 compile-core        Compile JMeter core classes.
 compile-examples    Compile example components.
 compile-ftp         Compile components specific to FTP sampling.
 compile-functions   Compile functions.
 compile-http        Compile components specific to HTTP sampling.
 compile-java        Compile components specific to Java sampling.
 compile-jdbc        Compile components specific to JDBC sampling.
 compile-jms         Compile components specific to JMS sampling.
 compile-jorphan     Compile JOrphan utility classes.
 compile-junit       Compile components specific to JUnit sampling.
 compile-ldap        Compile components specific to LDAP sampling.
 compile-mail        Compile components specific to IMAP and POP3 sampling.
 compile-mongodb     Compile components specific to MongoDB sampling.
 compile-native      Compile components specific to Native sampling.
 compile-protocols   Compile all protocol-specific components.
 compile-report      Compile report components.
 compile-rmi         Compile RMI stubs and skeletons.
 compile-tcp         Compile components specific to TCP sampling.
 compile-tests       Compile test components only
 distribution        Build JMeter for end-user distribution
 docs-api            Generate the API documentation.
 docs-printable      Generate printable HTML documentation.
 docs-site           Generate browsable HTML documentation in web-site format.
 download_jars       Download any missing jar files
 findbugs            Run the stand-alone Findbugs detector
 generator_jar       Create the test tree generator jar
 gump-build          Build JMeter
 gump-test           Test JMeter in Gump
 install             Install JMeter. (Compiles code and creates jars)
 install-examples    Build and installs the example components.
 junit               Run individual JUnit test
 maven_upload        Upload Maven jars and poms (and sigs if present) to Nexus.
 nightly             Build JMeter for nightly dir (package docs-printable pack-nightly)
 package             Compile everything and create the jars
 package-only        Package already-compiled classes (shortcut for IDE users)
 prepare-resources   Prepare some resources files, update date
 release_delete      Delete old release candidate from svnpubsub area
 run_gui             Run the JMeter GUI off the jar files
 sign_dist           Sign release artifacts in dist and dist/maven.  Usage: ant sign_dist -Dgpg.keyname=key-id [-Dgpg.secretKeyring=path-to-keyring]      
 svnCheck            Use SVN to get the current revision
 test                Run tests (use -Djava.awt.headless=true on systems without graphic displays)
Default target: install

Here help instructions ask to run ant download_jars first to get the depencies jar first since those are not present in the source directory. When executed the command I got the following failure.

BUILD FAILED
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2834: The following error occurred while executing this line:
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2772: The following error occurred while executing this line:
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2663: The following error occurred while executing this line:
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2701: Directory does not exist: /home/rakeshHome2/sprint/jMeter/src/jmeter/lib/api

I tried to google the solution but couldn’t find any post. As pointed by the last line of the failure statement, I created the directory using the following command.

/> mkdir -p /home/rakeshHome2/sprint/jMeter/src/jmeter/lib/api

And issued the same build command. I again got the similar failure message again..

BUILD FAILED
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2834: The following error occurred while executing this line:
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2813: The following error occurred while executing this line:
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2663: The following error occurred while executing this line:
/home/rakeshHome2/sprint/jMeter/src/jmeter/build.xml:2701: Directory does not exist: /home/rakeshHome2/sprint/jMeter/src/jmeter/lib/doc

Because this was similar error, without waiting I issued the command to create the folder and tried the build command same command.

/> mkdir -p /home/rakeshHome2/sprint/jMeter/src/jmeter/lib/doc

After download task was complete , issued ant install command to build the project. It worked fine and created the jar file in bin directory. Now the next step is to generate the distribution so issued the following command.

/> ant distribution -Djmeter.version=2.9 -Ddisable-svnCheck=true -Ddisable-check-versions=true

But got the following error.

     1 Setting JMeterHome: /home/rakeshHome2/sprint/jMeter/src/jmeter
     1 Setting up logging props using file: /home/rakeshHome2/sprint/jMeter/src/jmeter/bin/testfiles/jmetertest.properties
     1 /home/rakeshHome2/sprint/jMeter/src/jmeter/bin/testfiles/jmetertest.properties (No such file or directory)
     1 Using initializeProperties() from org.apache.jmeter.util.JMeterUtils
     1 Setting up initial properties using: /home/rakeshHome2/sprint/jMeter/src/jmeter/bin/testfiles/jmetertest.properties
     1 Initializing Properties: /home/rakeshHome2/sprint/jMeter/src/jmeter/bin/testfiles/jmetertest.properties
     1 Exception in thread "main" java.lang.RuntimeException: Could not read JMeter properties file:/home/rakeshHome2/sprint/jMeter/src/jmeter/bin/testfiles/jmetertest.properties
     1 	at org.apache.jmeter.util.JMeterUtils.loadJMeterProperties(JMeterUtils.java:190)
     1 	at org.apache.jmeter.util.JMeterUtils.getProperties(JMeterUtils.java:139)
     1 	at org.apache.jmeter.util.JMeterUtils.initializeProperties(JMeterUtils.java:290)
     1 	at org.apache.jorphan.test.AllTests.initializeManager(AllTests.java:300)
     1 	at org.apache.jorphan.test.AllTests.main(AllTests.java:144)

After examining the error it looked like test target is looking for jmetertest.properties in testfiles directory. Tried to locate the directory but couldn’t find it. Since test was throwing exception
I removed test from ‘depends’ section present in distribution target. After updating the line, it looked like this.

 <target name="distribution"
        depends="svnCheck,check-versions,clean,install,docs-printable,docs-api,_distribution"
        description="Build JMeter for end-user distribution"/>

It worked after this update. I was able to get the distribution in zip file. I tried to investigate this issue and turned to git. After executing git status command, I realized that somehow I have deleted the testfiles directory. After resetting the git, I was able to build JMeter successfully.


Hope this blog helped you in some way. If you like this blog then please share it. You can also leave your comment below.

, ,
Trackback

no comment untill now

Add your comment now