Hi, > > Could someone tell me what is the purpose of having WebappLoader and > > WebappClassLoader in Tomcat? > >>WebappLoader is the Tomcat object that a user can configure that > >>represents the class loader. It remains the same across web application > >>stop/start. > > >>WebappClassLoader is the actual class loader. Every time the web > >>application is started, a new instance is created and used. > > > As I understand WebappClassLoader is per web application and WebAppLoader > for > > tomcat server instance. Am I wrong? > >>Yes. > Thanks for the quick explanation. > So it means WebappClassLoader and WebAppLoader both are per web > application. > In tomcat 7 we were able to add repository to the class loader using > WebAppClassLoader.addRepository()
>>This is replaced in favor of the new resource implementation. >>Check this [1] and this [2]. Previous Implementation was @Override protected void startInternal() throws LifecycleException { .. for (String repository : webappClassloadingContext.getProvidedRepositories()) { addRepository(repository); } super.startInternal(); .. } Now I tried to add the required repositories as follows now @Override protected void startInternal() throws LifecycleException { .. if(webappClassloadingContext.getProvidedRepositories().length > 0){ File dir = new File(webappClassloadingContext.getProvidedRepositories()[0]); WebResourceRoot resources = getContext().getResources(); resources.addJarResources(new DirResourceSet(resources, "/WEB-INF/lib", dir.getAbsolutePath(), getContext().getPath())); getContext().setResources(resources); } super.startInternal(); .. } But I'm getting org.apache.catalina.LifecycleException: Failed to start component > [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/jaxrs_basic]] > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) > at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) > at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) > at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) > at > org.wso2.carbon.tomcat.internal.CarbonTomcat.addWebApp(CarbonTomcat.java:344) > at > org.wso2.carbon.tomcat.internal.CarbonTomcat.addWebApp(CarbonTomcat.java:189) > at > org.wso2.carbon.webapp.mgt.TomcatGenericWebappsDeployer.handleWebappDeployment(TomcatGenericWebappsDeployer.java:258) > at > org.wso2.carbon.webapp.mgt.TomcatGenericWebappsDeployer.handleWarWebappDeployment(TomcatGenericWebappsDeployer.java:207) > at > org.wso2.carbon.webapp.mgt.TomcatGenericWebappsDeployer.handleHotDeployment(TomcatGenericWebappsDeployer.java:174) > at > org.wso2.carbon.webapp.mgt.TomcatGenericWebappsDeployer.deploy(TomcatGenericWebappsDeployer.java:139) > at > org.wso2.carbon.webapp.mgt.AbstractWebappDeployer.deployThisWebApp(AbstractWebappDeployer.java:204) > at > org.wso2.carbon.webapp.mgt.AbstractWebappDeployer.deploy(AbstractWebappDeployer.java:111) > at > org.wso2.carbon.webapp.deployer.WebappDeployer.deploy(WebappDeployer.java:42) > at > org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136) > at > org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:807) > at > org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144) > at > org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377) > at > org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254) > at > org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:135) > at > org.wso2.carbon.core.CarbonAxisConfigurator.deployServices(CarbonAxisConfigurator.java:567) > at > org.wso2.carbon.core.internal.DeploymentServerStartupObserver.completingServerStartup(DeploymentServerStartupObserver.java:51) > at > org.wso2.carbon.core.internal.CarbonCoreServiceComponent.notifyBefore(CarbonCoreServiceComponent.java:235) > at > org.wso2.carbon.core.internal.StartupFinalizerServiceComponent.completeInitialization(StartupFinalizerServiceComponent.java:185) > at > org.wso2.carbon.core.internal.StartupFinalizerServiceComponent.serviceChanged(StartupFinalizerServiceComponent.java:288) > at > org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861) > at > org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) > at > org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451) > at > org.wso2.carbon.throttling.agent.internal.ThrottlingAgentServiceComponent.registerThrottlingAgent(ThrottlingAgentServiceComponent.java:123) > at > org.wso2.carbon.throttling.agent.internal.ThrottlingAgentServiceComponent.activate(ThrottlingAgentServiceComponent.java:100) > 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 > org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260) > at > org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146) > at > org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345) > at > org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620) > at > org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197) > at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343) > at > org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222) > at > org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861) > at > org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) > at > org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451) > at > org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:517) > at > org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219) > at > org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:91) > 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 > org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260) > at > org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146) > at > org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345) > at > org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620) > at > org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197) > at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343) > at > org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222) > at > org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861) > at > org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) > at > org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130) > at > org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214) > at > org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433) > at > org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81) > at > org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60) > at > org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40) > at > org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38) > at > org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231) > at > org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144) > at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031) > at > org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4909) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > at > org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) > at > org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > at java.lang.Thread.run(Thread.java:745) > Caused by: org.apache.catalina.LifecycleException: Failed to start > component [WebappLoader[/jaxrs_basic]] > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5030) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > ... 95 more > Caused by: java.lang.IllegalStateException: > org.apache.catalina.LifecycleException: Failed to initialize component > [org.apache.catalina.webresources.DirResourceSet@647452d0] > at > org.apache.catalina.webresources.DirResourceSet.<init>(DirResourceSet.java:83) > at > org.wso2.carbon.webapp.mgt.loader.CarbonWebappLoader.startInternal(CarbonWebappLoader.java:61) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > ... 97 more > Caused by: org.apache.catalina.LifecycleException: Failed to initialize > component [org.apache.catalina.webresources.DirResourceSet@647452d0] > at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139) > at > org.apache.catalina.webresources.DirResourceSet.<init>(DirResourceSet.java:81) > ... 99 more 2015-04-21 12:14 GMT+05:30 Thusitha Thilina Dayaratne < thusithathil...@gmail.com>: > Hi > > > > Could someone tell me what is the purpose of having WebappLoader and > > > WebappClassLoader in Tomcat? > > >>WebappLoader is the Tomcat object that a user can configure that > > >>represents the class loader. It remains the same across web application > > >>stop/start. > > > > >>WebappClassLoader is the actual class loader. Every time the web > > >>application is started, a new instance is created and used. > > > > > As I understand WebappClassLoader is per web application and > WebAppLoader > > for > > > tomcat server instance. Am I wrong? > > >>Yes. > > Thanks for the quick explanation. > > So it means WebappClassLoader and WebAppLoader both are per web > > application. > > In tomcat 7 we were able to add repository to the class loader using > > WebAppClassLoader.addRepository() > > >>This is replaced in favor of the new resource implementation. > >>Check this [1] and this [2]. > Thanks for quick response. > I will look into them :) > > Best Regards > > 2015-04-21 12:02 GMT+05:30 Violeta Georgieva <violet...@apache.org>: > >> Hi, >> >> 2015-04-21 6:42 GMT+03:00 Thusitha Thilina Dayaratne < >> thusithathil...@gmail.com>: >> > >> > Hi, >> > >> > > Could someone tell me what is the purpose of having WebappLoader and >> > > WebappClassLoader in Tomcat? >> > >>WebappLoader is the Tomcat object that a user can configure that >> > >>represents the class loader. It remains the same across web >> application >> > >>stop/start. >> > >> > >>WebappClassLoader is the actual class loader. Every time the web >> > >>application is started, a new instance is created and used. >> > >> > > As I understand WebappClassLoader is per web application and >> WebAppLoader >> > for >> > > tomcat server instance. Am I wrong? >> > >>Yes. >> > Thanks for the quick explanation. >> > So it means WebappClassLoader and WebAppLoader both are per web >> > application. >> > In tomcat 7 we were able to add repository to the class loader using >> > WebAppClassLoader.addRepository() >> >> This is replaced in favor of the new resource implementation. >> Check this [1] and this [2]. >> >> Regards, >> Violeta >> >> [1] http://tomcat.apache.org/migration-8.html#Web_application_resources >> [2] http://tomcat.apache.org/tomcat-8.0-doc/config/resources.html >> >> > So in Tomcat 8 if we wanna add repositories to the classloader we should >> > done that trough the WebAppLoader not with WebAppClassLoader? >> > Please correct me if I'm wrong. >> > >> > Thanks >> > Best Regards >> > >> > 2015-04-21 1:51 GMT+05:30 Mark Thomas <ma...@apache.org>: >> > >> > > On 20/04/2015 14:22, Thusitha Thilina Dayaratne wrote: >> > > > Hi, >> > > > >> > > > Could someone tell me what is the purpose of having WebappLoader and >> > > > WebappClassLoader in Tomcat? >> > > >> > > WebappLoader is the Tomcat object that a user can configure that >> > > represents the class loader. It remains the same across web >> application >> > > stop/start. >> > > >> > > WebappClassLoader is the actual class loader. Every time the web >> > > application is started, a new instance is created and used. >> > > >> > > > As I understand WebappClassLoader is per web application and >> > > WebAppLoader for >> > > > tomcat server instance. Am I wrong? >> > > >> > > Yes. >> > > >> > > Mark >> > > >> > > >> > > --------------------------------------------------------------------- >> > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> > > For additional commands, e-mail: users-h...@tomcat.apache.org >> > > >> > > >> > >> > >> > -- >> > > > > -- > > --