BindAddress exception error (was BindAddress error with jdk1.5 and Tomcat and Resin)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

BindAddress exception error (was BindAddress error with jdk1.5 and Tomcat and Resin)

Richard Schilling-4
I'm narrowing down a problem with BindAddress on jdk1.5, FreeBSD RELENG_6 .

uname -a output:
FreeBSD newbox.cognitiongroup.biz 6.0-STABLE FreeBSD 6.0-STABLE #3: Fri
Nov  4 23:36:56 PST 2005
[hidden email]:/usr/obj/usr/src/sys/PRODUCTION  amd64

Here's the error:

$ java TestServer localhost 8080
Host Address=localhost
Port        =8080
Exception in thread "main" java.net.BindException: Can't assign
requested address
         at java.net.PlainSocketImpl.socketBind(Native Method)
         at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
         at java.net.ServerSocket.bind(ServerSocket.java:319)
         at java.net.ServerSocket.bind(ServerSocket.java:277)
         at TestServer.main(TestServer.java:15)
$


Check out http;//bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206527

I'm able to reproduce the error with the following code, with IPv6
enabled and with IPv6 disabled...

import java.net.*;

public class TestServer {

         public static void main (String[] args) throws Exception {
                 if (args.length   != 2) {
                         System.out.println("Usage: java TestServer
<host_address_ipv6> <port>");
                         System.exit(1);
                 }

                 System.out.println("Host Address="+args[0]);
                 System.out.println("Port        ="+args[1]);
                 ServerSocket ss = new ServerSocket();

                 ss.bind(new
InetSocketAddress(InetAddress.getByName(args[0]),
  Integer.parseInt(args[1])));

                 System.out.println("ServerSocket Bound");

                 ss.accept();
         }
}


_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: BindAddress exception error (was BindAddress error with jdk1.5 and Tomcat and Resin)

Sean McNeil
On Fri, 2005-11-11 at 16:37 -0800, Richard Schilling wrote:

> I'm narrowing down a problem with BindAddress on jdk1.5, FreeBSD RELENG_6 .
>
> uname -a output:
> FreeBSD newbox.cognitiongroup.biz 6.0-STABLE FreeBSD 6.0-STABLE #3: Fri
> Nov  4 23:36:56 PST 2005
> [hidden email]:/usr/obj/usr/src/sys/PRODUCTION  amd64
>
> Here's the error:
>
> $ java TestServer localhost 8080
> Host Address=localhost
> Port        =8080
> Exception in thread "main" java.net.BindException: Can't assign
> requested address
>          at java.net.PlainSocketImpl.socketBind(Native Method)
>          at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
>          at java.net.ServerSocket.bind(ServerSocket.java:319)
>          at java.net.ServerSocket.bind(ServerSocket.java:277)
>          at TestServer.main(TestServer.java:15)

What does

netstat -a | grep 8080

show you?

Have you tried starting it with

java.net.preferIPv4Stack=true

set?

Cheers,
Sean


_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: BindAddress exception error (was BindAddress error with jdk1.5 and Tomcat and Resin)

Richard Schilling-4
This was the fix.  Thanks' Sean.  (I'll honor the free web hosting BTW)

Here's what I did.  I added the following line to /etc/rc.conf:

jakarta_tomcat55_java_opts="-Djava.net.preferIPv4Stack=true"

JDK1.5 chokes on binding to any address with FreeBSD 6.0 because of the
IPv6 stack.

The JDK documentation on IPv6 documents this command line define, also.

On a related note, when I tried to build JDK1.5 with IPV6 support, I got
an error.  But, that's a subject for another thread, I think.

Thanks Sean.

Richard



Sean McNeil wrote:

> On Fri, 2005-11-11 at 16:37 -0800, Richard Schilling wrote:
>
>>I'm narrowing down a problem with BindAddress on jdk1.5, FreeBSD RELENG_6 .
>>
>>uname -a output:
>>FreeBSD newbox.cognitiongroup.biz 6.0-STABLE FreeBSD 6.0-STABLE #3: Fri
>>Nov  4 23:36:56 PST 2005
>>[hidden email]:/usr/obj/usr/src/sys/PRODUCTION  amd64
>>
>>Here's the error:
>>
>>$ java TestServer localhost 8080
>>Host Address=localhost
>>Port        =8080
>>Exception in thread "main" java.net.BindException: Can't assign
>>requested address
>>         at java.net.PlainSocketImpl.socketBind(Native Method)
>>         at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
>>         at java.net.ServerSocket.bind(ServerSocket.java:319)
>>         at java.net.ServerSocket.bind(ServerSocket.java:277)
>>         at TestServer.main(TestServer.java:15)
>
>
> What does
>
> netstat -a | grep 8080
>
> show you?
>
> Have you tried starting it with
>
> java.net.preferIPv4Stack=true
>
> set?
>
> Cheers,
> Sean
>
>
>
>
>

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
To unsubscribe, send any mail to "[hidden email]"