saiddfhi / gwt-maven

Automatically exported from code.google.com/p/gwt-maven
0 stars 0 forks source link

"java.net.MalformedURLException: unknown protocol: c" in GwtWebInfProcessor (path spaces) #91

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The problem happens on Maven 2 (presumably Maven 1 as well) and is related
to the way Windows systems interpret URIs.

"mvn clean package" fails with exception like:

java.net.MalformedURLException: unknown protocol: c
        at java.net.URL.<init>(URL.java:574)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLE
ntityManager.java:
650)
        at
com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(X
MLVersionDetector.java:
186)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configu
ration.java:
771)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configu
ration.java:
737)
        at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:
107)
        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXPa
rser.java:
1205)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
$JAXPSAXParser.parse(SAXParserImpl.java:522)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
        at
com.totsp.mavenplugin.gwt.support.GwtWebInfProcessor.getWebXml(GwtWebInfProcesso
r.java:
216)
        at
com.totsp.mavenplugin.gwt.support.GwtWebInfProcessor.insertServlets(GwtWebInfPro
cessor.java:
231)
        at
com.totsp.mavenplugin.gwt.support.GwtWebInfProcessor.process(GwtWebInfProcessor.
java:
297)
        at
com.totsp.mavenplugin.gwt.support.GwtWebInfProcessorTest.testProcess(GwtWebInfPr
ocessorTest.java:
38)
        at
com.totsp.mavenplugin.gwt.support.GwtWebInfProcessorTest.testProcess(GwtWebInfPr
ocessorTest.java:
38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:
25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:
25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:
213)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(Abstra
ctDirectoryTestSuite.java:
138)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirec
toryTestSuite.java:
125)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:
25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBoote
r.java:290)
        at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)

The error is described in detail in following thread
http://groups.google.com/group/gwt-maven/browse_thread/thread/138ffe67dbd598d1/4
aae58c613952b2b#4aae58c613952b2b

It happens when you have your code located in a folder with name containing
spaces, for example:
"C:\Documents and Settings\admin\gwt_project" 
all the tasks related to 
com.totsp.mavenplugin.gwt.support.GwtWebInfProcessor.getWebXml
will throw an exception. 

Sould be easy to reproduce.

The solution described in the thread to invoke SAXBuilder.build based on
File instead of String should work

Original issue reported on code.google.com by awa...@op.pl on 28 Mar 2008 at 10:12

GoogleCodeExporter commented 9 years ago
Workaround that works form me
add webXml location with full path, like this:
 <configuration>
...
<webXml>${project.home}/src/main/webapp/WEB-INF/web.xml</webXml>
...
 </configuration>

Original comment by msteiner...@gmail.com on 3 Apr 2008 at 7:18

GoogleCodeExporter commented 9 years ago
Does this really help? For us the plugin still fails in gwt:mergewebxml and if 
we
comment out gwt:mergewebxml it fails in gwt:compile. 

I am not sure how your solution could work as the code:
http://code.google.com/p/gwt-maven/source/browse/trunk/maven-googlewebtoolkit-su
pport/src/java/com/totsp/mavenplugin/gwt/support/GwtWebInfProcessor.java
line 216 still uses String as parameter to SAXBuilder.build() so in my opinion 
the
error should be and is the same.

Original comment by awa...@op.pl on 4 Apr 2008 at 11:09

GoogleCodeExporter commented 9 years ago
This is something we definitely need to address, it's a common problem in 
several
Maven projects though, not just this one - relating to using a location with 
spaces
in the path.

Workaround, and probably smart policy in general, is to not use paths with 
spaces. 

I will try to get this fixed soon though, as yes, it is valid, and should be 
fixed.
The report is much appreciated. 

Original comment by charlie....@gmail.com on 4 Apr 2008 at 11:38

GoogleCodeExporter commented 9 years ago
I fully agree that the spaces are not the wisest approach, but for example in 
our
case - the company CI server is configured this way, a number of projects do 
work
there and unfortunately our team is the first that suffer from this problem. We 
can
ask for reconfiguring the server, but still the impression is not good.

Thank you for looking at it.

Original comment by awa...@op.pl on 4 Apr 2008 at 1:24

GoogleCodeExporter commented 9 years ago
We have several new contributors working on the Windows spaces issues.  Should 
be
movement here soon. 

Original comment by charlie....@gmail.com on 17 Apr 2008 at 4:28

GoogleCodeExporter commented 9 years ago
Here's a patch that solved the issue for me:

Index: maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/Sc
riptWriterWindows.java
===================================================================
--- maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/Scrip
tWriterWindows.java     (Revision 622)
+++ maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/Scrip
tWriterWindows.java     (Arbeitskopie)
@@ -117,7 +117,7 @@
             writer.print(mojo.getStyle());

             writer.print(" -out ");
-            writer.print(mojo.getOutput().getAbsolutePath());
+            writer.print("\"" + mojo.getOutput().getAbsolutePath() + "\"");
             writer.print(" ");

             if (mojo.isEnableAssertions()) {

Original comment by michaelh...@gmail.com on 8 Jun 2008 at 5:26

GoogleCodeExporter commented 9 years ago
Oops, wrong diff, I apologize. Here's the one that solved this, but may need a 
little more generalizing:

Index: maven-googlewebtoolkit-
support/src/java/com/totsp/mavenplugin/gwt/support/GwtWebInfProcessor.java
===================================================================
--- maven-googlewebtoolkit-
support/src/java/com/totsp/mavenplugin/gwt/support/GwtWebInfProcessor.java   
(Revision 622)
+++ maven-googlewebtoolkit-
support/src/java/com/totsp/mavenplugin/gwt/support/GwtWebInfProcessor.java   
(Arbeitskopie)
@@ -235,7 +235,9 @@
         if (this.webXml == null) {
             SAXBuilder builder = new SAXBuilder(false);
             builder.setFeature("http://apache.org/xml/features/nonvalidating/load-
external-dtd", false);
-            return this.webXml = builder.build(this.webXmlPath);
+            File webXmlUrl = new File(this.webXmlPath);
+            System.out.println("Reading source web.xml: "+webXmlUrl.toURL());
+            return this.webXml = builder.build(webXmlUrl.toURL());
         }
         else {
             return this.webXml;

Original comment by michaelh...@gmail.com on 8 Jun 2008 at 5:30

GoogleCodeExporter commented 9 years ago
Thanks for the patch.  There hasn't been any movement on this as new contribs 
never
really contributed, yet.  At some point I will try to get this in. 

Original comment by charlie....@gmail.com on 1 Jul 2008 at 6:11

GoogleCodeExporter commented 9 years ago
I changed it to this in SVN: return this.webXml = builder.build(new
File(this.webXmlPath).toURL());. 

To file.toUrl is deprecated, which is ugly, it does work. 

Since this is now in SVN (version 1.6.0 of support jar), it will get merged into
trunk soon. 

Original comment by charlie....@gmail.com on 15 Aug 2008 at 2:28

GoogleCodeExporter commented 9 years ago
Fixed as of 2.0-beta22

Original comment by charlie....@gmail.com on 7 Sep 2008 at 10:41

GoogleCodeExporter commented 9 years ago
thanks man you saved my day

Original comment by shareinf...@gmail.com on 3 Jul 2011 at 10:03