Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343680

Summary: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 in org.eclipse.jetty.webapp.WebInfConfiguration.unpack
Product: [RT] Jetty Reporter: nevis
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox
Version: 7.1.5   
Target Milestone: 7.2.x   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description nevis CLA 2011-04-23 01:06:06 EDT
The following function (current in http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java),
though the actual error was encountered in 7.1.5.

To reproduce the failure, install the EclipseRT Web Starter Kit,
create a web bundle, compile it to a jar, deploy it (e.g.: dropins folder)
and run the start kit standalone (using start.bat or equivalent).

Note that running the EclipseRT Web Starter Kit as an OSGi launch
configuration in the Eclipse IDE will not reproduce the error, as
in the Eclipse environment, there is a bundle folder and not a
bundle jar.

A workaround to the bug is to do as Eclipse, deploy a bundle folder instead of a bundle jar.

                if (war!=null)
                {
                    // look for a sibling like "foo/" to a "foo.war"
                    File warfile=Resource.newResource(war).getFile();
                    if (warfile!=null)
                    {
// *** BUG ***
                        File sibling = new File(warfile.getParent(),warfile.getName().substring(0,warfile.getName().length()-4));
                        if (sibling.exists() && sibling.isDirectory() && sibling.canWrite())
                            extractedWebAppDir=sibling;
                    }
                }


2011-04-22 12:54:36.795:DBUG::Calling org.eclipse.jetty.deploy.bindings.StandardStarter for App[WebAppContext@78979f67@78979f67/mywebapp,null,bundleentry://4.fwk1516115866/war/,mywebapp-1.0.0.qualifier/war]
2011-04-22 12:54:36.795:DBUG::Starting WebAppContext@78979f67@78979f67/mywebapp,null,bundleentry://4.fwk1516115866/war/2011-04-22 12:54:36.795:DBUG::loaded class org.eclipse.jetty.webapp.WebInfConfiguration from org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@56c163f
2011-04-22 12:54:36.795:DBUG::loaded class org.eclipse.jetty.webapp.WebXmlConfiguration from org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@56c163f
2011-04-22 12:54:36.795:DBUG::loaded class org.eclipse.jetty.webapp.MetaInfConfiguration from org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@56c163f
2011-04-22 12:54:36.795:DBUG::loaded class org.eclipse.jetty.webapp.FragmentConfiguration from org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@56c163f
2011-04-22 12:54:36.795:DBUG::loaded class org.eclipse.jetty.webapp.JettyWebXmlConfiguration from org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@56c163f
2011-04-22 12:54:36.795:DBUG::loaded class org.eclipse.jetty.webapp.TagLibConfiguration from org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@56c163f
2011-04-22 12:54:36.795:DBUG::Thread Context class loader is: ContextLoader@null([]) / org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@5d6d2633
2011-04-22 12:54:36.795:DBUG::Parent class loader is: org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@5d6d2633
2011-04-22 12:54:36.795:DBUG::Parent class loader is: org.eclipse.osgi.baseadaptor.BaseAdaptor$1@3882764b
2011-04-22 12:54:36.805:DBUG::Set temp dir C:\Users\mylogin\AppData\Local\Temp\Jetty_0_0_0_0_8888_war__mywebapp__.1ml6gy
2011-04-22 12:54:36.805:DBUG::Try webapp=bundleentry://4.fwk1516115866/war/, exists=true, directory=true
2011-04-22 12:54:36.805:WARN::Failed startup of context WebAppContext@78979f67@78979f67/mywebapp,null,bundleentry://4.fwk1516115866/war/
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
Comment 1 Greg Wilkins CLA 2011-05-10 02:51:00 EDT
Fixed in r3108

only look for sibling dir if filename ends with .war
Comment 2 Greg Wilkins CLA 2011-05-10 02:51:34 EDT
Fixed in r3108

only look for sibling dir if filename ends with .war