[CONTROLLER-1] run.sh does not correctly handle pathnames containing " " characters Created: 23/Mar/13  Updated: 19/Oct/17  Resolved: 05/May/15

Status: Resolved
Project: controller
Component/s: adsal
Affects Version/s: 0.4.0
Fix Version/s: None

Type: Bug
Reporter: Ed Warnicke Assignee: Venkata Siva Vijayendra Bhamidipati
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Mac OS
Platform: PC


External issue ID: 3

 Description   

If somewhere in the full path for the location where you are trying to run your controller, you have a path segment with a space, for example:

/tmp/Development Stuff/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight

(note the " " in "Development Stuff" above)

When you try to execute run.sh, it will fail with the message:

usage: dirname path
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/equinox/launcher/Main
Caused by: java.lang.ClassNotFoundException: org.eclipse.equinox.launcher.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

This failure is occurring due to mishandling of the space in "Development Stuff"

Still working on fixing... but wanted folks to know ASAP that the workaround is
to simply do something like

mv /tmp/Development\ Stuff/ /tmp/DevelopmentStuff

in other words, kill the space in the path segment.



 Comments   
Comment by Venkata Siva Vijayendra Bhamidipati [ 21/Dec/13 ]

I see that this issue still exists on the controller trunk, and this looked like a relatively easy starter bug (Today is my first day working with opendaylight), so am assigning this to myself.

I've patched run.sh to get over the spaces issue, and with that, the NoClassDefFoundError goes away, but I'm still running into an issue with the way the URIParser.parse() routine is being called - looks like it cannot parse file URIs when spaces exist in the path:

BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments: -console -consoleLog

!ENTRY org.eclipse.osgi 4 0 2013-12-20 09:26:14.716
!MESSAGE Bundle reference:file:../lib/logging.bridge-0.4.1-SNAPSHOT@1:start not found.
gogo: URISyntaxException: Illegal character in opaque part at index 29: jar:file:/home/cloud/work/new nd/controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage/opendaylight/configuration/org.eclipse.osgi/bundles/184/1/bundlefile!/gosh_profile
java.net.URISyntaxException: Illegal character in opaque part at index 29: jar:file:/home/cloud/work/new nd/controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage/opendaylight/configuration/org.eclipse.osgi/bundles/184/1/bundlefile!/gosh_profile
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parse(URI.java:3039)
at java.net.URI.<init>(URI.java:595)
at java.net.URL.toURI(URL.java:938)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:469)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:395)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:744)
I'm not using eclipse - I'm running the controller from CLI (ubuntu 12.04).

There are more stack traces at different points in the code that are invoked by different libraries - for example, the above is invoked by the "gogo" package, it repeats later with another trace:

2013-12-20 09:29:37 PST [org.apache.catalina.startup.ContextConfig] SEVERE org.apache.catalina.startup.ContextConfig getWebXmlSource Error processed default web.xml named conf/web.xml at /home/cloud/work/new nd/controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage/opendaylight/conf/web.xml
java.net.URISyntaxException: Illegal character in opaque part at index 29: jar:file:/home/cloud/work/new nd/controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage/opendaylight/configuration/org.eclipse.osgi/bundles/245/1/bundlefile!/conf/web.xml
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parse(URI.java:3039)
at java.net.URI.<init>(URI.java:595)
at java.net.URL.toURI(URL.java:938)
at org.apache.catalina.startup.ContextConfig.getWebXmlSource(ContextConfig.java:1828)
at org.apache.catalina.startup.ContextConfig.getGlobalWebXmlSource(ContextConfig.java:1741)
at org.apache.catalina.startup.ContextConfig.getDefaultWebXmlFragment(ContextConfig.java:1414)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1250)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

.
.
.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:950)
at org.eclipse.gemini.web.tomcat.internal.Activator.start(Activator.java:61)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1175)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1153)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.processAllBundles(DirectoryWatcher.java:1146)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:456)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:263)

Is this OSGI related? Is it possible that the OSGI package being used is outdated and later versions do the parsing correctly (either encode spaces to %20 or call another routine)? Any idea what this glue component/jar is and how I can update its version? I do see in the run.sh file itself, CLASSPATH and FWCLASSPATH variables being initialized to eclipse jar files, but I have little idea of how OSGI works or how the jar components are updated.

Thanks!
Regards,
Vijay

Comment by Ed Warnicke [ 23/Dec/13 ]

You are completely awesome for picking this up

In a URI, you must substitute %20 for " " a space character.

And example of how to do this kind of substitution from the shell would be:

echo "This is a string" | sed 's/ /%20/g'

And thank you so much for picking this up

Comment by Venkata Siva Vijayendra Bhamidipati [ 24/Dec/13 ]

Thanks Ed! I actually did try out the %20 in the sed 's/ /
/g' portions of the script along with putting everything in double quotes, but the problem there is that then the run.sh script passes off those paths as /home/dir1/xy%20z/blah/ to jdk, and then again java fails to locate those paths and runs into the original class not found error.. so I wasn't able to work around it that way..

The %20 encoding should be done somewhere in the java layers, but looking at the stack traces, it doesn't look like we can do that in the controller code. Ideally, the call to java.net.URL.toURI(URL.java:938) that is being made, should be encoding those spaces, or handling it differently. So that's where I'm kind of stuck, since I don't know if those OSGI/gogo modules were actually patched later on to fix this, and if so, how we can upgrade those dependencies in the controller packaging.

Comment by Venkata Siva Vijayendra Bhamidipati [ 21/Jan/14 ]

The fix has been merged to master - however, the osgi bundles will still need to be updated. I'm marking this bug as fixed for now with this caveat.

Comment by Carol Sanders [ 05/May/15 ]

This bug is part of the project to Move all ADSAL associated component bugs to ADSAL.

Generated at Wed Feb 07 19:51:56 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.