java.net.MalformedURLException: no protocol:

1,620 views
Skip to first unread message

pierrot

unread,
Mar 4, 2007, 5:37:28 PM3/4/07
to Google Web Toolkit
Hello,

I have developed a RPC service to read data from an XML file. It works
fine in Eclipse but I always get java.net.MalformedURLException: no
protocol: size.xml when I execute it in hosted mode.

Here is an excerpt of the module that seems to be causing the problem:

private void parseXmlFile() {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
dom = db.parse("size.xml");
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

As I said it works in Eclipse and here is the error messages in the
host console:

java.net.MalformedURLException: no protocol: size.xml
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at
org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.
java:796)
at
org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntity
Manager.java:741)
at
org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocum
entScannerImpl.java:260)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:498)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:580)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:
152)
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:
253)
at
org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.
java:201)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at
com.uniksoft.server.SizeServiceImpl.parseXmlFile(SizeServiceImpl.java
:52)
at
com.uniksoft.server.SizeServiceImpl.getAllSize(SizeServiceImpl.java:4
2)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(Remot
eServiceServlet.java:281)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServ
iceServlet.java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
802)

It seems GWT expect me to specify the size.xml file with a URL. But
this file happens to be on the same disk than my GWT installation.

Does anybody have any suggestion at all as to what could be the
problem?

Cheerio.

pierrot

unread,
Mar 4, 2007, 8:33:32 PM3/4/07
to Google Web Toolkit
Hello everyone,

After a few trials and errors I finally figured out what the problem
was.

I changed the line

dom = db.parse("size.xml");

to

dom = db.parse("http://localhost:8888/com.uniksoft.sgtPepperoni2/
size.xml");

and it did rock & rolled big time!

Cheerio

Adam T

unread,
Mar 5, 2007, 6:51:32 AM3/5/07
to Google Web Toolkit
Hi Pierre,

You might want to use:

dom = db.parse(GWT.getBaseModuleURL()+"size.xml");

as that should protect you when moving your application between web
servers with different URLs the result of GWT.getBaseModuleURL()
should return the "http://localhost:8888/com.uniksoft.sgtPepperoni2/"
part for you.

//Adam
Coauthor of GWT In Action http://www.manning.com/hanson

> > Cheerio.- Dölj citerad text -
>
> - Visa citerad text -

pierrot

unread,
Mar 5, 2007, 8:01:07 AM3/5/07
to Google Web Toolkit
Hi Adam,

I did the change you mentined but here is the error I get in the
Development Tool:

[WARN] StandardContext[]Exception while dispatching incoming RPC call
java.lang.UnsatisfiedLinkError:
com.google.gwt.core.client.Impl.getModuleBaseURL()Ljava/lang/String;
at com.google.gwt.core.client.GWT.getModuleBaseURL(GWT.java:77)
at
com.uniksoft.server.SizeServiceImpl.parseXmlFile(SizeServiceImpl.java:
61)
at
com.uniksoft.server.SizeServiceImpl.getAllSize(SizeServiceImpl.java:
48)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
281)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:


167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at
com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:
248)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
237)

[ERROR] Error
com.google.gwt.user.client.rpc.InvocationException: The call failed on
the server; see server log for details
at com.uniksoft.client.SizeService_Proxy$1.onCompletionImpl(transient
source for com.uniksoft.client.SizeService_Proxy:59)
at com.uniksoft.client.SizeService_Proxy
$1.onCompletionAndCatch(transient source for
com.uniksoft.client.SizeService_Proxy:43)
at com.uniksoft.client.SizeService_Proxy$1.onCompletion(transient
source for com.uniksoft.client.SizeService_Proxy:37)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:
107)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:
140)

Here is the single change I made:

//dom = db.parse("http://localhost:8888/com.uniksoft.sgtPepperoni2/
size.xml");

to:

dom = db.parse(GWT.getModuleBaseURL() + "size.xml");

I don't have any clue of what's going on behind the scenes. Do you?

Cheerio


On Mar 5, 6:51 am, "Adam T" <adam.t...@gmail.com> wrote:
> Hi Pierre,
>
> You might want to use:
>
> dom = db.parse(GWT.getBaseModuleURL()+"size.xml");
>
> as that should protect you when moving your application between web
> servers with different URLs the result of GWT.getBaseModuleURL()
> should return the "http://localhost:8888/com.uniksoft.sgtPepperoni2/"
> part for you.
>
> //Adam

> Coauthor of GWT In Actionhttp://www.manning.com/hanson

pierrot

unread,
Mar 5, 2007, 8:20:39 AM3/5/07
to Google Web Toolkit
Hi Adam,

I also tried the following statement but it keeps failing the
application:

System.out.println("BaseURL = " + GWT.getModuleBaseURL());

Any idea at all?

Cheerio

On Mar 5, 6:51 am, "Adam T" <adam.t...@gmail.com> wrote:

> Hi Pierre,
>
> You might want to use:
>
> dom = db.parse(GWT.getBaseModuleURL()+"size.xml");
>
> as that should protect you when moving your application between web
> servers with different URLs the result of GWT.getBaseModuleURL()
> should return the "http://localhost:8888/com.uniksoft.sgtPepperoni2/"
> part for you.
>
> //Adam

> Coauthor of GWT In Actionhttp://www.manning.com/hanson

Adam T

unread,
Mar 5, 2007, 8:26:12 AM3/5/07
to Google Web Toolkit
Hej Pierre,

Ignore me; I was obviously having a lost brain moment over lunch!!
This code is in your server side implementation, right? If so, then
the GWT.getModuleBaseURL() method is not relevant as it is more for
client side code!

On the server side it depends on where your size.xml file is. If is
is always going to be in one location on the same server forever then
you could take the approach you have and hard code it in. If it is
always going to be somewhere relative to where your servlet / RPC
service class is, then you could use one of the methods in
HttpServletRequest class(http://java.sun.com/j2ee/sdk_1.3/techdocs/api/
javax/servlet/http/HttpServletRequest.html) to get the URL or URI of
the servlet and then navigate to the relative path (e.g.
request.getRequestURL()+"../../XMLDump/")

//Adam

On 5 Mar, 14:01, "pierrot" <pierre.lasa...@gmail.com> wrote:
> Hi Adam,
>
> I did the change you mentined but here is the error I get in the
> Development Tool:
>
> [WARN] StandardContext[]Exception while dispatching incoming RPC call
> java.lang.UnsatisfiedLinkError:
> com.google.gwt.core.client.Impl.getModuleBaseURL()Ljava/lang/String;
> at com.google.gwt.core.client.GWT.getModuleBaseURL(GWT.java:77)
> at
> com.uniksoft.server.SizeServiceImpl.parseXmlFile(SizeServiceImpl.java:
> 61)
> at
> com.uniksoft.server.SizeServiceImpl.getAllSize(SizeServiceImpl.java:
> 48)
> at

> com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServi­ceServlet.java:


> 281)
> at
> com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceSer­vlet.java:
> 167)

> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at
> com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:
> 248)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at

> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio­nFilterChain.java:

> > > - Visa citerad text -- Dölj citerad text -

pierrot

unread,
Mar 5, 2007, 9:25:29 AM3/5/07
to Google Web Toolkit
Thanks Adam,

I had thought of using the request.getRequestURL() method but I was
hoping it would have been possible
to use GWT.getModuleBaseURL() on the server side as well as on the
client side.

Cheerio

Reply all
Reply to author
Forward
0 new messages