0

I create a Jersey-Grizzy-Server which runs fine on Win7. But after starting on Linux I'll get a strange, allways repeting Exception

java.lang.IllegalArgumentException: java.net.URISyntaxException: Expected hostname at index 8: https://:443/

, even if nothing is calling the server. The Rest Services are allways working. Did anbody has an idea, why this Exception rises, or how to start with debuging the grizzly2 Httpserver?

The Server Start is implemented like this (simplified):

boolean https = true;
int port = 9960;
URI baseURI = UriBuilder.fromUri("http" + (https ? "s" : "") + "://0.0.0.0/").port(port).build();

//Jersey Service Config
final ResourceConfig rc = new UriExtensionsConfig(GcardApplication.getConfigPackages());

// create Grizzly Container
final HttpHandler handler = ContainerFactory.createContainer(HttpHandler.class, rc);

//do the ssl Config
SLEngineConfigurator ssl = configSSL(https);

HttpServer server = GrizzlyServerFactory.createHttpServer(baseURI, handler, https, ssl);

The Log with the Exception:

INFO: Initiating Jersey application, version 'Jersey: 1.11 12/09/2011 10:27 AM'
May 7, 2012 8:20:45 PM org.glassfish.grizzly.http.server.NetworkListener start
INFO: Started listener bound to [0.0.0.0:9960]
May 7, 2012 8:20:45 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
Crm WS Server started at https://localhost:9960/

Hit Ctrl C to stop the server ...
May 7, 2012 8:20:46 PM org.glassfish.grizzly.http.server.HttpHandler doHandle
SEVERE: service exception
java.lang.IllegalArgumentException: java.net.URISyntaxException: Expected hostname at index 8: https://:443/
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer.getBaseUri(GrizzlyContainer.java:226)
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer._service(GrizzlyContainer.java:195)
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer.service(GrizzlyContainer.java:185)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
    at org.glassfish.grizzly.http.server.HttpHandlerChain.service(HttpHandlerChain.java:195)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:158)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:286)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:223)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:155)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:134)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:827)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:103)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:111)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:131)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:508)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:488)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.URISyntaxException: Expected hostname at index 8: https://:443/
    at java.net.URI$Parser.fail(URI.java:2810)
    at java.net.URI$Parser.failExpecting(URI.java:2816)
    at java.net.URI$Parser.parseHostname(URI.java:3352)
    at java.net.URI$Parser.parseServer(URI.java:3198)
    at java.net.URI$Parser.parseAuthority(URI.java:3117)
    at java.net.URI$Parser.parseHierarchical(URI.java:3059)
    at java.net.URI$Parser.parse(URI.java:3015)
    at java.net.URI.<init>(URI.java:662)
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer.getBaseUri(GrizzlyContainer.java:223)
    ... 20 more
May 7, 2012 8:20:49 PM org.glassfish.grizzly.http.server.HttpHandler doHandle
SEVERE: service exception
java.lang.IllegalArgumentException: java.net.URISyntaxException: Expected hostname at index 8: https://:443/
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer.getBaseUri(GrizzlyContainer.java:226)
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer._service(GrizzlyContainer.java:195)
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer.service(GrizzlyContainer.java:185)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
    at org.glassfish.grizzly.http.server.HttpHandlerChain.service(HttpHandlerChain.java:195)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:158)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:286)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:223)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:155)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:134)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:827)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:103)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:111)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:131)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:508)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:488)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.URISyntaxException: Expected hostname at index 8: https://:443/
    at java.net.URI$Parser.fail(URI.java:2810)
    at java.net.URI$Parser.failExpecting(URI.java:2816)
    at java.net.URI$Parser.parseHostname(URI.java:3352)
    at java.net.URI$Parser.parseServer(URI.java:3198)
    at java.net.URI$Parser.parseAuthority(URI.java:3117)
    at java.net.URI$Parser.parseHierarchical(URI.java:3059)
    at java.net.URI$Parser.parse(URI.java:3015)
    at java.net.URI.<init>(URI.java:662)
    at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer.getBaseUri(GrizzlyContainer.java:223)
    ... 
mbue
  • 1
  • 2
  • have you configured loopback address (/etc/hosts, probably) in your linux distro? – Flavio Cysne May 07 '12 at 19:25
  • We have already configured /etc/hosts with 127.0.0.1 localhost – mbue May 08 '12 at 08:29
  • Could get the Jersey Logger to work. And there I can see from where my server is called. It looks like the reverseproxy is calling on port:9960 and not on 443. – mbue May 08 '12 at 18:35

2 Answers2

0

https://:443/ is not a valid URL - there is no host name.

From your code, I see that you call UriBuilder.fromUri("https://0.0.0.0/")

Is "0.0.0.0" really a valid value here?

Check the output of the commands hostname and domainname; they should return useful values (domainname isn't that critical but it's better if it has some useful value).

Also see this answer how to determine the IP address of yourself: How to get the ip of the computer on linux through Java?

[EDIT] You are probably looking at the wrong place in the code. Set a breakpoint in the constructor of URISyntaxException and find out where the broken URI comes from.

Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • The Jersey Factory assigns it internally from URI u: final String host = (u.getHost() == null) ? NetworkListener.DEFAULT_NETWORK_HOST : u.getHost(); with constant String DEFAULT_NETWORK_HOST = "0.0.0.0" But the same issu with 2 network listener 1 for localhost and the other one for the server IP. – mbue May 08 '12 at 10:48
  • Ah. The code you posted is for the setup of Jersy. But that part does work as you can see in the log (port=9660). You need to check the code that creates URLs for SSL access (code where the port is 443). – Aaron Digulla May 08 '12 at 10:53
  • The server runs. There is no networklistener on port 443. From where is this request comming? netstat -apl | grep 443 unix 2 [ ACC ] STREAM LISTENING 27443 - private/scache – mbue May 08 '12 at 11:01
  • I'm working on geting a port opened from the security department for debug purposes. – mbue May 08 '12 at 11:05
  • As I said: Create a breakpoint in the constructor and you will know. Whoever tries to make the connection must eventually come through this part of the code or you wouldn't get the exception in the log :-) – Aaron Digulla May 08 '12 at 11:38
0

The Source off the Problem was the the Config of the ReversProxys Healthcheck which had the following Send String

GET / HTTP/1.1\r\nHost: \r\nConnection: close\r\n\r\n

We had to correct the Get Request to

GET https://servername:9960/ HTTP/1.1\r\nHost: originalservername\r\nConnection: close\r\n\r\n
mbue
  • 1
  • 2