答复: [Tomcat] Error page not work for 400 error.

2018-08-05 Thread Leonard Afeng
Thanks Mark,

1. The web.xml is defind in the {$TOMCAT_HOME} /conf , not in application.
2. I add some walk around code in the ErrorPageSupport.java
3. public ErrorPage find(int statusCode) {
4. log.info("before find, the length of statusPages 
is:"+statusPages.size());   
5.  
6.  log.info("in addErrorPage find by status Code  code 
is:"+statusCode );
7.  log.info(Integer.valueOf(statusCode));
8.  if ( statusPages.get(Integer.valueOf(statusCode)) == null )
9.  log.info("cannot find for "+statusCode);
10. else
11. 
log.info("find:"+statusPages.get(Integer.valueOf(statusCode)).getLocation() );
12. 
13. if ( statusCode == 400 ) {
14. log.info("%% use custom errorpage");
15. ErrorPage ep =new ErrorPage();
16. ep.setErrorCode(400);
17. ep.setLocation("\400.html");
18. return ep;
19. }else
20.  return statusPages.get(Integer.valueOf(statusCode));
21. }

This code was reached but the return was not worked.

发送自 Windows 10 版邮件应用

发件人: Mark Thomas
发送时间: 2018年8月6日 3:32
收件人: users@tomcat.apache.org
主题: Re: [Tomcat] Error page not work for 400 error.

On 05/08/2018 04:13, Leonard Afeng wrote:
>   Dear all,
> 
> I custom the error page in web.xml as below:



> And I added some log action in org.apache.catalina.util.ErrorPageSupport
> and found out that in some case the 400 error page not working but the
> default error page.



> 20:02:59.674 INFO [http-nio-8080-exec-1]
> org.apache.coyote.http11.Http11Processor.service
> Error parsing HTTP request header



> Is it a known bug 

No.

> or I can get some patch for it ?

No.

What you are asking for is logically impossible.

The request parsing has failed. Therefore Tomcat can't (reliably) 
identify the web application the request should be routed to. Therefore 
you can't have an application error page generate a response.

If you are using 9.0.6 onwards, the ErrorReportValve can be configured 
to return a custom *static* page for any specific error code and/or 
Exception.

Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




Re: o.a.tomcat.util.scan.StandardJarScanner : Failed to scan [file:/C:/Users//.m2/repository/org/glassfish/hk2/hk2/2.5.0-b42/javax.inject.jar] from classloader hierarchy

2018-08-05 Thread Mark Thomas




On 05/08/2018 08:51, Karen Goh wrote:

Hi all,

I have a Spring Boot web app which gives me an error which is related to 
Tomcat, specifically embedded Tomcat.

There is nothing related in the internet related to this problem so I am hoping 
someone in this group would be able to provide me with the solutions.

This is the error stack :





2018-08-05 15:24:17.153  WARN 4856 --- [ost-startStop-1] 
o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan 
[file:/C:/Users//.m2/repository/org/glassfish/hk2/hk2/2.5.0-b42/hk2-utils.jar] 
from classloader hierarchy

java.io.FileNotFoundException: 
C:\Users\\.m2\repository\org\glassfish\hk2\hk2\2.5.0-b42\hk2-utils.jar (The 
system cannot find the file specified)





I do not know why suddenly I am receiving all these errors.  I tried Maven 
clean, install etc but the same error keeps coming and I can't continue my work.


Those are warnings. There is nothing there that stops Tomcat from 
continuing.


At a guess, you have a JAR file that contains a manifest that defines a 
class path and the JARs it lists are not present.


If my guess is correct, you have a couple of options:

1. Look in the JARs you are using, figure out which one defines a class 
path in its manifest and configure Tomcat to skip that JAR.


2. Configure Tomcat to skip the JARs it can't find.

3. Disable manifest scanning in the StandardJarScanner

Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: [Tomcat] Error page not work for 400 error.

2018-08-05 Thread Mark Thomas

On 05/08/2018 04:13, Leonard Afeng wrote:

  Dear all,

I custom the error page in web.xml as below:





And I added some log action in org.apache.catalina.util.ErrorPageSupport
and found out that in some case the 400 error page not working but the
default error page.





20:02:59.674 INFO [http-nio-8080-exec-1]
org.apache.coyote.http11.Http11Processor.service
Error parsing HTTP request header




Is it a known bug 


No.


or I can get some patch for it ?


No.

What you are asking for is logically impossible.

The request parsing has failed. Therefore Tomcat can't (reliably) 
identify the web application the request should be routed to. Therefore 
you can't have an application error page generate a response.


If you are using 9.0.6 onwards, the ErrorReportValve can be configured 
to return a custom *static* page for any specific error code and/or 
Exception.


Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



o.a.tomcat.util.scan.StandardJarScanner : Failed to scan [file:/C:/Users//.m2/repository/org/glassfish/hk2/hk2/2.5.0-b42/javax.inject.jar] from classloader hierarchy

2018-08-05 Thread Karen Goh
Hi all,

I have a Spring Boot web app which gives me an error which is related to 
Tomcat, specifically embedded Tomcat.

There is nothing related in the internet related to this problem so I am hoping 
someone in this group would be able to provide me with the solutions.

This is the error stack :

2018-08-05 15:24:02.476  INFO 4856 --- [   main] 
c.hi5tutors.Spring.Hi5SpringApplication  : Starting Hi5SpringApplication on 
DESKTOP-1KGGO27 with PID 4856 (C:\Users\\workspace9\Hi5Spring\target\classes 
started by  in C:\Users\\workspace9\Hi5Spring)
2018-08-05 15:24:02.491  INFO 4856 --- [   main] 
c.hi5tutors.Spring.Hi5SpringApplication  : No active profile set, falling back 
to default profiles: default
2018-08-05 15:24:14.605  INFO 4856 --- [   main] 
o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-08-05 15:24:14.620  INFO 4856 --- [   main] 
org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache 
Tomcat/8.5.31
2018-08-05 15:24:14.669  INFO 4856 --- [ost-startStop-1] 
o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native 
library which allows optimal performance in production environments was not 
found on the java.library.path: [C:\Program 
Files\Java\jdk1.8.0_151\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program
 Files/Java/jre1.8.0_171/bin/server;C:/Program 
Files/Java/jre1.8.0_171/bin;C:/Program 
Files/Java/jre1.8.0_171/lib/amd64;C:\Program Files (x86)\Common 
Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program 
Files\MySQL\mysql-5.7.20-win32\bin;C:\Program 
Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program
 
Files\Java\jdk1.8.0_151\bin;C:\Users\\AppData\Local\Microsoft\WindowsApps;;C:\Program
 Files (x86)\Eclipse-Spring IDE\eclipse;;.]
2018-08-05 15:24:17.153  WARN 4856 --- [ost-startStop-1] 
o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan 
[file:/C:/Users//.m2/repository/org/glassfish/hk2/hk2/2.5.0-b42/hk2-utils.jar] 
from classloader hierarchy

java.io.FileNotFoundException: 
C:\Users\\.m2\repository\org\glassfish\hk2\hk2\2.5.0-b42\hk2-utils.jar (The 
system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_151]
at java.util.zip.ZipFile.(ZipFile.java:225) ~[na:1.8.0_151]
at java.util.zip.ZipFile.(ZipFile.java:155) ~[na:1.8.0_151]
at java.util.jar.JarFile.(JarFile.java:166) ~[na:1.8.0_151]
at java.util.jar.JarFile.(JarFile.java:130) ~[na:1.8.0_151]
at 
org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:188) 
~[tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.tomcat.util.scan.JarFileUrlJar.(JarFileUrlJar.java:65) 
~[tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49) 
~[tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374)
 [tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309)
 [tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266)
 [tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229)
 [tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) 
[tomcat-embed-jasper-8.5.31.jar:8.5.31]
at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) 
[tomcat-embed-jasper-8.5.31.jar:8.5.31]
at 
org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101)
 [tomcat-embed-jasper-8.5.31.jar:8.5.31]
at 
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)
 [tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
[tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421) 
[tomcat-embed-core-8.5.31.jar:8.5.31]
at 
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411) 
[tomcat-embed-core-8.5.31.jar:8.5.31]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
[na:1.8.0_151]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[na:1.8.0_151]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[na:1.8.0_151]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]

2018-08-05 15:24:17.170  WARN 4856 --- [ost-startStop-1] 
o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan