Saturday, March 15, 2014

Mule REST on Tomcat (via Jersey)

I. Dependencies
  1. Mule server libraries (Mule standalone 3.3.x or later)
  2. Tomcat
  3. Eclipse (any IDE capable of the same)
II. Prerequisites
  1. Install Mule on Tomcat
  2. Create a Dynamic Web Application project in Eclipse and set Tomcat as deploy server
III. Design

IV. Service Class



public class HelloWorldService {

   public Response defaulMethod(){

      String output = "Hello World!";

      return Response.status(200).entity(output).build();

   public Response getMsg(@PathParam("param") String msg) {

      String output = "Hello " + msg + "!";

      return Response.status(200).entity(output).build();

   public SampleEO getEO() {
      SampleEO eo = new SampleEO();
      eo.setName("Juan dela Cruz");
      return eo;


V. Entity/Model Class

public class SampleEO {
   private String name;
   private int age;

   public String getName() {
      return name;
   public void setName(String name) { = name;
   public int getAge() {
      return age;
   public void setAge(int age) {
      this.age = age;

VI. Mule Config
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json=""

      <spring:import resource="classpath:sampleRestAppContext.xml"/>

   <flow name="restappFlow1" doc:name="restappFlow1">

   <servlet:inbound-endpoint path="restService" responseTimeout="10000"

   <jersey:resources doc:name="REST">
      <!--<component class=""/> -->
         <spring-object bean="helloWorldService"/>

VII. Spring Context
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<bean id="helloWorldService" class=""/>

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=""
xsi:schemaLocation="" id="WebApp_ID" version="2.5">



Download Project HERE

See MuleSoft (Mule ESB)

Saturday, February 2, 2013

How to Make Ubuntu 12.04 a Wi-Fi Hotspot from Your Wired Internet

All credits to Tan Zhijun 谭智军.

Figure 1
Figure 1
1. Right click network manager on the laptop with wireless hardware (these days most of laptops have wireless modules) and connected with internet by wired network (WLAN), then choose “Edit Connections…”, click it (Figure 1 at left).
Figure 2

2. Click the menu “Wireless”, and click “Add” button, then fill up the blanks as you like: your “Connection name”, “SSID”, then choose “Mode” option as “Ad-hoc”, for others no need to change, shown as Figure 3.

Figure 3
3. The next step is set up your key for the connection, click “Wireless Security”, choose “WEP 40/128-bit Key (Hex or ASCII)”, type your own “Key” if you do not want to make the whole world to share your WIFI, it is better make the length of the key as 5 that I tried successfully (Figure 4).

Figure 4
 4. Turn to “IPv4-Settings”, choose the option “Shared to other computers” for “Method”, as shown in Figure 5.

Figure 5

5. Do not make any change for “IPv6 Settings”, OK, click “Save” to finish the setup work, as shown in Figure 6.

Figure 6

original post:

Wednesday, December 26, 2012

How to Apply Verified SSL Certificate for Tomcat Using OpenSSL

Before anything else, I suggest that you work all of this in a single directory, something like apache_certs/.

1. Create the CSR (below is an example of generating CSR for - an actual and existing domain):
openssl req -new -newkey rsa:2048 -nodes -out host_name_com.csr
-keyout host_name_com.key -subj "/C=US/ST=Colorado/L=Denver/
LLC/OU=Test Department/"

2. The command above will produce two files : host_name_com.csr and host_name_com.key. You have to submit the contents of host_name_com.csr to the certificate authority, like, DigiCert, VeriSign, CACert, etc. You may use the URL below to validate your csr:

3. Once the validated certificate has been received, you have to combine the private key and verified certificate into a file as PKCS12 (set password; you may use tomcat's default, 'changeit'):
openssl pkcs12 -export -inkey host_name_com.key 
-in host_name_com.crt -out host_name_com.p12

host_name_com.key = key generated along with the csr host_name_com.crt = certificate received from the certificate authority host_name_com.p12 = the new file that will contain the key and the certificate

4. Add the p12 to your keystore, password should be similar to the one used on #3 (or tomcat's default, 'changeit')
keytool -importkeystore -destalias tomcat -destkeystore keystore.jks 
-srckeystore host_name_com.p12 -srcstoretype PKCS12 -alias 1
keystore.jks = my named keystore, default is ".keystore"

5. Modify tomcat's server.xml under conf folder:
<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol" 
SSLEnabled="true" keystoreFile="~/apache_certs/keystore.jks"
keystorePass="changeit" maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />

6. Restart the server. And when you access your applications, you should now see the verified certificate on your site.

Friday, November 30, 2012

Super Cow

Today when I woke up, my machine prompted me that an error occurred on retrieving updates.

"An error occurred, please run Package Manager from the right-click menu or apt-get in a terminal to see what is wrong. The error message was ..."

So I tried running apt-get in my terminal and here's the lighter side of ubuntu.

Here's another issued command:

The error wasn't so serious that seeing the Super Cow Powers made my day.