And Todays’s Quote Would Be..

Life begins at the end of your comfort zone.

Neale Donald Walsch

[Mule] Error 400 Bad Request, Request Header Or Cookie Too Large

I had an error yersterday, when connecting Mule ESB to NGinx. Very weird, because somehow it never shown any errors when fired directly without a reverse proxy. Here is the complete stacktrace

<head><title>400 Request Header Or Cookie Too Large</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>Request Header Or Cookie Too Large</center>
<hr><center>nginx/1.4.4</center>
</body>
</html>
 (javax.xml.ws.soap.SOAPFaultException)
  org.apache.cxf.jaxws.JaxWsClientProxy:156 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/xml/ws/soap/SOAPFaultException.html)
3. Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: <html>
<head><title>400 Request Header Or Cookie Too Large</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>Request Header Or Cookie Too Large</center>
<hr><center>nginx/1.4.4</center>
</body>
</html>

It happens because Mule, by default, send a very large cookies called “X-MULE_SESSION”. After removing it, my ESB runs well again. This is how i remove it,

<http:connector name="NoSessionConnector">
	    <service-overrides sessionHandler="org.mule.session.NullSessionHandler"/>
</http:connector>
Google+

Weird Error on Java Mail, “javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client”

I run into a weird error that never happened before, somehow it happened since my user upgrade their Microsoft Mail Exchange’s version. Here is the complete stacktrace,

Caused by: javax.mail.AuthenticationFailedException: 
No authentication mechansims supported by both server and client
    at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:760)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:673)
    at javax.mail.Service.connect(Service.java:317)

I guess there are several reasons why it happens. First of all, it happens because im using starttls = “true” despite im connecting to port 25, first i change it into “false”. And the other thing is that im using username and password for connecting to my email exchange server, so the workaround is quite easy, just setting my mail.smtp.auth parameter into “false” instead of “true”. Or try sending email without setting username and password.

But actually, it’s much easier to fix the error on the mail server’s side, because it’s only a simple checklist configuration :-P

Google+

Download A Compressed Attachment (Zip, Rar or 7Z) on GMail

I want to download a compressed file that i’ve sent several years ago, but somehow google disabled it, and gives an “anti virus warning”. And it happen for all my email with compressed attachments files, such as .zip, .rar and also .7z.

compressed download

Well, the workaround is quite simple, im opening my email using my Android GMail client , and then save my attachment to Google Drive.

7zip

From Google Drive, i can easily download my attachment freely.
google drive

Hopefully it can help other people. :-D

Google+

Creating Alphabet Numbering on Jasper Report

Usually jasper report provide a numbering, accessible using REPORT_COUNT variable, but today my friend Edward Barchia asked me something interesting, how can i create a simple numbering using alphabet instead of number. Well basically, it’s actually quite easy.

Below is the image, how i do it.
jasperreportcharat

Here is my complete jasper xml file,

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="97dae3d4-5e81-4825-b4e7-cf3d1f77190f">
	<property name="ireport.zoom" value="1.2100000000000002"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="42"/>
	<queryString language="SQL">
		<![CDATA[select * from testing]]>
	</queryString>
	<field name="id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="name" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="address" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="79" splitType="Stretch"/>
	</title>
	<pageHeader>
		<band height="35" splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="20" splitType="Stretch">
			<staticText>
				<reportElement x="50" y="0" width="100" height="20" uuid="f68bc18a-5471-4d4f-89ed-34d98bb06b6e"/>
				<text><![CDATA[name]]></text>
			</staticText>
			<staticText>
				<reportElement x="150" y="0" width="100" height="20" uuid="155f7ce1-e70c-4d93-8ebc-bad45d9f0ae1"/>
				<text><![CDATA[address]]></text>
			</staticText>
			<staticText>
				<reportElement x="0" y="0" width="50" height="20" uuid="48b8e6ef-1efd-4233-98f5-b2da6d273333"/>
				<text><![CDATA[No]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="20" splitType="Stretch">
			<textField>
				<reportElement x="50" y="0" width="100" height="20" uuid="3ffd3edf-b950-4dd9-8f13-ac8942e5bb8e"/>
				<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="150" y="0" width="100" height="20" uuid="236aec6c-34dc-4a54-ae2d-086c2a23786c"/>
				<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="0" y="0" width="50" height="20" uuid="704b47d3-7dca-4f33-950a-a3efd0fb764b"/>
				<textFieldExpression><![CDATA["abcdefghijklmnopqrstuvwxyz".charAt( $V{REPORT_COUNT}-1 )]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="45" splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band height="54" splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band height="42" splitType="Stretch"/>
	</summary>
</jasperReport>
Google+

[Java] SMS Gateway dengan Modem Zoglab Q2687RD

Baru-baru ini gw dapet kerjaan untuk membuat suatu sistem notifikasi yang terhubung dengan modem SMS, kebetulan modem yang dipakai adalah modem dengan merk Zoglab seri Q2687RD. Awalnya gw pikir menggunakan metode konvensional, menggunaan 7bit sms gateway ala-ala skripsi jaman gw masih kuliah, dan ternyata rada berbeda format AT Command-nya.

Oh ya, sebelumnya ini adalah wujud modemnya. Sekilas agak aneh, karena ada colokan power dibelakangnya tapi waktu membeli engga dapet kabel powernya. Ternyata powernya bisa lewat kabel USB.

modem zoglab

Oke, berikut adalah class java yang gw gunakan untuk testing sending SMS, kebetulan gw menggunakan library RXTXcomm.jar.

package com.edw.commportchecker;

import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.OutputStream;
import java.util.Enumeration;

public class Main {

    private OutputStream outputStream;
    private SerialPort serialPort;

    private void doSomething()
            throws Exception {
        Enumeration portList = CommPortIdentifier.getPortIdentifiers();
        System.out.println(portList.hasMoreElements());
        while (portList.hasMoreElements()) {
            CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
            if (portId.getPortType() == 1) {
                System.out.println("connecting to " + portId.getName());
            }
            // kebetulan modem kedetect sebagai COM3
            if (portId.getName().equalsIgnoreCase("COM3")) {
                this.serialPort = ((SerialPort) portId.open("SMSGateway", 2000));
            }
        }


        this.serialPort.setSerialPortParams(9600, 8, 1, 0);
        this.serialPort.setFlowControlMode(0);

        this.outputStream = this.serialPort.getOutputStream();

        System.out.println("sending");

        // gunakan prefix +62, contoh : +62856727xxxx 
        // agak aneh nih, sebelumnya tanpa prefix "+" jalan, tapi ditengah jalan tiba2 jadi ga jalan T_T
        String nomerHp = ""; 
        
        // content sms yang akan dikirim
        String contentSMS = "ini isi sms-nya";
        
        sendToStream("AT\r");
        sendToStream("AT+CMGF=1\r");
        sendToStream("AT+CMGS=\""+nomerHp+"\"\r\n");
        sendToStream(contentSMS);
        sendToStream("\032");

        System.out.println("finish");

        System.exit(1);
    }

    private void sendToStream(String content) throws Exception {
        System.out.println(">" + content);

        this.outputStream.write(content.getBytes());
        this.outputStream.flush();

        Object o = new Object();
        synchronized ( o ) {
            o.wait(1500L);
        }
    }

    public static void main(String[] args) {
        Main main = new Main();
        try {
            main.doSomething();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Google+