You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Aditya Chopra <ad...@turvo.com> on 2015/05/26 09:36:02 UTC

Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Hi,

To reduce the size of my war file, i am trying to put all the jar files being used by my web app in a separate folder /mylibs. I added path to /mylibs folder under shared.loader property in catalina.properties but on runtime i am getting a ClassNotFoundException for one of the classes that is present in one the project module jar under WEB-INF/lib folder.

When i add all the libraries required by my project in WEB-INF/lib folder my application works fine. However, when i put the libraries in a separate /mylibs folder i get a ClassNotFoundException on runtime. 

I suspect that it could be due to order in which the classes are being loaded, so added a Loader component in my context.xml as below, but that too didn’t work. Can someone please help me on this?

 19 <Context>
 20 
 21     <!-- Default set of monitored resources. If one of these changes, the    -->
 22     <!-- web application will be reloaded.                                   -->
 23     <WatchedResource>WEB-INF/web.xml</WatchedResource>
 24     <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
 25     <Loader className="org.apache.catalina.loader.WebappLoader" delegate="true" searchExternalFirst="true"/>

Regards,
Aditya

Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Daniel Mikusa <dm...@pivotal.io>.
On Tue, May 26, 2015 at 6:21 AM, Aditya Chopra <ad...@turvo.com> wrote:

> The reason i am trying to reduce the war file size is because its size has
> gone upto 55MB and time taken for copying it to the server for deployments
> has increased.
>

What you're trying to do may seem like a good idea, but in practice is
usually not.  There are a handful of things that can go wrong with it
(library version issues, classpath casting issues, etc...).  You're hitting
just one of those problems and as you can see it's not easy to debug (none
of them are really).  All for what?  A marginally smaller WAR file.  Unless
you're on dial-up, it's likely that the time you spend debugging issues
will far exceed the time you spend uploading files, and that's something
that can be automated.

Solutions to the problem of a larger WAR file that I would suggest (I'm
sure others can add to this list):

   a.) just live with the upload time.  55M is not that crazy.  run the
upload while you're doing something else or at night.
   b.) get a faster Internet connection
   c.) build your project on a remote server, possibly a CI server, that
has better bandwidth.


>
> Is there any best practice around this that we should be following?
>

Put everything into the WAR file.  This is my opinion, but I find it makes
life a lot easier.

Dan



>
> Anyways, i will also check Spring usage to see why the threat context
> class loader isn’t being used.
>
> Aditya
>
>
> > On 26-May-2015, at 3:37 pm, Mark Thomas <ma...@apache.org> wrote:
> >
> > On 26/05/2015 10:53, Aditya Chopra wrote:
> >
> > This thread does beg the question *why* do you want to reduce the size
> > of your WAR. Doing so creates problems as you have found.
> >
> >> In WEB-INF/lib i only have 2 JARs, which are my application JAR’s. All
> other dependent JAR’s i have moved to /mylibs.
> >>
> >> Below mentioned com.myapp.CustomGrantedAuth class is part of my
> application JAR present under WEB-INF/lib.
> >
> > You'll need to speak to the Spring folks to see why the thread context
> > class loader isn't being used. Whether that is a Spring bug or a Spring
> > usage error in your part I don't know.
> >
> > Mark
> >
> >
> >>
> >> Here is the stack trace:
> >>
> >> DEBUG [http-nio-8080-exec-3] (DefaultExceptionHandler.java:123) - error.
> >> java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
> com.myapp.CustomGrantedAuth
> >>      at
> org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:36)
> >>      at
> com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:124)
> >>      at
> com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:1)
> >>      at
> org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
> >>      at
> org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
> >>      at
> org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:708)
> >>      at
> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
> >>      at
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
> >>      at
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
> >>      at
> org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737)
> >>      at
> org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:811)
> >>      at
> com.arl.mg.services.CustomTokenStore.readAuthentication(CustomTokenStore.java:121)
> >>      at
> com.arl.mg.services.CustomTokenServices.loadAuthentication(CustomTokenServices.java:139)
> >>      at
> org.springframework.security.oauth2.provider.filter.OAuth2ProtectedResourceFilter.doFilter(OAuth2ProtectedResourceFilter.java:53)
> >>      at
> org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
> >>      at
> com.arl.mg.error.CustomExceptionHandlerFilter.doFilter(CustomExceptionHandlerFilter.java:59)
> >>      at
> org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
> >>      at
> org.springframework.security.oauth2.provider.filter.CompositeFilter.doFilter(CompositeFilter.java:59)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:139)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
> >>      at
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
> >>      at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> >>      at
> org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
> >>      at
> org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
> >>      at
> org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
> >>      at
> org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
> >>      at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> >>      at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> >>      at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
> >>      at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
> >>      at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
> >>      at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
> >>      at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
> >>      at
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
> >>      at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
> >>      at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
> >>      at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
> >>      at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
> >>      at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
> >>      at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
> >>      at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> >>      at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> >>      at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> >>      at java.lang.Thread.run(Thread.java:745)
> >> Caused by: java.lang.ClassNotFoundException: com.myapp.CustomGrantedAuth
> >>      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> >>      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> >>      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> >>      at java.lang.Class.forName0(Native Method)
> >>      at java.lang.Class.forName(Class.java:348)
> >>      at
> java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
> >>      at
> java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
> >>      at
> java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
> >>      at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
> >>      at
> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> >>      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
> >>      at java.util.ArrayList.readObject(ArrayList.java:791)
> >>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>      at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >>      at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >>      at java.lang.reflect.Method.invoke(Method.java:497)
> >>      at
> java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
> >>      at
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
> >>      at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
> >>      at
> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> >>      at
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
> >>      at
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
> >>      at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
> >>      at
> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> >>      at
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
> >>      at
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
> >>      at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
> >>      at
> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> >>      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
> >>      at
> org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:32)
> >>      ... 59 more
> >> DEBUG [http-nio-8080-exec-3] (ExceptionTranslationFilter.java:115) -
> Chain processed normally
> >>
> >>
> >>
> >>> On 26-May-2015, at 3:17 pm, Mark Thomas <ma...@apache.org> wrote:
> >>>
> >>> On 26/05/2015 10:44, Aditya Chopra wrote:
> >>>> Thanks for quick response Mark.
> >>>>
> >>>> JARs in /mylib are not dependent on JARs in web app. In fact its the
> other way round. /mylib is having all Spring, hibernate jar’s, other common
> libs and WEB-INF/lib is containing jar of one of my application modules.
> >>>> The class for which i am getting ClassNotFoundException exception is
> part of JAR present under WEB-INF/lib.
> >>>>
> >>>> I enabled the class loader logs and don’t see that class getting
> loaded on server startup. However, when i copy all JAR’s from /mylib to
> WEB-INF/lib, that class is getting loaded and i don’t get the
> ClassNotFoundException on runtime.
> >>>>
> >>>> Any thoughts what might be causing this?
> >>>
> >>> Yes. One of the JARs in /mylib depends on one of the JARs in
> WEB-INF/lib
> >>> and that is not permitted.
> >>>
> >>> The dependency may not be obvious. If you provide the full stack trace
> >>> we might be able to provide you with some pointers.
> >>>
> >>> Mark
> >>>
> >>>>
> >>>> Aditya
> >>>>
> >>>>> On 26-May-2015, at 3:04 pm, Mark Thomas <ma...@apache.org> wrote:
> >>>>>
> >>>>> On 26/05/2015 08:36, Aditya Chopra wrote:
> >>>>>> Hi,
> >>>>>>
> >>>>>> To reduce the size of my war file, i am trying to put all the jar
> files being used by my web app in a separate folder /mylibs. I added path
> to /mylibs folder under shared.loader property in catalina.properties but
> on runtime i am getting a ClassNotFoundException for one of the classes
> that is present in one the project module jar under WEB-INF/lib folder.
> >>>>>>
> >>>>>> When i add all the libraries required by my project in WEB-INF/lib
> folder my application works fine. However, when i put the libraries in a
> separate /mylibs folder i get a ClassNotFoundException on runtime.
> >>>>>>
> >>>>>> I suspect that it could be due to order in which the classes are
> being loaded, so added a Loader component in my context.xml as below, but
> that too didn’t work. Can someone please help me on this?
> >>>>>
> >>>>> JARs in /mylibs must not depend on JARs in a web application. There
> is
> >>>>> no configuration option that would enable you to bypass this
> restriction.
> >>>>>
> >>>>> Mark
> >>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >>>>> For additional commands, e-mail: users-help@tomcat.apache.org
> >>>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >>>> For additional commands, e-mail: users-help@tomcat.apache.org
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >>> For additional commands, e-mail: users-help@tomcat.apache.org
> >>>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org <mailto:
> users-unsubscribe@tomcat.apache.org>
> > For additional commands, e-mail: users-help@tomcat.apache.org <mailto:
> users-help@tomcat.apache.org>
>

Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
We use GIT for deployment. This way you are only uploading the delta.

Have a look at how OpenShift does it for the mechanics. I wasn¹t involved
in setting up the system we use but I know the team who did leaned heavily
on what was done on OpenShift.

I can tell you from experience deployments are much faster to upload and
deploy.

Z.



On 26/05/2015 8:21 pm, "Aditya Chopra" <ad...@turvo.com> wrote:

>The reason i am trying to reduce the war file size is because its size
>has gone upto 55MB and time taken for copying it to the server for
>deployments has increased.
>
>Is there any best practice around this that we should be following?
>
>Anyways, i will also check Spring usage to see why the threat context
>class loader isn¹t being used.
>
>Aditya
>
>
>> On 26-May-2015, at 3:37 pm, Mark Thomas <ma...@apache.org> wrote:
>> 
>> On 26/05/2015 10:53, Aditya Chopra wrote:
>> 
>> This thread does beg the question *why* do you want to reduce the size
>> of your WAR. Doing so creates problems as you have found.
>> 
>>> In WEB-INF/lib i only have 2 JARs, which are my application JAR¹s. All
>>>other dependent JAR¹s i have moved to /mylibs.
>>> 
>>> Below mentioned com.myapp.CustomGrantedAuth class is part of my
>>>application JAR present under WEB-INF/lib.
>> 
>> You'll need to speak to the Spring folks to see why the thread context
>> class loader isn't being used. Whether that is a Spring bug or a Spring
>> usage error in your part I don't know.
>> 
>> Mark
>> 
>> 
>>> 
>>> Here is the stack trace:
>>> 
>>> DEBUG [http-nio-8080-exec-3] (DefaultExceptionHandler.java:123) -
>>>error.
>>> java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
>>>com.myapp.CustomGrantedAuth
>>> 	at 
>>>org.springframework.security.oauth2.common.util.SerializationUtils.deser
>>>ialize(SerializationUtils.java:36)
>>> 	at 
>>>com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:124)
>>> 	at 
>>>com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:1)
>>> 	at 
>>>org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(Ro
>>>wMapperResultSetExtractor.java:93)
>>> 	at 
>>>org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(Ro
>>>wMapperResultSetExtractor.java:60)
>>> 	at 
>>>org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcT
>>>emplate.java:708)
>>> 	at 
>>>org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644
>>>)
>>> 	at 
>>>org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
>>> 	at 
>>>org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
>>> 	at 
>>>org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737)
>>> 	at 
>>>org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.j
>>>ava:811)
>>> 	at 
>>>com.arl.mg.services.CustomTokenStore.readAuthentication(CustomTokenStore
>>>.java:121)
>>> 	at 
>>>com.arl.mg.services.CustomTokenServices.loadAuthentication(CustomTokenSe
>>>rvices.java:139)
>>> 	at 
>>>org.springframework.security.oauth2.provider.filter.OAuth2ProtectedResou
>>>rceFilter.doFilter(OAuth2ProtectedResourceFilter.java:53)
>>> 	at 
>>>org.springframework.security.oauth2.provider.filter.CompositeFilter$Virt
>>>ualFilterChain.doFilter(CompositeFilter.java:79)
>>> 	at 
>>>com.arl.mg.error.CustomExceptionHandlerFilter.doFilter(CustomExceptionHa
>>>ndlerFilter.java:59)
>>> 	at 
>>>org.springframework.security.oauth2.provider.filter.CompositeFilter$Virt
>>>ualFilterChain.doFilter(CompositeFilter.java:79)
>>> 	at 
>>>org.springframework.security.oauth2.provider.filter.CompositeFilter.doFi
>>>lter(CompositeFilter.java:59)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.access.ExceptionTranslationFilter.doFil
>>>ter(ExceptionTranslationFilter.java:113)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.session.SessionManagementFilter.doFilte
>>>r(SessionManagementFilter.java:103)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.authentication.AnonymousAuthenticationF
>>>ilter.doFilter(AnonymousAuthenticationFilter.java:113)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.authentication.rememberme.RememberMeAut
>>>henticationFilter.doFilter(RememberMeAuthenticationFilter.java:139)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.servletapi.SecurityContextHolderAwareRe
>>>questFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.savedrequest.RequestCacheAwareFilter.do
>>>Filter(RequestCacheAwareFilter.java:45)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.authentication.AbstractAuthenticationPr
>>>ocessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.context.request.async.WebAsyncManagerIn
>>>tegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:5
>>>0)
>>> 	at 
>>>org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequ
>>>estFilter.java:107)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.context.SecurityContextPersistenceFilte
>>>r.doFilter(SecurityContextPersistenceFilter.java:87)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doF
>>>ilter(FilterChainProxy.java:342)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy.doFilterInternal(Filte
>>>rChainProxy.java:192)
>>> 	at 
>>>org.springframework.security.web.FilterChainProxy.doFilter(FilterChainPr
>>>oxy.java:160)
>>> 	at 
>>>org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(Dele
>>>gatingFilterProxy.java:344)
>>> 	at 
>>>org.springframework.web.filter.DelegatingFilterProxy.doFilter(Delegating
>>>FilterProxy.java:261)
>>> 	at 
>>>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>>>tionFilterChain.java:239)
>>> 	at 
>>>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>>>erChain.java:206)
>>> 	at 
>>>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
>>>e.java:219)
>>> 	at 
>>>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
>>>e.java:106)
>>> 	at 
>>>org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator
>>>Base.java:502)
>>> 	at 
>>>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
>>>:142)
>>> 	at 
>>>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
>>>:79)
>>> 	at 
>>>org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessL
>>>ogValve.java:617)
>>> 	at 
>>>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
>>>java:88)
>>> 	at 
>>>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:5
>>>18)
>>> 	at 
>>>org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11P
>>>rocessor.java:1091)
>>> 	at 
>>>org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Abs
>>>tractProtocol.java:668)
>>> 	at 
>>>org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint
>>>.java:1521)
>>> 	at 
>>>org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.j
>>>ava:1478)
>>> 	at 
>>>java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.jav
>>>a:1142)
>>> 	at 
>>>java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.ja
>>>va:617)
>>> 	at 
>>>org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThrea
>>>d.java:61)
>>> 	at java.lang.Thread.run(Thread.java:745)
>>> Caused by: java.lang.ClassNotFoundException:
>>>com.myapp.CustomGrantedAuth
>>> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>>> 	at java.lang.Class.forName0(Native Method)
>>> 	at java.lang.Class.forName(Class.java:348)
>>> 	at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
>>> 	at 
>>>java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
>>> 	at 
>>>java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
>>> 	at 
>>>java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774
>>>)
>>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>>> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
>>> 	at java.util.ArrayList.readObject(ArrayList.java:791)
>>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> 	at 
>>>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
>>>a:62)
>>> 	at 
>>>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
>>>Impl.java:43)
>>> 	at java.lang.reflect.Method.invoke(Method.java:497)
>>> 	at 
>>>java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
>>> 	at 
>>>java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
>>> 	at 
>>>java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801
>>>)
>>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>>> 	at 
>>>java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
>>> 	at 
>>>java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
>>> 	at 
>>>java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801
>>>)
>>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>>> 	at 
>>>java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
>>> 	at 
>>>java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
>>> 	at 
>>>java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801
>>>)
>>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>>> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
>>> 	at 
>>>org.springframework.security.oauth2.common.util.SerializationUtils.deser
>>>ialize(SerializationUtils.java:32)
>>> 	... 59 more
>>> DEBUG [http-nio-8080-exec-3] (ExceptionTranslationFilter.java:115) -
>>>Chain processed normally
>>> 
>>> 
>>> 
>>>> On 26-May-2015, at 3:17 pm, Mark Thomas <ma...@apache.org> wrote:
>>>> 
>>>> On 26/05/2015 10:44, Aditya Chopra wrote:
>>>>> Thanks for quick response Mark.
>>>>> 
>>>>> JARs in /mylib are not dependent on JARs in web app. In fact its the
>>>>>other way round. /mylib is having all Spring, hibernate jar¹s, other
>>>>>common libs and WEB-INF/lib is containing jar of one of my
>>>>>application modules.
>>>>> The class for which i am getting ClassNotFoundException exception is
>>>>>part of JAR present under WEB-INF/lib.
>>>>> 
>>>>> I enabled the class loader logs and don¹t see that class getting
>>>>>loaded on server startup. However, when i copy all JAR¹s from /mylib
>>>>>to WEB-INF/lib, that class is getting loaded and i don¹t get the
>>>>>ClassNotFoundException on runtime.
>>>>> 
>>>>> Any thoughts what might be causing this?
>>>> 
>>>> Yes. One of the JARs in /mylib depends on one of the JARs in
>>>>WEB-INF/lib
>>>> and that is not permitted.
>>>> 
>>>> The dependency may not be obvious. If you provide the full stack trace
>>>> we might be able to provide you with some pointers.
>>>> 
>>>> Mark
>>>> 
>>>>> 
>>>>> Aditya
>>>>> 
>>>>>> On 26-May-2015, at 3:04 pm, Mark Thomas <ma...@apache.org> wrote:
>>>>>> 
>>>>>> On 26/05/2015 08:36, Aditya Chopra wrote:
>>>>>>> Hi,
>>>>>>> 
>>>>>>> To reduce the size of my war file, i am trying to put all the jar
>>>>>>>files being used by my web app in a separate folder /mylibs. I
>>>>>>>added path to /mylibs folder under shared.loader property in
>>>>>>>catalina.properties but on runtime i am getting a
>>>>>>>ClassNotFoundException for one of the classes that is present in
>>>>>>>one the project module jar under WEB-INF/lib folder.
>>>>>>> 
>>>>>>> When i add all the libraries required by my project in WEB-INF/lib
>>>>>>>folder my application works fine. However, when i put the libraries
>>>>>>>in a separate /mylibs folder i get a ClassNotFoundException on
>>>>>>>runtime. 
>>>>>>> 
>>>>>>> I suspect that it could be due to order in which the classes are
>>>>>>>being loaded, so added a Loader component in my context.xml as
>>>>>>>below, but that too didn¹t work. Can someone please help me on this?
>>>>>> 
>>>>>> JARs in /mylibs must not depend on JARs in a web application. There
>>>>>>is
>>>>>> no configuration option that would enable you to bypass this
>>>>>>restriction.
>>>>>> 
>>>>>> Mark
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>> 
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>> 
>>> 
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>><ma...@tomcat.apache.org>
>> For additional commands, e-mail: users-help@tomcat.apache.org
>><ma...@tomcat.apache.org>



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


Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Aditya Chopra <ad...@turvo.com>.
The reason i am trying to reduce the war file size is because its size has gone upto 55MB and time taken for copying it to the server for deployments has increased.

Is there any best practice around this that we should be following? 

Anyways, i will also check Spring usage to see why the threat context class loader isn’t being used.

Aditya


> On 26-May-2015, at 3:37 pm, Mark Thomas <ma...@apache.org> wrote:
> 
> On 26/05/2015 10:53, Aditya Chopra wrote:
> 
> This thread does beg the question *why* do you want to reduce the size
> of your WAR. Doing so creates problems as you have found.
> 
>> In WEB-INF/lib i only have 2 JARs, which are my application JAR’s. All other dependent JAR’s i have moved to /mylibs.
>> 
>> Below mentioned com.myapp.CustomGrantedAuth class is part of my application JAR present under WEB-INF/lib.
> 
> You'll need to speak to the Spring folks to see why the thread context
> class loader isn't being used. Whether that is a Spring bug or a Spring
> usage error in your part I don't know.
> 
> Mark
> 
> 
>> 
>> Here is the stack trace:
>> 
>> DEBUG [http-nio-8080-exec-3] (DefaultExceptionHandler.java:123) - error.
>> java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: com.myapp.CustomGrantedAuth
>> 	at org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:36)
>> 	at com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:124)
>> 	at com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:1)
>> 	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
>> 	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
>> 	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:708)
>> 	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
>> 	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
>> 	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
>> 	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737)
>> 	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:811)
>> 	at com.arl.mg.services.CustomTokenStore.readAuthentication(CustomTokenStore.java:121)
>> 	at com.arl.mg.services.CustomTokenServices.loadAuthentication(CustomTokenServices.java:139)
>> 	at org.springframework.security.oauth2.provider.filter.OAuth2ProtectedResourceFilter.doFilter(OAuth2ProtectedResourceFilter.java:53)
>> 	at org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
>> 	at com.arl.mg.error.CustomExceptionHandlerFilter.doFilter(CustomExceptionHandlerFilter.java:59)
>> 	at org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
>> 	at org.springframework.security.oauth2.provider.filter.CompositeFilter.doFilter(CompositeFilter.java:59)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:139)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
>> 	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
>> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>> 	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
>> 	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
>> 	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
>> 	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
>> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
>> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
>> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
>> 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
>> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
>> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
>> 	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
>> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
>> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
>> 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
>> 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
>> 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
>> 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
>> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>> 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>> 	at java.lang.Thread.run(Thread.java:745)
>> Caused by: java.lang.ClassNotFoundException: com.myapp.CustomGrantedAuth
>> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>> 	at java.lang.Class.forName0(Native Method)
>> 	at java.lang.Class.forName(Class.java:348)
>> 	at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
>> 	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
>> 	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
>> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
>> 	at java.util.ArrayList.readObject(ArrayList.java:791)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> 	at java.lang.reflect.Method.invoke(Method.java:497)
>> 	at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
>> 	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
>> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>> 	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
>> 	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
>> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>> 	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
>> 	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
>> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
>> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
>> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
>> 	at org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:32)
>> 	... 59 more
>> DEBUG [http-nio-8080-exec-3] (ExceptionTranslationFilter.java:115) - Chain processed normally
>> 
>> 
>> 
>>> On 26-May-2015, at 3:17 pm, Mark Thomas <ma...@apache.org> wrote:
>>> 
>>> On 26/05/2015 10:44, Aditya Chopra wrote:
>>>> Thanks for quick response Mark.
>>>> 
>>>> JARs in /mylib are not dependent on JARs in web app. In fact its the other way round. /mylib is having all Spring, hibernate jar’s, other common libs and WEB-INF/lib is containing jar of one of my application modules.
>>>> The class for which i am getting ClassNotFoundException exception is part of JAR present under WEB-INF/lib.
>>>> 
>>>> I enabled the class loader logs and don’t see that class getting loaded on server startup. However, when i copy all JAR’s from /mylib to WEB-INF/lib, that class is getting loaded and i don’t get the ClassNotFoundException on runtime.
>>>> 
>>>> Any thoughts what might be causing this?
>>> 
>>> Yes. One of the JARs in /mylib depends on one of the JARs in WEB-INF/lib
>>> and that is not permitted.
>>> 
>>> The dependency may not be obvious. If you provide the full stack trace
>>> we might be able to provide you with some pointers.
>>> 
>>> Mark
>>> 
>>>> 
>>>> Aditya
>>>> 
>>>>> On 26-May-2015, at 3:04 pm, Mark Thomas <ma...@apache.org> wrote:
>>>>> 
>>>>> On 26/05/2015 08:36, Aditya Chopra wrote:
>>>>>> Hi,
>>>>>> 
>>>>>> To reduce the size of my war file, i am trying to put all the jar files being used by my web app in a separate folder /mylibs. I added path to /mylibs folder under shared.loader property in catalina.properties but on runtime i am getting a ClassNotFoundException for one of the classes that is present in one the project module jar under WEB-INF/lib folder.
>>>>>> 
>>>>>> When i add all the libraries required by my project in WEB-INF/lib folder my application works fine. However, when i put the libraries in a separate /mylibs folder i get a ClassNotFoundException on runtime. 
>>>>>> 
>>>>>> I suspect that it could be due to order in which the classes are being loaded, so added a Loader component in my context.xml as below, but that too didn’t work. Can someone please help me on this?
>>>>> 
>>>>> JARs in /mylibs must not depend on JARs in a web application. There is
>>>>> no configuration option that would enable you to bypass this restriction.
>>>>> 
>>>>> Mark
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>> 
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org <ma...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org <ma...@tomcat.apache.org>

Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Mark Thomas <ma...@apache.org>.
On 26/05/2015 10:53, Aditya Chopra wrote:

This thread does beg the question *why* do you want to reduce the size
of your WAR. Doing so creates problems as you have found.

> In WEB-INF/lib i only have 2 JARs, which are my application JAR’s. All other dependent JAR’s i have moved to /mylibs.
> 
> Below mentioned com.myapp.CustomGrantedAuth class is part of my application JAR present under WEB-INF/lib.

You'll need to speak to the Spring folks to see why the thread context
class loader isn't being used. Whether that is a Spring bug or a Spring
usage error in your part I don't know.

Mark


> 
> Here is the stack trace:
> 
> DEBUG [http-nio-8080-exec-3] (DefaultExceptionHandler.java:123) - error.
> java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: com.myapp.CustomGrantedAuth
> 	at org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:36)
> 	at com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:124)
> 	at com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:1)
> 	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
> 	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
> 	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:708)
> 	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
> 	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
> 	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
> 	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737)
> 	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:811)
> 	at com.arl.mg.services.CustomTokenStore.readAuthentication(CustomTokenStore.java:121)
> 	at com.arl.mg.services.CustomTokenServices.loadAuthentication(CustomTokenServices.java:139)
> 	at org.springframework.security.oauth2.provider.filter.OAuth2ProtectedResourceFilter.doFilter(OAuth2ProtectedResourceFilter.java:53)
> 	at org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
> 	at com.arl.mg.error.CustomExceptionHandlerFilter.doFilter(CustomExceptionHandlerFilter.java:59)
> 	at org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
> 	at org.springframework.security.oauth2.provider.filter.CompositeFilter.doFilter(CompositeFilter.java:59)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:139)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
> 	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
> 	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
> 	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
> 	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
> 	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
> 	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
> 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
> 	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
> 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
> 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
> 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
> 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.ClassNotFoundException: com.myapp.CustomGrantedAuth
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> 	at java.lang.Class.forName0(Native Method)
> 	at java.lang.Class.forName(Class.java:348)
> 	at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
> 	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
> 	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
> 	at java.util.ArrayList.readObject(ArrayList.java:791)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:497)
> 	at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
> 	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> 	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
> 	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> 	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
> 	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
> 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
> 	at org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:32)
> 	... 59 more
> DEBUG [http-nio-8080-exec-3] (ExceptionTranslationFilter.java:115) - Chain processed normally
> 
> 
> 
>> On 26-May-2015, at 3:17 pm, Mark Thomas <ma...@apache.org> wrote:
>>
>> On 26/05/2015 10:44, Aditya Chopra wrote:
>>> Thanks for quick response Mark.
>>>
>>> JARs in /mylib are not dependent on JARs in web app. In fact its the other way round. /mylib is having all Spring, hibernate jar’s, other common libs and WEB-INF/lib is containing jar of one of my application modules.
>>> The class for which i am getting ClassNotFoundException exception is part of JAR present under WEB-INF/lib.
>>>
>>> I enabled the class loader logs and don’t see that class getting loaded on server startup. However, when i copy all JAR’s from /mylib to WEB-INF/lib, that class is getting loaded and i don’t get the ClassNotFoundException on runtime.
>>>
>>> Any thoughts what might be causing this?
>>
>> Yes. One of the JARs in /mylib depends on one of the JARs in WEB-INF/lib
>> and that is not permitted.
>>
>> The dependency may not be obvious. If you provide the full stack trace
>> we might be able to provide you with some pointers.
>>
>> Mark
>>
>>>
>>> Aditya
>>>
>>>> On 26-May-2015, at 3:04 pm, Mark Thomas <ma...@apache.org> wrote:
>>>>
>>>> On 26/05/2015 08:36, Aditya Chopra wrote:
>>>>> Hi,
>>>>>
>>>>> To reduce the size of my war file, i am trying to put all the jar files being used by my web app in a separate folder /mylibs. I added path to /mylibs folder under shared.loader property in catalina.properties but on runtime i am getting a ClassNotFoundException for one of the classes that is present in one the project module jar under WEB-INF/lib folder.
>>>>>
>>>>> When i add all the libraries required by my project in WEB-INF/lib folder my application works fine. However, when i put the libraries in a separate /mylibs folder i get a ClassNotFoundException on runtime. 
>>>>>
>>>>> I suspect that it could be due to order in which the classes are being loaded, so added a Loader component in my context.xml as below, but that too didn’t work. Can someone please help me on this?
>>>>
>>>> JARs in /mylibs must not depend on JARs in a web application. There is
>>>> no configuration option that would enable you to bypass this restriction.
>>>>
>>>> Mark
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> 


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


Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Aditya Chopra <ad...@turvo.com>.
In WEB-INF/lib i only have 2 JARs, which are my application JAR’s. All other dependent JAR’s i have moved to /mylibs.

Below mentioned com.myapp.CustomGrantedAuth class is part of my application JAR present under WEB-INF/lib.

Here is the stack trace:

DEBUG [http-nio-8080-exec-3] (DefaultExceptionHandler.java:123) - error.
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: com.myapp.CustomGrantedAuth
	at org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:36)
	at com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:124)
	at com.arl.mg.services.CustomTokenStore$2.mapRow(CustomTokenStore.java:1)
	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:708)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737)
	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:811)
	at com.arl.mg.services.CustomTokenStore.readAuthentication(CustomTokenStore.java:121)
	at com.arl.mg.services.CustomTokenServices.loadAuthentication(CustomTokenServices.java:139)
	at org.springframework.security.oauth2.provider.filter.OAuth2ProtectedResourceFilter.doFilter(OAuth2ProtectedResourceFilter.java:53)
	at org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
	at com.arl.mg.error.CustomExceptionHandlerFilter.doFilter(CustomExceptionHandlerFilter.java:59)
	at org.springframework.security.oauth2.provider.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:79)
	at org.springframework.security.oauth2.provider.filter.CompositeFilter.doFilter(CompositeFilter.java:59)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:139)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.myapp.CustomGrantedAuth
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
	at java.util.ArrayList.readObject(ArrayList.java:791)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
	at org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:32)
	... 59 more
DEBUG [http-nio-8080-exec-3] (ExceptionTranslationFilter.java:115) - Chain processed normally



> On 26-May-2015, at 3:17 pm, Mark Thomas <ma...@apache.org> wrote:
> 
> On 26/05/2015 10:44, Aditya Chopra wrote:
>> Thanks for quick response Mark.
>> 
>> JARs in /mylib are not dependent on JARs in web app. In fact its the other way round. /mylib is having all Spring, hibernate jar’s, other common libs and WEB-INF/lib is containing jar of one of my application modules.
>> The class for which i am getting ClassNotFoundException exception is part of JAR present under WEB-INF/lib.
>> 
>> I enabled the class loader logs and don’t see that class getting loaded on server startup. However, when i copy all JAR’s from /mylib to WEB-INF/lib, that class is getting loaded and i don’t get the ClassNotFoundException on runtime.
>> 
>> Any thoughts what might be causing this?
> 
> Yes. One of the JARs in /mylib depends on one of the JARs in WEB-INF/lib
> and that is not permitted.
> 
> The dependency may not be obvious. If you provide the full stack trace
> we might be able to provide you with some pointers.
> 
> Mark
> 
>> 
>> Aditya
>> 
>>> On 26-May-2015, at 3:04 pm, Mark Thomas <ma...@apache.org> wrote:
>>> 
>>> On 26/05/2015 08:36, Aditya Chopra wrote:
>>>> Hi,
>>>> 
>>>> To reduce the size of my war file, i am trying to put all the jar files being used by my web app in a separate folder /mylibs. I added path to /mylibs folder under shared.loader property in catalina.properties but on runtime i am getting a ClassNotFoundException for one of the classes that is present in one the project module jar under WEB-INF/lib folder.
>>>> 
>>>> When i add all the libraries required by my project in WEB-INF/lib folder my application works fine. However, when i put the libraries in a separate /mylibs folder i get a ClassNotFoundException on runtime. 
>>>> 
>>>> I suspect that it could be due to order in which the classes are being loaded, so added a Loader component in my context.xml as below, but that too didn’t work. Can someone please help me on this?
>>> 
>>> JARs in /mylibs must not depend on JARs in a web application. There is
>>> no configuration option that would enable you to bypass this restriction.
>>> 
>>> Mark
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Mark Thomas <ma...@apache.org>.
On 26/05/2015 10:44, Aditya Chopra wrote:
> Thanks for quick response Mark.
> 
> JARs in /mylib are not dependent on JARs in web app. In fact its the other way round. /mylib is having all Spring, hibernate jar’s, other common libs and WEB-INF/lib is containing jar of one of my application modules.
> The class for which i am getting ClassNotFoundException exception is part of JAR present under WEB-INF/lib.
> 
> I enabled the class loader logs and don’t see that class getting loaded on server startup. However, when i copy all JAR’s from /mylib to WEB-INF/lib, that class is getting loaded and i don’t get the ClassNotFoundException on runtime.
> 
> Any thoughts what might be causing this?

Yes. One of the JARs in /mylib depends on one of the JARs in WEB-INF/lib
and that is not permitted.

The dependency may not be obvious. If you provide the full stack trace
we might be able to provide you with some pointers.

Mark

> 
> Aditya
> 
>> On 26-May-2015, at 3:04 pm, Mark Thomas <ma...@apache.org> wrote:
>>
>> On 26/05/2015 08:36, Aditya Chopra wrote:
>>> Hi,
>>>
>>> To reduce the size of my war file, i am trying to put all the jar files being used by my web app in a separate folder /mylibs. I added path to /mylibs folder under shared.loader property in catalina.properties but on runtime i am getting a ClassNotFoundException for one of the classes that is present in one the project module jar under WEB-INF/lib folder.
>>>
>>> When i add all the libraries required by my project in WEB-INF/lib folder my application works fine. However, when i put the libraries in a separate /mylibs folder i get a ClassNotFoundException on runtime. 
>>>
>>> I suspect that it could be due to order in which the classes are being loaded, so added a Loader component in my context.xml as below, but that too didn’t work. Can someone please help me on this?
>>
>> JARs in /mylibs must not depend on JARs in a web application. There is
>> no configuration option that would enable you to bypass this restriction.
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


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


Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Aditya Chopra <ad...@turvo.com>.
Thanks for quick response Mark.

JARs in /mylib are not dependent on JARs in web app. In fact its the other way round. /mylib is having all Spring, hibernate jar’s, other common libs and WEB-INF/lib is containing jar of one of my application modules.
The class for which i am getting ClassNotFoundException exception is part of JAR present under WEB-INF/lib.

I enabled the class loader logs and don’t see that class getting loaded on server startup. However, when i copy all JAR’s from /mylib to WEB-INF/lib, that class is getting loaded and i don’t get the ClassNotFoundException on runtime.

Any thoughts what might be causing this?

Aditya

> On 26-May-2015, at 3:04 pm, Mark Thomas <ma...@apache.org> wrote:
> 
> On 26/05/2015 08:36, Aditya Chopra wrote:
>> Hi,
>> 
>> To reduce the size of my war file, i am trying to put all the jar files being used by my web app in a separate folder /mylibs. I added path to /mylibs folder under shared.loader property in catalina.properties but on runtime i am getting a ClassNotFoundException for one of the classes that is present in one the project module jar under WEB-INF/lib folder.
>> 
>> When i add all the libraries required by my project in WEB-INF/lib folder my application works fine. However, when i put the libraries in a separate /mylibs folder i get a ClassNotFoundException on runtime. 
>> 
>> I suspect that it could be due to order in which the classes are being loaded, so added a Loader component in my context.xml as below, but that too didn’t work. Can someone please help me on this?
> 
> JARs in /mylibs must not depend on JARs in a web application. There is
> no configuration option that would enable you to bypass this restriction.
> 
> Mark
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


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


Re: Tomcat 8.0.22 - Putting all Libraries in a Separate Folder to reduce War file size

Posted by Mark Thomas <ma...@apache.org>.
On 26/05/2015 08:36, Aditya Chopra wrote:
> Hi,
> 
> To reduce the size of my war file, i am trying to put all the jar files being used by my web app in a separate folder /mylibs. I added path to /mylibs folder under shared.loader property in catalina.properties but on runtime i am getting a ClassNotFoundException for one of the classes that is present in one the project module jar under WEB-INF/lib folder.
> 
> When i add all the libraries required by my project in WEB-INF/lib folder my application works fine. However, when i put the libraries in a separate /mylibs folder i get a ClassNotFoundException on runtime. 
> 
> I suspect that it could be due to order in which the classes are being loaded, so added a Loader component in my context.xml as below, but that too didn’t work. Can someone please help me on this?

JARs in /mylibs must not depend on JARs in a web application. There is
no configuration option that would enable you to bypass this restriction.

Mark


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