Yet!

geekery and stuff

twitter.com/iesahin on 2010-03-08

Comments

  • rdesktop connected Windows deliberately opened an iTunes and stopped receiving my mouse input, it's both a sin and hell to develop on Window #

Written by Emre

March 8th, 2010 at 8:45 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-03-06

Comments

  • "If you don’t have time to do it right, when will you have time to do it over?" – John Wooden #

Written by Emre

March 6th, 2010 at 10:45 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-03-02

Comments

  • @passpassive kafeyle beraber friendfeed de mi uçtu acaba? yazdığın tweet'ler maile gelmemiş, hayranınım ben aslında #

Written by Emre

March 2nd, 2010 at 10:45 pm

Posted in Uncategorized

Java Internet Connection Problems in Debian

Comments

The case is this: I have three computers running different versions of Debian GNU/Linux. The server has (stable) Lenny, my desktop computer at work has Sid (unstable) and my laptop has Squeeze (testing.) I want to install version 3 Glassfish application server to all of these.

The installation at the (Lenny) production server went straightforward, download the file, unzip it, then type

$ glassfish-v3/bin/asadmin start-domain

and let it start. Ordinary installation task ends here.

Then I wanted to repeat this on my desktop system and ended with an intense Googling and testing process.

The problem is this: When I repeat the above procedure in my desktop system and in my laptop, it reports a fault like this:

There is a process already using the admin port 4848 -- it probably is
another instance of a GlassFish server.
Command start-domain failed.

Then I wrote:

$ netstat -tlp --numeric-ports | grep 4848

Nothing returns, hence there is no process listening port 4848.

I googled a bit, people write about different kinds of workarounds related to this error, mostly related with /etc/hosts.

I played with /etc/hosts a bit, changing localhost addresses, adding and removing my LAN address as localhost, turning off interfaces, checking routes to no avail.

In the meantime I changed my java installations from OpenJDK to Sun JDK with

# update-alternatives --config java

and this also didn’t change anything.

I wrote the problem to java.net forums. Someone asked me to add another domain, so did I and nothing changed.

I purged Glassfish and downloaded NetBeans 6.8 and Glassfish bundle. It too couldn’t start Glassfish. Moreover, when Netbeans started, I noticed, I can’t connect to the Internet too.

My Java Internet connection was off.

This is a larger and more severe bug than a minor Glassfish problem and this was (against common sense) good news. It’s always easier to correct a large bug then a small one.

I then repeat the process above, playing with /etc/hosts, checking java configuration files in /etc and purging packages and reinstalling. This time, I tried to connect to Internet with a small program I found from Stack Overflow.

public static boolean isInternetReachable()
{
try {
    //      SecurityManager security =3D System.getSecurityManager();
    //      System.out.println(security.toString());
    //make a URL to a known source
    URL url =3D new URL("http://www.google.com");
    //open a connection to that source
    HttpURLConnection urlConnect =3D (HttpURLConnection)url.openConnection();
    //trying to retrieve data from the source. If there
    //is no connection, this line will fail
    Object objData =3D urlConnect.getContent();
} catch (UnknownHostException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return false;
}
catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return false;
}
return true;

This program resulted in following stack trace:

java.net.NoRouteToHostException: Network is unreachable
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163)
    at java.net.Socket.connect(Socket.java:542)
    at java.net.Socket.connect(Socket.java:492)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:174)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:409)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:240)
    at sun.net.www.http.HttpClient.New(HttpClient.java:321)
    at sun.net.www.http.HttpClient.New(HttpClient.java:338)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:814)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:755)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:680)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1005)
    at java.net.URLConnection.getContent(URLConnection.java:705)
    at internetConnection.testConnection.isInternetReachable(testConnection.java:26)
    at internetConnection.testConnection.main(testConnection.java:12)

Then I found somebody complaining about the same problem in NetBeans IRC logs.

Then I read all relevant pieces of code from OpenJDK’s java.net package. The problem, in my opinion, was java.net.InetAddress class’ handling of local addresses. It was simply returning false instead of checking whether an address is local or remote.

But this was to make all network handling of Java obsolote, so there should be some other problem, and there it is:

Quoting Debian Bug Report.

Netbase has recently introduced the sysctl-setting net.ipv6.bindv6only=3D1 in /etc/sysctl.d/bindv6only.conf and this setting will probably be the default in squeeze.

This setting breaks networking in java, and any traffic will for openjdk always result in a “java.net.NoRouteToHostException: Network is unreachable”.

It should probably be an rc-bug, but setting as important for now, since users can easily rectify the issue.

Quick fix for users hit by this:

sudo sed -i ’s/net.ipv6.bindv6only\ =3D\ 1/net.ipv6.bindv6only\ =3D\ 0/’ \ /etc/sysctl.d/bindv6only.conf && sudo invoke-rc.d procps restart

This is present in both Sun’s Java6 and OpenJDK6.

The solution is to type (as root):

# sysctl net.ipv6.bindv6only=3D0

and everything is fine now. This one line solves problem after 20 hours of active search and tests.

Now, I can (and should) complete the necessary Web Services.

Written by Emre

February 14th, 2010 at 12:25 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-02-07

Comments

  • RT @Mashouf: Most Muslim preachers I hear could shorten their sermons to 140 characters and save us all some time #Honestly #

Written by Emre

February 7th, 2010 at 8:45 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-02-04

Comments

  • insan duymadıklarına bakınca pek de üzülmüyor #

Written by Emre

February 4th, 2010 at 10:45 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-02-02

Comments

  • chatter stops / light talks / death is near #

Written by Emre

February 2nd, 2010 at 10:45 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-01-30

Comments

  • My email signature config file (.signify) now contains 550+ quotations #

Written by Emre

January 30th, 2010 at 8:45 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-01-21

Comments

Written by Emre

January 21st, 2010 at 10:45 pm

Posted in Uncategorized

twitter.com/iesahin on 2010-01-15

Comments

Written by Emre

January 15th, 2010 at 10:45 pm

Posted in Uncategorized