emacs-eclim icon indicating copy to clipboard operation
emacs-eclim copied to clipboard

java.net.URISyntaxException: Illegal character in authority at index 7

Open jsuper opened this issue 10 years ago • 7 comments

Emacs-eclim can not work on windows 7. I have installed vim on my PC, it can work correctly.

emacs-eclim command log

C:/Work/worktools/eclipse_kepler/eclipse/eclim.bat -command project_by_resource -f c\:/Users/tangilin/Test.java

eclim output

NGSession 1: 127.0.0.1: org.eclim.command.Main exited with status 1

Execute the command from command line

command

c:\Work\worktools\eclipse_kepler\eclipse\eclim.bat -command project_by_resource -f c:\Users\tangilin\workspace\hello_project\src\org\tony\Main.java

output

java.net.URISyntaxException: Illegal character in authority at index 7: file://c
:\Users\tangilin\workspace\hello_project\src\org\tony\Main.java
        at java.net.URI$Parser.fail(URI.java:2809)
        at java.net.URI$Parser.parseAuthority(URI.java:3147)
        at java.net.URI$Parser.parseHierarchical(URI.java:3058)
        at java.net.URI$Parser.parse(URI.java:3014)
        at java.net.URI.<init>(URI.java:578)
        at org.eclim.plugin.core.command.project.ProjectByResource.execute(ProjectByResource.java:55)
        at org.eclim.command.Main$1.run(Main.java:100)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
        at org.eclim.eclipse.EclimApplication.start(EclimApplication.java:85)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1450)

jsuper avatar Aug 13 '13 06:08 jsuper

I have never seen this issue myself, but the error message seems to suggest there is a problem either with the encoding of you source file, or a bug in eclim. I can't help you there, alas.

fred-o avatar Aug 29 '13 14:08 fred-o

From the sound of similar exceptions (in different pieces of software), it sounds like the URI class can get confused as to what elements of the passed string (the file in this case) is scheme, port and path.

I don't use Windows, so I don't know if this is completely off, but does using only forward slashes in the path, or prefixing the file with file:// help at all?

skybert avatar Sep 23 '13 17:09 skybert

I wonder if the backslashes in the file path is causing some of the characters to be interpreted as escape sequences perhaps?

fred-o avatar Oct 14 '13 17:10 fred-o

I run into the same problem when I tried to use the eclim-complete, (The project functions such as eclim-project-info were fine on the other way) Looked like the argument passed to the eclim.bat was wrong.

-command project_by_resource -f d\:/leo/src/xxx.java

After I change the eclim.bat file to make it replace the "d:" with “d:" , the complete function started to work.

PS: Windows 7, eclim 2.3.2, Emacs 24.3.

leodream avatar Nov 06 '13 10:11 leodream

Standard URIs do not accept backslash (\) as path segment delimiter. java.net.URI will throw URISyntaxException at any syntax violation of RFC 2396 (an old version of the URI syntax standard).

In this case, just replacing backslashes with slashes (/) might do the job (e.g. new URI(str.replace("\\", "/"))). For a more general solution, you can look at the WHATWG URL Standard for some hints about file:// URLs parsing. I have a working implementation that might be useful too: https://github.com/smola/galimatias

smola avatar Jan 05 '14 15:01 smola

I get the same problem with the file name passed by Emacs to eclim.bat. For example:

Error running timer `ac-update-greedy': (error "Illegal character in authority at index 7:
file://d\\:/Users/fni/Projects/dummy.java")

Though, I don't know how to change this. It seems to be the parameter %*in eclim.bat, but that's out of my control.

fniessen avatar Jun 19 '15 13:06 fniessen

This is how you solve the problem as leodream mentioned four years ago. First you will require cygwin be available on the path. Once you have that the remainder is easy. Here is the repaired file.

set CUR_PATH=%~dp0
set JAVA_CMD="%CUR_PATH%\ng" --nailgun-port 9091

echo %* | tr -d \\ > dump.txt
set /p TRANSLATED= < dump.txt
rm dump.txt

%JAVA_CMD% org.eclim.command.Main %TRANSLATED% 2>&1

sagneta avatar Apr 06 '17 11:04 sagneta