I have a Tomcat 7 server that receives a lot of GET-requests. This works very well for some time, then suddenly it stops working (after 7-8 hours).
When it stops working, I am getting this error:
mai 06, 2015 12:47:58 AM org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
All others errors after this, is just the same. I have tried to stop the get-requests, but it crashes after a while anyways. Do you have any ideas?
This is right before it crashes:
[06/May/2015:10:47:11 +0200] "GET /ListenerServlet?request=getLastChanged&_=1430852558104 HTTP/1.1" 200 32
After the crash:
[06/May/2015:10:47:14 +0200] "GET /ListenerServlet?request=getLastChanged&_=1430902035081 HTTP/1.1" 500 1674
After the crash, the Servlet can't get the request parameter.. that throws this nullpointer:
SEVERE: Servlet.service() for servlet [RoomServlet] in context with path [] threw exception java.lang.NullPointerException
at factory.Factory.initEditMode(Factory.java:37)
at factory.Factory.init(Factory.java:20)
at factory.TabsFactory.<init>(TabsFactory.java:19)
at servlet.RoomServlet.getTabs(RoomServlet.java:285)
at servlet.RoomServlet.doGet(RoomServlet.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
followed by:
mai 07, 2015 9:58:00 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class websocket.drawboard.DrawboardContextListener
java.lang.NoClassDefFoundError: javax/websocket/Endpoint
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2944)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at websocket.drawboard.DrawboardContextListener.contextDestroyed(DrawboardContextListener.java:32)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5014)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5659)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: javax.websocket.Endpoint
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
... 17 more
IF there is anything more I need to add, let me know! I really appreciate.
EDIT: Today was a good day, I got a new error! This might have something with the JDBC....
The last packet successfully received from the server was 33 921 291
milliseconds ago. The last packet sent successfully to the server was
1 milliseconds ago. No operations allowed after connection closed.
You can try installing Apache Tomcat v7.0.53 or higher.
Maybe you have a file descriptor leak, which could cause failure in class loading, you can check how many file descriptor are open by using lsof.
I found out the solution to this almost by random.
There was nothing related to:
org.apache.coyote.http11.AbstractHttp11Processor process
but it was rather a JDBC problem.. the connection closed after 8 hours, and I didn't get any errors in the Servlet' for this.
The solution for me was to add some lines in my application's Context:
I added:
url="jdbc:mysql://127.0.0.1:3306/test?autoReconnect=true"
dontTrackOpenResources="true"
testWhileIdle="true"
timeBetweenEvictionRunsMillis="300000"
This is my full Context now:
<Context>
<Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="100" maxWait="30000"
username="test" password="bestpassword"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/test?autoReconnect=true"
removeAbandoned="true" removeAbandonedTimeout="10"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
fairQueue="true"
dontTrackOpenResources="true"
testWhileIdle="true"
timeBetweenEvictionRunsMillis="300000"
/>
</Context>
My server has not crashed in a week now, and I believe it wont crash again.
Related
we currently have a problem with our jhipster application. from time to time the following exception is logged on our server
2021-12-15 09:58:09.813 ERROR 2784 --- [0.1-8080-exec-4] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:624)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:211)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:360)
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:873)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:858)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:591)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:527)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:389)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:254)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:349)
at org.apache.catalina.core.AsyncContextImpl.setErrorState(AsyncContextImpl.java:424)
at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:176)
at org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:245)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
we use the following technologies:
jhipster 5.8.2. with embedded tomcat
spring boot 2.0.8.
angular 7.3.1.
i can't exactly tell what causes the exception mentioned above to be thrown and furthermore we do not see any impact on the functionality of the program itself but the exception causes our logfile to get spammed with these exceptions.
additionally, the exception is only logged when we deploy the app to our ubuntu server but the exception does not get logged when i run/debug the app locally in my eclipse IDE on my windows pc.
furthermore, locally on my windows pc i run the app with oracle jdk 8 and on the ubuntu server we run the app with openjdk 11. could this make a difference?
additional note:
we switched from spring-boot-starter-undertow to spring-boot-starter-tomcat recently and since then the exception is thrown permanently (it was never thrown using spring-boot-starter-undertow)
any help how to get rid of this exception would be greatly appreciated!
UPDATE 17.12.2021:
i forgot to mention that we are heavily relying on websockets for our angular clients to receive updates from the spring boot server in realtime
after observing the problem for a while we noticed that often (nearly always) before the exception is thrown the following warnings are logged:
2021-12-17 10:31:25.352 WARN 18686 --- [0.1-8080-exec-5] o.z.problem.spring.common.AdviceTrait : Forbidden: Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-XSRF-TOKEN'.
2021-12-17 10:31:28.496 WARN 18686 --- [.1-8080-exec-10] o.z.problem.spring.common.AdviceTrait : Forbidden: Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-XSRF-TOKEN'.
2021-12-17 10:31:28.897 WARN 18686 --- [0.1-8080-exec-7] o.s.w.s.s.t.h.DefaultSockJsService : Origin check enabled but transport 'jsonp' does not support it.
these warnings also occured when we used undertow but the IllegalStateExceptions did not get thrown.
additionally, after the first exception mentioned above is thrown it's always followed by the following exception, which i assume is a consequence of the first exception (embedded tomcat seems to try to redirect to a tomcat error page due to the first thrown exception as seen in cause)
2021-12-17 10:18:43.535 ERROR 18686 --- [0.1-8080-exec-3] o.a.c.c.C.[Tomcat].[localhost] : Exception Processing ErrorPage[errorCode=0, location=/error]
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:989)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:873)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:858)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:591)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:527)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:389)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:254)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:349)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:175)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:230)
at org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:245)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:624)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:211)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109)
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:360)
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981)
... 25 common frames omitted
is it possible, that the warnings mentioned above cause these IllegalStateExceptions to be thrown but only with embedded tomcat but not with embedded undertow? is there anything configured for embedded undertow to not throw these exceptions?
if these warnings were the reason for these exceptions, how could we get rid of these warnings and hence the exceptions?
We are Migrating Struts 1.2 project from JDK 1.6 to 1.8 and application server jboss5.1 to tomcat 8.0. Database connection is working fine and initial pages are loading and populating some data. But when i do any action(Submit button)it throws an exception javax.naming.NamingException: Cannot create resource instance Same code was working in jboss 5.1 but getting an error in Tomcat 8.
But i am suspecting reason for the error is UserTransaction needs to be defined separately in the context.xml but not sure about it. Please let me know.
UserTransaction ut = (UserTransaction) myCntxt.lookup("java:comp/UserTransaction");
If UserTransaction needs to be defined , Please let me know how to configure in Tomcat server ?
Added database configuration in context.xml under META-INF/context.xml
<Resource name="jdbc/Test1"
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
maxIdle="30"
maxWaitMillis="10000"
username="xxxxx"
password="xxxxx"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#xxxx:1527:xxxx" />
<Resource name="jdbc/Test2"
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
maxIdle="30"
maxWaitMillis="10000"
username="xxxxx"
password="xxxxx"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#xxxx:1527:xxxx" />
Added data source reference in web.xml under {project}/WEB-INF/web.xml
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/Test1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/Test2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Sample Code
public static void dbInit(String test1dataSourceReference,String test2dataSourceReference) throws Exception
{
Context ctx = new InitialContext();
tds =(DataSource) ctx.lookup("java:comp/env/" + test1dataSourceReference);
cds = (DataSource) ctx.lookup("java:comp/env/" + test2dataSourceReference);
}
Stack-trace:
Dec 25, 2019 7:28:07 AM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
Dec 25, 2019 7:28:07 AM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
Dec 25, 2019 7:28:07 AM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
Dec 25, 2019 7:28:07 AM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
Dec 25, 2019 7:28:08 AM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.taglib.logic.LocalStrings', returnNull=true
Dec 25, 2019 7:28:08 AM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
Dec 25, 2019 7:28:08 AM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
Dec 25, 2019 7:28:22 AM org.apache.struts.action.RequestProcessor processException
WARNING: Unhandled Exception thrown: class javax.naming.NamingException
Dec 25, 2019 7:28:22 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [action] in context with path [/policy] threw exception [javax.naming.NamingException: Cannot create resource instance] with root cause
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:96)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:847)
at org.apache.naming.NamingContext.lookup(NamingContext.java:158)
at org.apache.naming.NamingContext.lookup(NamingContext.java:835)
at org.apache.naming.NamingContext.lookup(NamingContext.java:172)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:157)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.db.DbQuery.saveAppRejValue(DbQuery.java:798)
at com.actions.PolicyAction.executeDisplay(PolicyAction.java:298)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
As the TomEE Comparison page indicates Tomcat does not have support for JTA (JSR 907):
You'll either need to remove the JTA code or consider another EE server like Wildfly as a simpler upgrade path.
you can deploy a 3rd party TransactionManager solution (ie Atomikos) in your Tomcat, we have done it with an older version of Tomcat. We now run Struts1 (and Struts2) app on JBoss 6, so the code is compatible with newer JBoss which provides a JTA implementation.
You can remove the transactional boundaries from your code (keeping ORM and DAO code) but I am not sure it is a great idea as data inconsistency is a risk.
If you want to minimise changes I would try to upgrade to a newer JBoss version.
A better medium-term solution is to integrate Spring Transaction Management (if you don't need to handle transactions across multiple resources).
A long-term solution would be to refactor out Struts1 (epic effort probably but I must mention it).
Good luck.
Beppe
Need help troubleshooting MySQL database connect issue. First, when I run my Java web application on my development workstation I can successfully connect to my remote/hosted MySQL database.
When I deploy my Java web application to my hosted web server I get the following error org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
I have the mysql-connector-java-5.1.38.bin.jar located in the WEB-INF/libraries folder within my application. Like I said before, this seems to work fine when I run my web application on my local development machine, but fails when deployed to my web host.
Tomcat v7.x is running on my development workstation and my web host is using Tomcat v7.x as well. My development workstation is Windows based. I believe the web host is running CentOS7.x.
The other confusing part is my web application worked with my previous web host as written.
How can I get this problem resolved?
EDIT 3/9/2016
Context.xml:
<Resource
name="jdbc/dbname_ccp"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://domain.com:3306/dbname_ccp"
username="username_admin"
password="dbname_password"
validationQuery="select 1"
/>
web.xml
<resource-ref>
<description>MySQL Datasource</description>
<res-ref-name>jdbc/dbname_ccp</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I believe I have the correct user name, password, and database name since this same connection information works when I run my Java web application from my development workstation. When Deployed to the hosted web server I get the following error:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at utilities.DBConnection.getConnectionMySQL(DBConnection.java:33)
at model.account.UserAccountDAO.Register(UserAccountDAO.java:286)
at model.account.ProcessUserAccount.register(ProcessUserAccount.java:237)
at controller.AccountServlet.performTask(AccountServlet.java:50)
at controller.AccountServlet.doPost(AccountServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:278)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 24 more
I've tried including the mysql-connector-java-5.1.38-bin.jar file in my project application WEB-INF/lib folder as well as in the tomcat /lib folder. It doesn't seem to matter where I place the jar, the server deployment always fails with the error listed above.
How can I get this problem resolved? Is there any other MySQL connection options?
I have meet this problem before,my solution is to add the mysql-connector-java-5.1.38.bin.jar to tomcat/common/lib instead of in web app libraries and solved it.
As title introduced, the .War file I'm trying to deploy by using Tomcat 7 is not working on a machine running Linux. It does work on Windows and is of course deployed with Tomcat 7.
I've tried to track down the issue alone & searched for related problems on the web including this forum with no success so far. That is why i created this thread asking for help / hints.
The error message I tracked down are the following:
Sep 14, 2015 4:46:05 PM org.apache.catalina.deploy.NamingResources cleanUp
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SmartHomeReasoner]] so no cleanup was performed for that container
javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:986)
at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:968)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5676)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1256)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:692)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
It were 2 problems actually causing this issue.
To solve the issue I had to:
*Check the web.xml VERY carefully after any misstakes like e.g. servlets that do not exist our already defined things e.g. driver being defined twice, meaning it's defined somewhere already AND also in the web.xml.
*Remove servlet in the ..\WEB-INF\lib folder of the project. E.g. javax.servlet-api-3.0.1.jar + javax.servlet-api-3.1.0.jar were removed in this case.
NOTE I even had jars that can conflict with each other on project-level but still I was able to deployed successfully on Windows but not on Linux.
Trust me both of the things I mentioned can be a issue, most likely if you take over work from other devs that have done this miss.
Just had the same issue and synchronizing the Java version for the Maven build (from 1.8 to 1.10) and the running environment (1.10) solved it.
I'm getting the following error deploying my first WAR file in IntelliJ. It is a local issue, supposedly, as this is just a WAR file we deploy to test our setup.
All 80 Maven tests are passing, but when I browse to the web app, I get this error:
java.lang.IllegalArgumentException: javax.naming.NameNotFoundException: Name [jdbc/ipam] is not bound in this Context. Unable to find [jdbc].
com.myapp1.ipam.rest.JaxRsApplication.<init>(JaxRsApplication.java:26)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:526)
org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1104)
org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:902)
org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:872)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:964)
org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:956)
org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:336)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:315)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:310)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
This seems to be where the problem lies:
public JaxRsApplication() {
DataSource datasource;
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
datasource = (DataSource) envCtx.lookup("jdbc/ipam");
} catch (NamingException e) {
throw new IllegalArgumentException(e);
}
this.init(new SystemConfiguration(datasource));
}
This is my first time using IntelliJ, and I am new to Java, so I'm not sure what to do here.
Here is context-fragment.xml
<?xml version='1.0' encoding='utf-8'?>
<Context>
<Resource name="jdbc/ipam"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
auth="Container"
type="javax.sql.DataSource"
initialSize="2"
maxActive="5"
maxIdle="5"
minIdle="1"
maxWait="10000"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"
defaultReadOnly="false"
username="**********"
password="**********"
driverClassName="org.postgresql.Driver"
validationQuery="select 1"
validationQueryTimeout="5"
logValidationErrors="true"
testOnBorrow="true"
testWhileIdle="true"
url="jdbc:postgresql://db1host/ipam_dev_table_here"/>
</Context>
Make sure that you have setup IntelliJ to deploy the context.xml file when it starts tomcat. You can do this by
Select "Project Structure" from the File menu
From there, select the "Facets" option. Make sure that you have a Web facet configured. If not, add one.
Once the web facet is added, select "Add Application Server specific descriptor..."
Select Tomcat Context Descriptor from the options and click OK.
By default IntelliJ will point to META-INF/context.xml. If this is not the location of your context file, you will need to edit the Path to the file.