Thursday, October 16, 2014

hamcrest-library 1.3 not compatible with json-path-0.9.1

Background

While I was working on my SpringMVC project, I was trying to test jsonPath and encounter is problem. Here is the Stacktrace which I run the JunitTest:
java.lang.NoSuchMethodError: com.jayway.jsonpath.JsonPath.compile(Ljava/lang/String;[Lcom/jayway/jsonpath/Filter;)Lcom/jayway/jsonpath/JsonPath;
 at org.springframework.test.util.JsonPathExpectationsHelper.(JsonPathExpectationsHelper.java:54)
 at org.springframework.test.web.servlet.result.JsonPathResultMatchers.(JsonPathResultMatchers.java:43)
 at org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(MockMvcResultMatchers.java:196)
 at com.ggl.springmvc.BlogEntryControllerTest.test(BlogEntryControllerTest.java:40)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Solution

The reason for this is the incompatibility between json-path 1.1 and hamcrest-library 1.3. To fix this, simple change the version of json-path from 1.1.0 to 0.9.1

Thursday, October 9, 2014

Install Tomcat 8 On MacOS

Introduction

I have been using Tomcat on and off for the last 10 years. It is a great application server with respect to easy use and functionality. As I am developping an AngularJS project, I decided to use Tomcat as my server platform. This blog is to describe how to install the newly available Tomcat on MacOS.

Currently I am using OSX 10.9.5, as show in the figure below

Downlaod

The download site is at http://tomcat.apache.org/download-80.cgi

After download, you should verify MD5 signature by:
[/Users/Gary2013/Tomcat]$ md5 ~/Downloads/apache-tomcat-8.0.14.tar.gz 
MD5 (/Users/Gary2013/Downloads/apache-tomcat-8.0.14.tar.gz) = 96063b1e477869e8ff4801d777e8915b

Now copy the MD5 signature from apache tomcat's web site and compare the string. Here the script I used:

if [[ 96063b1e477869e8ff4801d777e8915b == 96063b1e477869e8ff4801d777e8915b ]] ; then echo "OK No Problem"; else echo "Wrong File"; fi

Install Tomcat

Now, execute the following procedures:
cd ~
mkdir Tomcat
cd $_
tar -zvxf ~/Downloads/apache-tomcat-8.0.14.tar.gz 
cd apache-tomcat-8.0.14/bin
./startup.sh
Now the tomcat is started. You can check the log file at $INSTALL_DIR/logs/catalina.out. And you can also use web browser to verify if you can load the tomcat's home page at http://localhost:8080.

Tuesday, October 7, 2014

Build, Deploy, Test, And Debug JBoss Fuse Service Works Applications

Introduction

In my previous blog , I have explained the procedures to install and start JBoss FSW as a stand alone server. This article explains the process to build, deploy, Test, and Debug applications for JBoss FSW. After reading this, you, as a JBoss FSW developer, should be able to start develop integration applications based on the platform of JBoss FSW. For those who have used JBoss Development Studio before, this is an easy process. The only thing you need to do is to change the run time server from previous runtime server to the newly installed JBoss FSW.

Install JBoss Development Studio

The details about installation of JBDS is cover in Chapter 7 of this document.

After installing the JBDS, you need to install the runtime server. In my case, I installed my JBoss FSW at /Users/Gary2013/JBoss-FSW/. I call this FSW_HOME. Make sure you have the JBOSS_HOME defined as $FSW_HOME/jboss-eap-6.1. You may also build quickstarts examples from command line.

Import Quickstarts Project to JBDS

I have imported the follow project to my workspace

Modify pom.xml

The example comes with pom.xml with JDK 1.6. We need to change it to 1.7. Looking for 1.6 in the pom.xml file and change the two places to 1.7. You may see error. In this case, you need to update the maven project

Add JBoss FSW Server

Remove The Existing Server

You may have default runtime server, remove it.

Add JBoss FSW Runtime Server

File-->New--Other [or Command-N for macos], the type ser on search panel, you should see the following:

click Add button:
Click 6.1+ Runtime and Next
Select Configuration File. The configuration file is under $JBOSS_HOME/standalone/configuraiton/standalone-full.xml.
click Finish.

Now, your JBDS is configured to run applications on JBoss FSW runtiem. If you have already deployed the switchyard remote invoker project, remove it from the admin console.

Now, let's add the project to the runtime:

Run The Servier

Now we can run the server in either default running mode or in debug mode by click the bug button:
First let's run the server in normal mode. If you run into problem, such as, server cannot start. do the following:
  • shutdown studio
  • make sure there is not FSW runtime is running by run ps -eaf | egrep java
  • run the server outside studio by cd $JBOSS_HOME/bin, standalone.sh -c standalone-full.xml

If above procedure is all good, your application may be deployed to the runtime. There are two ways to deal with this kind of problem. The first is to go to $JBOSS_HOME/standalone/deployment. Make sure the remote-invoker jar file is not presented in the deployment dir. The other is start studio, from add/remove page to remove the war or jar file you are about to deploy.

If everything works, you should be able to see the following from the admin console:

Now, let's test the application from the studio. Do the following:
  • open the file: RemoteClient.java
  • run this client
You should see the following:
Now, you are in business!

Run Maven Project From Terminal

During our installation of FSW, we should tell the install where is our maven setting. If the setting is correct, you should be able to run mvn install command. You may take a look at your ~/.m2/settings.xml file. The RedHat related profile is added.

Wednesday, October 1, 2014

JBoss Service Works Explained

Introduction

The targeted reader for this article is for architects and developers who want to use JBoss Service Workss as integration platform. JBoss Service Works (JSW) is build on top of JBoss EAP and JBoss Fuse, together with Apache projects like Apache Camel, Apache CXF, Apache ActiveMQ, etc. I will focus on the new functionalities provided by JSW.

Installation

Installation Document can be found at this link Unfortunately, this document is not well written. I will provide simplest instructions here for those who are not patient to read all the sections of the document.
  • download Red Hat JBoss Fuse Service Works jar file from here.
  • creade dir such as JBoss-FSW
  • copy the jar file JBoss-FSW
  • execute: java -jar jboss-fsw-installer-6.0.0.GA-redhat-4.jar
  • enter all passwords as admin123!

If you encounter any problem during installation, make sure your JAVA_HOME is set to jdk1.7.0_67 or later one. See this article

Start the FSW

To start the server, do the following:

cd $JBOSS_HOME/bin
./standalone.sh -c standalone-full.xml
In a network environment, you may have to use the following command in order to allow the access to the admin console within the network.
./standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 -c standalone-full.xml

If the FSW started properly, you should see the following line in the stdout:
13:27:16,823 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990

The default page can accessed via: http://localhost:8080. On this page, you can click the link "Administration Console", login as

User Name: admin
Password: admin123!
If you have used JBoss EAP, this admin console page should be familiar to you. JBoss FSW added SwitchYard tab as shown in the following diagram: [note: I have deployed remote-invoker application. I will cover this later]

Important Server Information

Once you start the server, you should see the following information

=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /Users/Gary2013/FSW/jboss-eap-6.1

  JAVA: /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java

  JAVA_OPTS:  -server -XX:+UseCompressedOops -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djava.security.manager "-Djava.security.policy=./security.policy" "-Drtgov.security.policy=./rtgov.policy" "-Dkie.security.policy=./kie.policy"

=========================================================================

References

There are a lot of documents availabe at this page:
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse_Service_Works/

Anypoint Studio Error: The project is missing Munit lIbrary to run tests

Anypoint Studio 7.9 has a bug. Even if we following the article: https://help.mulesoft.com/s/article/The-project-is-missing-MUnit-libraries-...