tomcat 9 fails when requesting a new URL
I'm working on developing a web page using Tomcat 9 as the local server. My web page comes up and when I submit my page for processing, the tomcat server crashes. Interestingly, when I run the same sequence in Eclipse, everything works fine. Anyway, I looked at the logs directory and I see some suspicious sections, but nothing that points directly back to source code causing the problem. I cleared the log directory and re-ran my process and I am attaching a compressed tar file of the log directory. I'm wondering if anyone can see any indication that Tomcat 9 is not configured properly. I apologize for sending the entire directory, but it is fairly small and I want to make the entire log available. The most likely error point is the "java.io.StreamCorruptedException: invalid type code: 00" in the catalina.2021-01-10.log file. Can my process or environment be the root cause of this? Jim A jja_tomcat_logs.tgz Description: application/compressed-tar - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: troubled by "SEVERE: Cannot register null bean"
I've abandon PerUserPoolDataSource and retreated to org.apache.tomcat.jdbc.pool.DataSourceand multiple resource entries in context.xml (probably even if I could make PerUser work). I'm clearly missing a crucial piece. Here's my current full context.xml My apologies for the noise. On 1/9/21 8:10 PM, Rob Sargent wrote: After many loops through this, I'm pretty certain my datasource factory is simply never added to the context as per the SEVERE message. Any other combinations of lookups generates a NamingException. This verbose approach demonstrates that the key is in the map and it is mapped to null. InitialContext ic = new InitialContext(); Context sgsContext = (Context) ic.lookup("java:/comp/env"); Context jctx = (Context) sgsContext.lookup("jdbc"); dataSource = (PerUserPoolDataSource) jctx.lookup("sgsdb"); gets to the last line with a valid "jctx" but still returns null (and NOT a NamingException) // normally I would do just two lookups //Context sgsContext = (Context) ic.lookup("java:/comp/env"); //dataSource = (PerUserPoolDataSource) sgsContext.lookup("jdbc/sgsdb"); In NamingContextListener.addResource(ContextResource resorce) (9.0.41), Lines 1011-1028 if (("javax.sql.DataSource".equals(ref.getClassName()) || "javax.sql.XADataSource".equals(ref.getClassName())) && resource.getSingleton()) { Object actualResource =null; try { ObjectName on = createObjectName(resource); actualResource =envCtx.lookup(resource.getName()); Registry.getRegistry(null,null).registerComponent(actualResource,on,null); objectNames.put(resource.getName(),on); }catch (Exception e) { log.warn(sm.getString("naming.jmxRegistrationFailed", e)); } // Bug 63210. DBCP2 DataSources require an explicit close. This goes // further and cleans up and AutoCloseable DataSource by default. if (actualResourceinstanceof AutoCloseable && !resource.getCloseMethodConfigured()) { resource.setCloseMethod("close"); } } The lookup setting actualResource (line 1017) returns null. This uses the passed in resource which has name = "jdbc/sgsdb" and lookupName = null. That no resource is found makes sense since it's being registered and registerComponent refuses to register a null value. I have no idea why the actualResource (a DataSource Factory) is not available. On 1/8/21 9:11 AM, Rob Sargent wrote: I'm getting the following error message during startup SEVERE: Cannot register null bean for [Tomcat:type=DataSource,host=localhost,context=/sgs,class=javax.sql.DataSource,name="jdbc/sgsdb"] with sgs/META-INF/context.xml as classname="org.apache.tomcat.dbcp.dbcp.datasources.PerUserPoolDataSource" factory="org.apache.commons.dbcp2.datasources.PerUserPoolDataSourceFactory" /> and sgs/WEB-INF/web.xml as http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; version="2.5"> SGSaaS Enable debugging for the application debug true databaseHost ${SGSSRVR_databaseHost} java.lang.String databasePort ${SGSSRVR_databasePort} java.lang.Integer roleExtension ${SGSSRVR_roleExtension} java.lang.String expansionStep ${SGSSRVR_expansionStep} java.lang.Integer Pointer to context datasource jdbc/sgsdb javax.sql.DataSource Container Deep down in NamingContextListen actualResource =envCtx.lookup(resource.getName()); fails, setting actualResource to null and resource.getName() is "jdbc/sgsdb" I can get the env values (some of which are superfluous) in my app, but I cannot get the DataSource I think because it isn't there. I've tried (with castings removed for brevity) ctx = initialContext.lookup("java:/comp/env"); dataSource = ctx.lookup("jdbc/sgsdb"); dataSource=initialContext.lookup("sgs/jdbc/sgsdb") //with and without leading slash and several permutations of these. Where have a gone afoul of the XMLgod(s)?
Re: troubled by "SEVERE: Cannot register null bean"
The problem is what Mark pointed out above. In the type attribute you use the commons package name, but then specify the tomcat factory. Try changing the type attribute to type="org.apache.tomcat.dbcp.dbcp2.datasources.PerUserPoolPoolDataSource" Phil On 1/10/21 8:41 AM, Rob Sargent wrote: I've abandon PerUserPoolDataSource and retreated to org.apache.tomcat.jdbc.pool.DataSourceand multiple resource entries in context.xml (probably even if I could make PerUser work). I'm clearly missing a crucial piece. Here's my current full context.xml factory="org.apache.tomcat.dbcp.dbcp2.datasources.PerUserPoolDataSourceFactory" validationQuery="select 1" testWhileIdle="false" testOnBorrow="true" testOnReturn="false" validationInterval="3" timeBetweenEvictionRunsMillis="3" maxActive="50" initialSize="5" maxWait="1" removeAbandonedTimeout="60" minEvictableIdleTimeMillis="3" minIdle="1" maxIdle="5" logAbandoned="true" removeAbandoned="true" username="x" password="y" /> My apologies for the noise. On 1/9/21 8:10 PM, Rob Sargent wrote: After many loops through this, I'm pretty certain my datasource factory is simply never added to the context as per the SEVERE message. Any other combinations of lookups generates a NamingException. This verbose approach demonstrates that the key is in the map and it is mapped to null. InitialContext ic = new InitialContext(); Context sgsContext = (Context) ic.lookup("java:/comp/env"); Context jctx = (Context) sgsContext.lookup("jdbc"); dataSource = (PerUserPoolDataSource) jctx.lookup("sgsdb"); gets to the last line with a valid "jctx" but still returns null (and NOT a NamingException) // normally I would do just two lookups //Context sgsContext = (Context) ic.lookup("java:/comp/env"); //dataSource = (PerUserPoolDataSource) sgsContext.lookup("jdbc/sgsdb"); In NamingContextListener.addResource(ContextResource resorce) (9.0.41), Lines 1011-1028 if (("javax.sql.DataSource".equals(ref.getClassName()) || "javax.sql.XADataSource".equals(ref.getClassName())) && resource.getSingleton()) { Object actualResource =null; try { ObjectName on = createObjectName(resource); actualResource =envCtx.lookup(resource.getName()); Registry.getRegistry(null,null).registerComponent(actualResource,on,null); objectNames.put(resource.getName(),on); }catch (Exception e) { log.warn(sm.getString("naming.jmxRegistrationFailed", e)); } // Bug 63210. DBCP2 DataSources require an explicit close. This goes // further and cleans up and AutoCloseable DataSource by default. if (actualResourceinstanceof AutoCloseable && !resource.getCloseMethodConfigured()) { resource.setCloseMethod("close"); } } The lookup setting actualResource (line 1017) returns null. This uses the passed in resource which has name = "jdbc/sgsdb" and lookupName = null. That no resource is found makes sense since it's being registered and registerComponent refuses to register a null value. I have no idea why the actualResource (a DataSource Factory) is not available. On 1/8/21 9:11 AM, Rob Sargent wrote: I'm getting the following error message during startup SEVERE: Cannot register null bean for [Tomcat:type=DataSource,host=localhost,context=/sgs,class=javax.sql.DataSource,name="jdbc/sgsdb"] with sgs/META-INF/context.xml as classname="org.apache.tomcat.dbcp.dbcp.datasources.PerUserPoolDataSource" factory="org.apache.commons.dbcp2.datasources.PerUserPoolDataSourceFactory" /> and sgs/WEB-INF/web.xml as http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; version="2.5"> SGSaaS Enable debugging for the application debug true databaseHost ${SGSSRVR_databaseHost} java.lang.String databasePort ${SGSSRVR_databasePort} java.lang.Integer roleExtension ${SGSSRVR_roleExtension} java.lang.String expansionStep ${SGSSRVR_expansionStep} java.lang.Integer Pointer to context datasource jdbc/sgsdb javax.sql.DataSource Container Deep down in NamingContextListen actualResource =envCtx.lookup(resource.getName()); fails, setting actualResource to null and resource.getName() is "jdbc/sgsdb" I can get the env values (some of which are superfluous) in my app, but I cannot get the DataSource I think because it isn't there. I've tried (with castings removed for brevity) ctx = initialContext.lookup("java:/comp/env"); dataSource = ctx.l
Re: troubled by "SEVERE: Cannot register null bean"
Honest I had corrected as Mark suggested, but I was first forgetting to match up the web.xml and then missing an error condition ("Must set the ConnectionPoolDataSource through setDataSourceName or setConnectionPoolDataSource before calling getConnection"). I've seen this and can confirm my folly, but I doubt I'll go back to PerUser since it doesn't by me the flexibility I was seeking. I will be using multiple Resource/DataSource entries, perhaps relying on tomcat noticing a new war. I doubly apologise for reposting the incorrect config. Thanks for you patience. rjs TL/DR: while investigation pool options I found a page on PerUser which stated firmly that two things had to be set: #1 was the factory and was #2 the DataSourceName? I re-found that page! Thanks so much, rj. On 1/10/21 11:57 AM, Phil Steitz wrote: The problem is what Mark pointed out above. In the type attribute you use the commons package name, but then specify the tomcat factory. Try changing the type attribute to type="org.apache.tomcat.dbcp.dbcp2.datasources.PerUserPoolPoolDataSource" Phil On 1/10/21 8:41 AM, Rob Sargent wrote: I've abandon PerUserPoolDataSource and retreated to org.apache.tomcat.jdbc.pool.DataSourceand multiple resource entries in context.xml (probably even if I could make PerUser work). I'm clearly missing a crucial piece. Here's my current full context.xml factory="org.apache.tomcat.dbcp.dbcp2.datasources.PerUserPoolDataSourceFactory" validationQuery="select 1" testWhileIdle="false" testOnBorrow="true" testOnReturn="false" validationInterval="3" timeBetweenEvictionRunsMillis="3" maxActive="50" initialSize="5" maxWait="1" removeAbandonedTimeout="60" minEvictableIdleTimeMillis="3" minIdle="1" maxIdle="5" logAbandoned="true" removeAbandoned="true" username="x" password="y" /> My apologies for the noise. On 1/9/21 8:10 PM, Rob Sargent wrote: After many loops through this, I'm pretty certain my datasource factory is simply never added to the context as per the SEVERE message. Any other combinations of lookups generates a NamingException. This verbose approach demonstrates that the key is in the map and it is mapped to null. InitialContext ic = new InitialContext(); Context sgsContext = (Context) ic.lookup("java:/comp/env"); Context jctx = (Context) sgsContext.lookup("jdbc"); dataSource = (PerUserPoolDataSource) jctx.lookup("sgsdb"); gets to the last line with a valid "jctx" but still returns null (and NOT a NamingException) // normally I would do just two lookups //Context sgsContext = (Context) ic.lookup("java:/comp/env"); //dataSource = (PerUserPoolDataSource) sgsContext.lookup("jdbc/sgsdb"); In NamingContextListener.addResource(ContextResource resorce) (9.0.41), Lines 1011-1028 if (("javax.sql.DataSource".equals(ref.getClassName()) || "javax.sql.XADataSource".equals(ref.getClassName())) && resource.getSingleton()) { Object actualResource =null; try { ObjectName on = createObjectName(resource); actualResource =envCtx.lookup(resource.getName()); Registry.getRegistry(null,null).registerComponent(actualResource,on,null); objectNames.put(resource.getName(),on); }catch (Exception e) { log.warn(sm.getString("naming.jmxRegistrationFailed", e)); } // Bug 63210. DBCP2 DataSources require an explicit close. This goes // further and cleans up and AutoCloseable DataSource by default. if (actualResourceinstanceof AutoCloseable && !resource.getCloseMethodConfigured()) { resource.setCloseMethod("close"); } } The lookup setting actualResource (line 1017) returns null. This uses the passed in resource which has name = "jdbc/sgsdb" and lookupName = null. That no resource is found makes sense since it's being registered and registerComponent refuses to register a null value. I have no idea why the actualResource (a DataSource Factory) is not available. On 1/8/21 9:11 AM, Rob Sargent wrote: I'm getting the following error message during startup SEVERE: Cannot register null bean for [Tomcat:type=DataSource,host=localhost,context=/sgs,class=javax.sql.DataSource,name="jdbc/sgsdb"] with sgs/META-INF/context.xml as classname="org.apache.tomcat.dbcp.dbcp.datasources.PerUserPoolDataSource" factory="org.apache.commons.dbcp2.datasources.PerUserPoolDataSourceFactory" /> and sgs/WEB-INF/web.xml as http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; version="2.5"> SGSaaS Enable debugging for the application debug true
javadoc 404
While trying to understand why PerUserPoolDataSource doesn't implement javax.sql.ConnectionPoolDataSource on https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/tomcat/dbcp/dbcp2/datasources/package-summary.html I get a 404 from anchor cpdsadapter example https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/package.html
Re: javadoc 404
Rob, On 1/10/2021 8:51 PM, Rob Sargent wrote: While trying to understand why PerUserPoolDataSource doesn't implement javax.sql.ConnectionPoolDataSource on https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/tomcat/dbcp/dbcp2/datasources/package-summary.html I get a 404 from anchor cpdsadapter example https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/package.html I went to https://tomcat.apache.org/tomcat-9.0-doc/api/overview-summary.html and then https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/package-summary.html with no issue. Maybe an internal link is broken? . . . just my two cents /mde/ OpenPGP_signature Description: OpenPGP digital signature
Re: tomcat 9 fails when requesting a new URL
On 10/01/2021 15:10, Jim Anderson wrote: > > I'm working on developing a web page using Tomcat 9 as the local server. > My web page comes up and when I submit my page for processing, the > tomcat server crashes. Interestingly, when I run the same sequence in > Eclipse, everything works fine. > > Anyway, I looked at the logs directory and I see some suspicious > sections, but nothing that points directly back to source code causing > the problem. I cleared the log directory and re-ran my process and I am > attaching a compressed tar file of the log directory. I'm wondering if > anyone can see any indication that Tomcat 9 is not configured properly. > I apologize for sending the entire directory, but it is fairly small and > I want to make the entire log available. > > The most likely error point is the "java.io.StreamCorruptedException: > invalid type code: 00" in the catalina.2021-01-10.log file. Can my > process or environment be the root cause of this? Yes. The application is placing attributes into the session that are not serializable. Fix that, clear the work directory and then test. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org