Re: Problrm with resources added using DirResourceSet
2015-05-20 20:30 GMT+03:00 Ed Rouse : > Server version: Apache Tomcat/8.0.14 A bit old... > Server built: Sep 24 2014 09:01:51 > Server number: 8.0.14.0 > OS Name:Linux > OS Version: 3.8.0-29-generic > Architecture: amd64 > JVM Version:1.7.0_55-b14 > JVM Vendor: Oracle Corporation > > I have implemented a custom WebappClassLoaderBase and StandardRoot, and it > looks like it is working; but the resources added are not available to the > web app. What follows is a bit long and I apologize for that, but didn't want > to leave out potentially important information. Any ideas on what's wrong? At what point of Lifecycle is your code called? Has StandardRoot.initInternal() already happened? Has StandardRoot.startInternal() already happened? > This is the code snippet: > > wsRoot = IDWMPluginRegistry.getInstance().getWebRoot(); > log.info("IDWMClassLoader init: " + wsRoot.getContext().getName()); > Set plugins = IDWMPluginRegistry.getInstance().getPlugins(); > for(IDWMPlugin plugin: plugins) > { > log.info("Loading plugin: " + plugin.getLoaderClassName()); > try > { > if(wsRoot == null) > { > log.info("wsRoot not set."); > wsRoot = new StandardRoot(); The above code does not work. It will fail at "if(wsRoot.getContext() == null)" check on the next line... > } > if(wsRoot.getContext() == null) > { > throw new Exception("NO CONTEXT!!!"); > } > File pFile = plugin.getRoot(); > log.info("Adding plugin root " + pFile.getAbsolutePath() + " to the > WebResourceRoot as a DirResourceSet."); > > DirResourceSet drs = new DirResourceSet(wsRoot, "/", > pFile.getAbsolutePath(), "/"); > log.info("DirResourceSet base URL = " + drs.getBaseUrl().toString()); > wsRoot.addPostResources(drs); > } > catch(Exception e) > { > log.log(Level.SEVERE, "Error setting up class path", e); > } > } > > And here is the catalina.out log pertaining to this section of code. > (...) https://wiki.apache.org/tomcat/FAQ/Developing#Debugging Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Problrm with resources added using DirResourceSet
On 20/05/2015 18:30, Ed Rouse wrote: > Server version: Apache Tomcat/8.0.14 > Server built: Sep 24 2014 09:01:51 > Server number: 8.0.14.0 > OS Name:Linux > OS Version: 3.8.0-29-generic > Architecture: amd64 > JVM Version:1.7.0_55-b14 > JVM Vendor: Oracle Corporation > > I have implemented a custom WebappClassLoaderBase and StandardRoot, and it > looks like it is working; but the resources added are not available to the > web app. What follows is a bit long and I apologize for that, but didn't want > to leave out potentially important information. Any ideas on what's wrong? Thanks for all the info. I can't see anything obviously wrong in what you posted. I'd fire up a debugger and step through the StandardRoot.getResource() call and check: - You see the StandardRoot instance you expect to see - The DirResourceSet is present - Follow the code to see why the resource isn't looked up in your DirResourceSet HTH, Mark > > This is the code snippet: > > wsRoot = IDWMPluginRegistry.getInstance().getWebRoot(); > log.info("IDWMClassLoader init: " + wsRoot.getContext().getName()); > Set plugins = IDWMPluginRegistry.getInstance().getPlugins(); > for(IDWMPlugin plugin: plugins) > { > log.info("Loading plugin: " + plugin.getLoaderClassName()); > try > { > if(wsRoot == null) > { > log.info("wsRoot not set."); > wsRoot = new StandardRoot(); > } > if(wsRoot.getContext() == null) > { > throw new Exception("NO CONTEXT!!!"); > } > File pFile = plugin.getRoot(); > log.info("Adding plugin root " + pFile.getAbsolutePath() + " to the > WebResourceRoot as a DirResourceSet."); > > DirResourceSet drs = new DirResourceSet(wsRoot, "/", > pFile.getAbsolutePath(), "/"); > log.info("DirResourceSet base URL = " + drs.getBaseUrl().toString()); > wsRoot.addPostResources(drs); > } > catch(Exception e) > { > log.log(Level.SEVERE, "Error setting up class path", e); > } > } > > And here is the catalina.out log pertaining to this section of code. > > 17-May-2015 23:27:52.399 INFO [localhost-startStop-1] > org.apache.catalina.startup.HostConfig.deployDirectory Deploying web > application directory /usr/local/apache-tomcat-8.0.14/webapps/ROOT > 17-May-2015 23:27:53.243 INFO [localhost-startStop-1] > org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned > for TLDs yet contained no TLDs. Enable debug logging for this logger for a > complete list of JARs that were scanned but no TLDs were found in them. > Skipping unneeded JARs during scanning can improve startup time and JSP > compilation time. > 17-May-2015 23:27:53.385 INFO [localhost-startStop-1] > org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web > application directory /usr/local/apache-tomcat-8.0.14/webapps/ROOT has > finished in 986 ms > 17-May-2015 23:27:53.388 INFO [localhost-startStop-1] > org.apache.catalina.startup.HostConfig.deployDirectory Deploying web > application directory /usr/local/apache-tomcat-8.0.14/webapps/idwm > 17-May-2015 23:27:53.424 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMFileDirContext. Default Constructor. > 17-May-2015 23:27:53.425 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMFileDirContext.importPlugins System > property idwm.plugins not set; using default plugin path /usr/us/idwm/plugins > 17-May-2015 23:27:53.431 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMFileDirContext.importFromDirectory Found > plugin at /usr/us/idwm/plugins/idw-plugins-role_change_attribute_audit > 17-May-2015 23:27:54.146 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMClassLoader. parent > constructor.class java.net.URLClassLoader > 17-May-2015 23:27:54.147 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMClassLoader.init IDWMClassLoader init: > /idwm > 17-May-2015 23:27:54.148 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMClassLoader.init Loading plugin: > idwplugin.RoleChangeAttributeAudit.RoleChangeAttributeAuditPluginLoader > 17-May-2015 23:27:54.148 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMClassLoader.init Adding plugin root > /usr/us/idwm/plugins/idw-plugins-role_change_attribute_audit to the > WebResourceRoot as a DirResourceSet. > 17-May-2015 23:27:54.148 INFO [localhost-startStop-1] > com.comsquared.idw.catalina.ext.IDWMClassLoader.init DirResourceSet base URL > = file:/usr/us/idwm/plugins/idw-plugins-role_change_attribute_audit/ > 17-May-2015 23:28:05.198 INFO [localhost-startStop-1] > com.comsquared.idwm.DataSourceFactory.getObjectInstance Get JNDI datasource > ImageDirectorWorkflowDS from app config > log4j:WARN No such property [maxBackupIndex] in > org.apache.log4j.DailyRollingFileAppender. > 17-May-2015 23:28:15.3
Problrm with resources added using DirResourceSet
Server version: Apache Tomcat/8.0.14 Server built: Sep 24 2014 09:01:51 Server number: 8.0.14.0 OS Name:Linux OS Version: 3.8.0-29-generic Architecture: amd64 JVM Version:1.7.0_55-b14 JVM Vendor: Oracle Corporation I have implemented a custom WebappClassLoaderBase and StandardRoot, and it looks like it is working; but the resources added are not available to the web app. What follows is a bit long and I apologize for that, but didn't want to leave out potentially important information. Any ideas on what's wrong? This is the code snippet: wsRoot = IDWMPluginRegistry.getInstance().getWebRoot(); log.info("IDWMClassLoader init: " + wsRoot.getContext().getName()); Set plugins = IDWMPluginRegistry.getInstance().getPlugins(); for(IDWMPlugin plugin: plugins) { log.info("Loading plugin: " + plugin.getLoaderClassName()); try { if(wsRoot == null) { log.info("wsRoot not set."); wsRoot = new StandardRoot(); } if(wsRoot.getContext() == null) { throw new Exception("NO CONTEXT!!!"); } File pFile = plugin.getRoot(); log.info("Adding plugin root " + pFile.getAbsolutePath() + " to the WebResourceRoot as a DirResourceSet."); DirResourceSet drs = new DirResourceSet(wsRoot, "/", pFile.getAbsolutePath(), "/"); log.info("DirResourceSet base URL = " + drs.getBaseUrl().toString()); wsRoot.addPostResources(drs); } catch(Exception e) { log.log(Level.SEVERE, "Error setting up class path", e); } } And here is the catalina.out log pertaining to this section of code. 17-May-2015 23:27:52.399 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/apache-tomcat-8.0.14/webapps/ROOT 17-May-2015 23:27:53.243 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 17-May-2015 23:27:53.385 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/apache-tomcat-8.0.14/webapps/ROOT has finished in 986 ms 17-May-2015 23:27:53.388 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/apache-tomcat-8.0.14/webapps/idwm 17-May-2015 23:27:53.424 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMFileDirContext. Default Constructor. 17-May-2015 23:27:53.425 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMFileDirContext.importPlugins System property idwm.plugins not set; using default plugin path /usr/us/idwm/plugins 17-May-2015 23:27:53.431 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMFileDirContext.importFromDirectory Found plugin at /usr/us/idwm/plugins/idw-plugins-role_change_attribute_audit 17-May-2015 23:27:54.146 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMClassLoader. parent constructor.class java.net.URLClassLoader 17-May-2015 23:27:54.147 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMClassLoader.init IDWMClassLoader init: /idwm 17-May-2015 23:27:54.148 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMClassLoader.init Loading plugin: idwplugin.RoleChangeAttributeAudit.RoleChangeAttributeAuditPluginLoader 17-May-2015 23:27:54.148 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMClassLoader.init Adding plugin root /usr/us/idwm/plugins/idw-plugins-role_change_attribute_audit to the WebResourceRoot as a DirResourceSet. 17-May-2015 23:27:54.148 INFO [localhost-startStop-1] com.comsquared.idw.catalina.ext.IDWMClassLoader.init DirResourceSet base URL = file:/usr/us/idwm/plugins/idw-plugins-role_change_attribute_audit/ 17-May-2015 23:28:05.198 INFO [localhost-startStop-1] com.comsquared.idwm.DataSourceFactory.getObjectInstance Get JNDI datasource ImageDirectorWorkflowDS from app config log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.DailyRollingFileAppender. 17-May-2015 23:28:15.367 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/apache-tomcat-8.0.14/webapps/idwm has finished in 21,978 ms 17-May-2015 23:28:15.371 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/apache-tomcat-8.0.14/webapps/docs 17-May-2015 23:28:15.425 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this