You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2015/04/16 18:14:46 UTC

[Bug 57823] New: Server hangs if there is a colon on the start of the class path

https://bz.apache.org/bugzilla/show_bug.cgi?id=57823

            Bug ID: 57823
           Summary: Server hangs if there is a colon on the start of the
                    class path
           Product: Tomcat 8
           Version: 8.0.21
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: gregh3269@gmail.com

I have a startup in /etc/rc.d/init.d script that uses the daemon  eg:

daemon --user $tomcatuser --pidfile=$pidfile $command start

The server was hanging when starting up. I traced it
org.apache.catalina.startup.ContextConfig.java 

..
protected void processAnnotationsUrl(URL url, WebXml fragment,
            boolean handlesTypesOnly) {

        if (url == null) {
            // Nothing to do.
            return;
        } else if ("jar".equals(url.getProtocol())) {
            System.out.println(url.toExternalForm());
            processAnnotationsJar(url, fragment, handlesTypesOnly);
        } else if ("file".equals(url.getProtocol())) {
            try {
                System.out.println(url.toExternalForm());
                processAnnotationsFile(
                       new File(url.toURI()), fragment, handlesTypesOnly);
            } catch (URISyntaxException e) {
                log.error(sm.getString("contextConfig.fileUrl", url), e);
            }
        } else {
            log.error(sm.getString("contextConfig.unknownUrlProtocol",
                    url.getProtocol(), url));
        }

    }

Where it would hang trying to process this line file:/


file:/opt/apache-tomcat/apache-tomcat-8.0.21/lib/
jar:file:/opt/apache-tomcat/apache-tomcat-8.0.21/lib/mysql-connector-java-5.1.34.jar!/
file:/


The file:/ seems to be from a :/ (colon) on the class path, and the combination
of running it from /etc/rc.d/init.d makes it not work.

Not working
-classpath
:/opt/apache-tomcat/apache-tomcat-8.0.21/bin/bootstrap.jar:/opt/apache-tomcat/apache-tomcat-8.0.21/bin/tomcat-juli.jar

Working
-classpath
/opt/apache-tomcat/apache-tomcat-8.0.21/bin/bootstrap.jar:/opt/apache-tomcat/apache-tomcat-8.0.21/bin/tomcat-juli.jar


I guess we need to check for file:/ some where in the processAnnotationsUrl
procesing so we do not scan the whole server.

Cheers Greg

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57823] Server hangs if there is a colon on the start of the class path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57823

--- Comment #2 from gregh <gr...@gmail.com> ---
This was the entry in the /etc/rc.d/init.d script that I have used for many
years, 5,6,7.  This only happens in 8.

CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar

ie the CLASSPATH value in /etc/profile.d had been commented out.

Still, I think it should have some sanity check that it does not scan the root
folder.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57823] Server hangs if there is a colon on the start of the class path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57823

--- Comment #4 from gregh <gr...@gmail.com> ---
Agreed, there would be far too many permutations to check for, but not knowing
that the colon causes it to hang is the key.  Without debugging tomcat I was
stuck as it would not start and nothing in the logs.  Maybe add something to
the upgrade guide?

Cheers Greg

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57823] Server hangs if there is a colon on the start of the class path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57823

--- Comment #3 from Christopher Schultz <ch...@christopherschultz.net> ---
(In reply to gregh from comment #2)
> This was the entry in the /etc/rc.d/init.d script that I have used for many
> years, 5,6,7.  This only happens in 8.
> 
> CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar
> 
> ie the CLASSPATH value in /etc/profile.d had been commented out.
> 
> Still, I think it should have some sanity check that it does not scan the
> root folder.

Your script can easily check to see if $CLASSPATH is empty and then ignore it.
Tomcat doesn't do any scanning of the CLASSPATH itself (meaning, no textual
scanning of the actual string representing the system classpath) and so there's
not really any appropriate place to do this checking, other than adding some
new sanity check for this.

I agree with Mark's reticence to add a check for this; there are an infinite
number of insane CLASSPATH entries, and we can't check for all of them.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57823] Server hangs if there is a colon on the start of the class path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57823

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nitsan_daniel@bmc.com

--- Comment #5 from Konstantin Kolinko <kn...@gmail.com> ---
*** Bug 58766 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57823] Server hangs if there is a colon on the start of the class path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57823

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
An empty class path element is treated by the JVM as the current working
directory.

The class path is normally only scanned when the JarScanner is explicitly
configured with scanBootstrapClassPath="true".

I suspect that starting via the init.d script sets the current working
directory to '/' which is why the change in behavior is observed.

I'm against adding code to skip "file:/" in the JarScanner since that is the
start of a slippery slope where we get all sorts of suggestions for what should
be skipped. In essence, this is a configuration error and needs to be fixed at
source - where the class path is set. Tomcat has code that optionally adds a
separator when appending entries to the class path depending on if it is
currently set or not. This init.d script should have the same logic.

I looked at adding some sort of warning if scanning a class path location was
too long but I'm not convinced that this problem affects enough users to
justify adding the code (this is the first report I can recall in my 10+ years
working on Tomcat). The general "take 3 thread dumps 10s apart and compare"
advice appears (to me) to be good enough to handle this case.

Given the above, I'm resolving this as WONTFIX.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org