You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by sp...@gmx.eu on 2013/11/28 13:59:53 UTC

org.apache.catalina.filters.CorsFilter

Hi,

I 'm using the CorsFilter in Tomcat 7.0.47, all good.
Then tried it in 7.0.37 -> no luck, only available since 7.0.41.
OK, I put the class into the war file and expected that it is loadable now.
But I get a ClassNotFound. Guessing some special classloader rules I remaned
the class to com.apache.catalina.filters.CorsFilter and now it is working.

So - what are the special rules for org.apache.catalina.*?

Thank you

P.S. yum update tomcat7 did not help, lastest tomcat7 is 7.0.37. How can I
update it to the lastest version? Just wget the tar from tomcat downloads
and extract it into the current tomcat dir? Or will this destroy the tomcat?



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


RE: org.apache.catalina.filters.CorsFilter

Posted by sp...@gmx.eu.
> > Just wanna now why the class is not loadable as
> > org.apache.catalina.filters.CorsFilter but as
> > com.apache.catalina.filters.CorsFilter (different dir in 
> classes of course).
> 
> Because Tomcat prevents web applications from replacing 
> container classes.

Ah, so we do have special rules for org.apache.catalina.filters.* (and other
tomcat packages/classes).

Thank you.


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


Re: org.apache.catalina.filters.CorsFilter

Posted by Mark Thomas <ma...@apache.org>.
On 03/12/2013 17:41, spring@gmx.eu wrote:
>> Exactly where?  The full path is needed here.
> 
> TOMCAT/webapps/myapp/WEB-INF/classes/org/apache/catalina/filters/CorsFilter.
> class
> 
>> Rather than mucking about with an old Tomcat version, just 
>> throw away the 3rd-party repackaged crap and install the 
>> current one from tomcat.apache.org; it will make everyone's 
>> life simpler.
> 
> Just wanna now why the class is not loadable as
> org.apache.catalina.filters.CorsFilter but as
> com.apache.catalina.filters.CorsFilter (different dir in classes of course).

Because Tomcat prevents web applications from replacing container classes.

Mark


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


RE: org.apache.catalina.filters.CorsFilter

Posted by sp...@gmx.eu.
> Exactly where?  The full path is needed here.

TOMCAT/webapps/myapp/WEB-INF/classes/org/apache/catalina/filters/CorsFilter.
class

> Rather than mucking about with an old Tomcat version, just 
> throw away the 3rd-party repackaged crap and install the 
> current one from tomcat.apache.org; it will make everyone's 
> life simpler.

Just wanna now why the class is not loadable as
org.apache.catalina.filters.CorsFilter but as
com.apache.catalina.filters.CorsFilter (different dir in classes of course).


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


RE: org.apache.catalina.filters.CorsFilter

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: spring@gmx.eu [mailto:spring@gmx.eu] 
> Subject: RE: org.apache.catalina.filters.CorsFilter

> > There aren't any. Without the details of how you configured 
> > the filter,
> > where you put the class file and the stack trace of the exception we
> > can't help you.

> Class is in WEB-INF/classes of the webapp.

Exactly where?  The full path is needed here.

Rather than mucking about with an old Tomcat version, just throw away the 3rd-party repackaged crap and install the current one from tomcat.apache.org; it will make everyone's life simpler.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: org.apache.catalina.filters.CorsFilter

Posted by sp...@gmx.eu.
> There aren't any. Without the details of how you configured 
> the filter,
> where you put the class file and the stack trace of the exception we
> can't help you.

Class is in WEB-INF/classes of the webapp.

SEVERE: Exception starting filter CorsFilter
java.lang.ClassNotFoundException: org.apache.catalina.filters.CorsFilter
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	at
org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceMan
ager.java:522)
	at
org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(Def
aultInstanceManager.java:514)
	at
org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceM
anager.java:133)
	at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilter
Config.java:256)
	at
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFil
terConfig.java:382)
	at
org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterCon
fig.java:103)
	at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:46
50)
	at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:
5306)
	at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:15
59)
	at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:15
49)
	at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:11
10)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:6
03)
	at java.lang.Thread.run(Thread.java:722)


	<filter>
	  <filter-name>CorsFilter</filter-name>
	
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
	  <init-param>
	    <param-name>cors.allowed.origins</param-name>
	    <param-value>*</param-value>
	  </init-param>
	  <init-param>
	    <param-name>cors.allowed.methods</param-name>
	    <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value>
	  </init-param>
	  <init-param>
	    <param-name>cors.allowed.headers</param-name>
	    <param-value>X-Requested-With, accept-language, accept,
cache-control, if-modified-since, if-none-match, content-type, Origin,
Access-Control-Request-Method, Access-Control-Request-Headers</param-value>
	  </init-param>
	  <init-param>
	    <param-name>cors.exposed.headers</param-name>
	    <param-value>date, location,
Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
	  </init-param>
	  <init-param>
	    <param-name>cors.support.credentials</param-name>
	    <param-value>true</param-value>
	  </init-param>
	  <init-param>
	    <param-name>cors.preflight.maxage</param-name>
	    <param-value>84600</param-value>
	  </init-param>
	</filter>


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


Re: org.apache.catalina.filters.CorsFilter

Posted by Mark Thomas <ma...@apache.org>.
On 28/11/2013 12:59, spring@gmx.eu wrote:
> Hi,
> 
> I 'm using the CorsFilter in Tomcat 7.0.47, all good.
> Then tried it in 7.0.37 -> no luck, only available since 7.0.41.
> OK, I put the class into the war file and expected that it is loadable now.
> But I get a ClassNotFound. Guessing some special classloader rules I remaned
> the class to com.apache.catalina.filters.CorsFilter and now it is working.
> 
> So - what are the special rules for org.apache.catalina.*?

There aren't any. Without the details of how you configured the filter,
where you put the class file and the stack trace of the exception we
can't help you.

> Thank you
> 
> P.S. yum update tomcat7 did not help, lastest tomcat7 is 7.0.37. How can I
> update it to the lastest version?


Complain to the folks the produce the package you use.

> Just wget the tar from tomcat downloads
> and extract it into the current tomcat dir?

How successful (or not) that is will depend on how your package has been
constructed.

> Or will this destroy the tomcat?

Based on past experience, probably.

Mark


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