Tomcat Binary Connector
We would like to run a binary protocol in a Tomcat container, so that binary sent to a specific port all ends up in a specific servlet. This is not AJP, we do not want Tomcat itself to look at the bits, just pass them through. So in Tomcat parlance we need a special Connector. Does such a thing exist or do we need to write it ourselves? Tomcat itself is a fixed requirement for the container architecture. Just having a process listening on a port is not considered to be enterprisy enough. Thanks, Anthony -- Dr Anthony Berglas, anth...@berglas.org Mobile: +61 4 4838 8874 Just because it is possible to push twigs along the ground with ones nose does not necessarily mean that that is the best way to collect firewood.
Re: How to Disable JSP in Embedded Tomcat
On Fri, Sep 21, 2018 at 5:11 PM Igal Sapir wrote: > Mark, > > On Fri, Sep 21, 2018 at 12:54 AM Mark Thomas wrote: > >> On 21/09/18 05:57, Igal Sapir wrote: >> > I want to embed Tomcat in a simple application that does not use JSP, >> and >> > that sets the default servlet's listings initParam to true. >> > >> > When I use the StandardContext, Tomcat.initWebappDefaults() [1] is >> called >> > and adds the default servlet and the JSP servlet. I would like to >> prevent >> > that, but hopefully without having to rewrite the whole Tomcat class >> nor to >> > subclass it. >> > >> > Further, when I try to override a setting in WEB-INF/web.xml, e.g. to >> > specify init-param of "listings" with value "true" for the servlet >> > "default", I get an error that "default" is not unique, but in a regular >> > Tomcat deployment that works just fine. >> > >> > Is there an easy way to override Tomcat.initWebappDefaults() or to >> prevent >> > it from being called? >> >> There are a couple few options. >> >> Sub-classing looks to be the simplest. >> >> You can use addContext() rather than addWebapp() but then you become >> responsible for all of the configuration. If the app is simple, this >> shouldn't be too much effort. >> > > The app is simple, but it is for use by other developers who may use their > own web.xml files, so I think that sub-classing would be much easier and > that's what I did. > > While searching for a solution prior to asking on the mailing list, I > noticed that quite a few users were looking for a simple solution of using > addWebapp() without setting up the default servlets. What do you think > about adding a System Property that will allow to opt-out of > initWebappDefaults() and set the DefaultWebXml to null so that the web.xml > files will be parsed? > > I am thinking of a property name > org.apache.catalina.startup.INIT_WEBAPP_DEFAULTS [default true], or > org.apache.catalina.startup.DISABLE_WEBAPP_DEFAULTS [default false]. > > Alternatively, we can add the sub-classing implementation that I used > (with the proper ASF license headers, of course). The code is pasted below > in case anyone else needs such an implementation. > Actually, the code that I pasted below doesn't seem to play well with JSP so I guess it's not quite ready. When I tried to add a simple JSP file I get an NPE: JspFactory.getDefaultFactory() returns null java.lang.NullPointerException org.apache.jasper.compiler.Validator$ValidateVisitor.(Validator.java:524) org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1856) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:224) org.apache.jasper.compiler.Compiler.compile(Compiler.java:385) org.apache.jasper.compiler.Compiler.compile(Compiler.java:362) org.apache.jasper.compiler.Compiler.compile(Compiler.java:346) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:383) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) > > I can add either solution myself if approved. > > Thank you, > > Igal > > /** > * This class extends Tomcat to override the default functionality which > registers the default and JSP servlets, and > * prevents the parsing of the Web Application Deployment Descriptors > web.xml. > * > * Using this class therefore enables the parsing of the web.xml files, > and does not add any defaults beyond them. > * > * @author Igal Sapir > */ > public class TomcatRunner extends Tomcat { > > /** > * Tomcat.addWebapp() sets DefaultWebXml to a non-null value to > prevent the parsing of the web.xml file(s). > * Here we want to parse those files, so after calling the super > method we set that value to null. > * > * @param host The host in which the context will be deployed > * @param contextPath The context mapping to use, "" for root context. > * @param docBase Base directory for the context, for static files. > * Must exist, relative to the server home > * @param config Custom context configurator helper > * @return the deployed context > * @see #addWebapp(String, String) > */ > public Context addWebapp(Host host, String contextPath, String > docBase, LifecycleListener config) { > > Context ctx = super.addWebapp(host, contextPath, docBase, config); > ((ContextConfig) config).setDefaultWebXml(null); > > return ctx; > } > > /** > * Returns a listener that does nothing, as opposed to the default one > in Tomcat which always > * adds the default servlet and the JSP servlet with the rules that > are set in the defautl web.xml > * @return a listener that does nothing. > */ > @Override > public LifecycleListener getDefaultWebXmlListener() { > // noop >
Re: How to Disable JSP in Embedded Tomcat
Mark, On Fri, Sep 21, 2018 at 12:54 AM Mark Thomas wrote: > On 21/09/18 05:57, Igal Sapir wrote: > > I want to embed Tomcat in a simple application that does not use JSP, and > > that sets the default servlet's listings initParam to true. > > > > When I use the StandardContext, Tomcat.initWebappDefaults() [1] is called > > and adds the default servlet and the JSP servlet. I would like to > prevent > > that, but hopefully without having to rewrite the whole Tomcat class nor > to > > subclass it. > > > > Further, when I try to override a setting in WEB-INF/web.xml, e.g. to > > specify init-param of "listings" with value "true" for the servlet > > "default", I get an error that "default" is not unique, but in a regular > > Tomcat deployment that works just fine. > > > > Is there an easy way to override Tomcat.initWebappDefaults() or to > prevent > > it from being called? > > There are a couple few options. > > Sub-classing looks to be the simplest. > > You can use addContext() rather than addWebapp() but then you become > responsible for all of the configuration. If the app is simple, this > shouldn't be too much effort. > The app is simple, but it is for use by other developers who may use their own web.xml files, so I think that sub-classing would be much easier and that's what I did. While searching for a solution prior to asking on the mailing list, I noticed that quite a few users were looking for a simple solution of using addWebapp() without setting up the default servlets. What do you think about adding a System Property that will allow to opt-out of initWebappDefaults() and set the DefaultWebXml to null so that the web.xml files will be parsed? I am thinking of a property name org.apache.catalina.startup.INIT_WEBAPP_DEFAULTS [default true], or org.apache.catalina.startup.DISABLE_WEBAPP_DEFAULTS [default false]. Alternatively, we can add the sub-classing implementation that I used (with the proper ASF license headers, of course). The code is pasted below in case anyone else needs such an implementation. I can add either solution myself if approved. Thank you, Igal /** * This class extends Tomcat to override the default functionality which registers the default and JSP servlets, and * prevents the parsing of the Web Application Deployment Descriptors web.xml. * * Using this class therefore enables the parsing of the web.xml files, and does not add any defaults beyond them. * * @author Igal Sapir */ public class TomcatRunner extends Tomcat { /** * Tomcat.addWebapp() sets DefaultWebXml to a non-null value to prevent the parsing of the web.xml file(s). * Here we want to parse those files, so after calling the super method we set that value to null. * * @param host The host in which the context will be deployed * @param contextPath The context mapping to use, "" for root context. * @param docBase Base directory for the context, for static files. * Must exist, relative to the server home * @param config Custom context configurator helper * @return the deployed context * @see #addWebapp(String, String) */ public Context addWebapp(Host host, String contextPath, String docBase, LifecycleListener config) { Context ctx = super.addWebapp(host, contextPath, docBase, config); ((ContextConfig) config).setDefaultWebXml(null); return ctx; } /** * Returns a listener that does nothing, as opposed to the default one in Tomcat which always * adds the default servlet and the JSP servlet with the rules that are set in the defautl web.xml * @return a listener that does nothing. */ @Override public LifecycleListener getDefaultWebXmlListener() { // noop return event -> {}; } }
Re: Connection refused: connect
On 9/21/2018 12:45 PM, André Warnier (tomcat) wrote: Hi. Sorry, forget my answer below, I was probably talking nonsense here. The stack trace that you show does not even mention any Tomcat class, so the "connect" mentioned below probably has nothing to do with the HTTP CONNECT method. It looks like something in Eclipse itself, but since I do not know Eclipse (either), I don't have a clue. On 21.09.2018 17:06, André Warnier (tomcat) wrote: On 21.09.2018 10:54, Karen Goh wrote: Hi, I am repeatedly getting the following exceptions and am stuck here like forever. Hope someone can tell me what's wrong with my tomcat server version: 8.5.24 with Eclipse java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.eclipse.jdi.internal.connect.SocketTransportService$2.run(SocketTransportService.java:148) at java.lang.Thread.run(Unknown Source) It looks to me like Eclipse is trying to connect to Tomcat but fails. If the connection is made over the network then a firewall might be playing a role here. If it's all done locally then Tomcat is not listening on the host:port to which Eclipse is trying to connect. Can you connect to that host:port with a browser? e.g. http://localhost:8080/ ? Igal - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Connection refused: connect
Hi. Sorry, forget my answer below, I was probably talking nonsense here. The stack trace that you show does not even mention any Tomcat class, so the "connect" mentioned below probably has nothing to do with the HTTP CONNECT method. It looks like something in Eclipse itself, but since I do not know Eclipse (either), I don't have a clue. On 21.09.2018 17:06, André Warnier (tomcat) wrote: On 21.09.2018 10:54, Karen Goh wrote: Hi, I am repeatedly getting the following exceptions and am stuck here like forever. Hope someone can tell me what's wrong with my tomcat server version: 8.5.24 with Eclipse java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.eclipse.jdi.internal.connect.SocketTransportService$2.run(SocketTransportService.java:148) at java.lang.Thread.run(Unknown Source) Tks. Did you configure an access log for your Tomcat ? If yes, can you look into it for the an access that would happen at the same time as the error you show above ? I am curious, rather than definitive here. But the word "connect" looks suspiciously like the HTTP CONNECT method (see : https://en.wikipedia.org/wiki/HTTP_tunnel), and maybe someone is just trying to use your Tomcat server as a proxy to something. If so, then someone or something is trying to hack your server, and your server is (correctly) rejecting that call. --- On Sat, 9/15/18, Karen Goh wrote: From: Karen Goh Subject: Error: Could not find or load main class set To: users@tomcat.apache.org Date: Saturday, September 15, 2018, 2:50 PM Hi, I am now getting the above error. There is no further error stacktrace from error log or console etc. So far, I have deleted the server and created new instances but still getting the same error. I have read the following solutions but they are not helpful http://www.java67.com/2016/09/3-ways-to-solve-eclipse-main-class-not-found-error-java.html https://www.researchgate.net/post/How_to_solve_Error_Could_not_find_or_load_main_class Please help. Tks, Karen - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: jk_handler::mod_jk.c (2917): Could not get endpoint for worker ...
Am 15.09.2018 um 12:50 schrieb Clemens Wyss DEV: Hi all, we are seeing quite a few: "[Mon Sep 10 15:19:46 2018] [27562:140532026529536] [error] jk_handler::mod_jk.c (2917): Could not get endpoint for worker=testAPJ" errors in our md_jk.log. Worker properties are as follwos: ... worker.list=testAPJ worker.testAPJ.port=8009 worker.testAPJ.host=127.0.0.1 worker.testAPJ.type=ajp13 worker.testAPJ.socket_keepalive=1 worker.testAJP.connection_pool_timeout=600 ... At that point Apache seems to be stuck/struggling (but our tomcat does not seem to be under pressure). Restarting Apache solves the issue ... till it pops up again ... What is happening? What needs tob e tuned? Apache 2.4.34, tried both event- and worker-MPM Assuming this is mod_jk 1.2.44? Are there more setting for worker testAPJ? Normally mod_jk creates as many local connection structures (named endpoints) in each Apache httpd child process, as that process has worker threads. When an httpd worker thread wants to talk to tomcat, it retrieves such an endpoint and uses it to create and handle the commnunication. The error you observe means, that all endpoints were already in use. Since we create as many structures as there are worker threads - everything is per httpd process, this should not happen (and I don't remember any case were it did happen). Ideas what could go wrong: - setting the worker property connection_pool_size or the deprecated cachesize for worker testAPJ to a smaller value than your httpd ThreadsPerChild (32 from your config snippet). If not set, mod_jk automatically detects the number of httpd worker threads - setting connection_acquire_timeout to a small value. By default it is equals to retries*retry_interval which in turn by default is equals to 2*100 milliseconds. mod_jk will retry getting an endpoint before it shows you error message "retries" times with a sleep pause of "retry_interval" milliseconds but no longer than connection_acquire_timeout milliseconds. - retrieving and endpoint must acquire a lock first. On some platforms locking can lead to problems like false positives in deadlock detection. But i think this can't happen here since the code doesn't check the return value of the locking. - memory shortage leading to failing allocations (not likely but possible) Do you see any other log messages? Any ones in the httpd error log or especially the mod_jk log? There should be a WARN message of type "Unable to get the free endpoint for worker %s from %u slots" but maybe more before that final problem happens? What do you see with JkLogLevel info? Does the problem happen under high load or when your backend gets slow? What does "netstat -anp | grep 8009" show when the hang occurs? Regards, Rainer - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: tomcat manager gui hangs on web-app reload for one web-app not others
PS - my Thunderbird has a "Reply List" button for this mailing list. Mitch On 09/20/2018 09:41 AM, Shawn Heisey wrote: On 9/20/2018 8:30 AM, Bill Harrelson wrote: Looking back through my sent folder I realize that I have been replying directly to people that posted directly to me instead of the list. I see from message headers that you're using Thunderbird. In Options/Advanced, open the config editor and change the setting for "mail.override_list_reply_to" to false. You can do this by double-clicking on the setting. That will fix this so that when you reply to an Apache mailing list, your reply will go to the list. Apache lists use the Reply-To header to indicate where replies should go. See this bug for a heated discussion about the problem: https://bugzilla.mozilla.org/show_bug.cgi?id=1392371 Thanks, Shawn - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Connection refused: connect
On 21.09.2018 10:54, Karen Goh wrote: Hi, I am repeatedly getting the following exceptions and am stuck here like forever. Hope someone can tell me what's wrong with my tomcat server version: 8.5.24 with Eclipse java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.eclipse.jdi.internal.connect.SocketTransportService$2.run(SocketTransportService.java:148) at java.lang.Thread.run(Unknown Source) Tks. Did you configure an access log for your Tomcat ? If yes, can you look into it for the an access that would happen at the same time as the error you show above ? I am curious, rather than definitive here. But the word "connect" looks suspiciously like the HTTP CONNECT method (see : https://en.wikipedia.org/wiki/HTTP_tunnel), and maybe someone is just trying to use your Tomcat server as a proxy to something. If so, then someone or something is trying to hack your server, and your server is (correctly) rejecting that call. --- On Sat, 9/15/18, Karen Goh wrote: From: Karen Goh Subject: Error: Could not find or load main class set To: users@tomcat.apache.org Date: Saturday, September 15, 2018, 2:50 PM Hi, I am now getting the above error. There is no further error stacktrace from error log or console etc. So far, I have deleted the server and created new instances but still getting the same error. I have read the following solutions but they are not helpful http://www.java67.com/2016/09/3-ways-to-solve-eclipse-main-class-not-found-error-java.html https://www.researchgate.net/post/How_to_solve_Error_Could_not_find_or_load_main_class Please help. Tks, Karen - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Connection refused: connect
Hi, I am repeatedly getting the following exceptions and am stuck here like forever. Hope someone can tell me what's wrong with my tomcat server version: 8.5.24 with Eclipse java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.eclipse.jdi.internal.connect.SocketTransportService$2.run(SocketTransportService.java:148) at java.lang.Thread.run(Unknown Source) Tks. --- On Sat, 9/15/18, Karen Goh wrote: > From: Karen Goh > Subject: Error: Could not find or load main class set > To: users@tomcat.apache.org > Date: Saturday, September 15, 2018, 2:50 PM > Hi, > > I am now getting the above error. > There is no further error stacktrace from error log or > console etc. > > So far, I have deleted the server and > created new instances but still getting the same error. > > I have read the following solutions but > they are not helpful > > http://www.java67.com/2016/09/3-ways-to-solve-eclipse-main-class-not-found-error-java.html > > https://www.researchgate.net/post/How_to_solve_Error_Could_not_find_or_load_main_class > > Please help. > > Tks, > Karen > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: How to Disable JSP in Embedded Tomcat
On 21/09/18 05:57, Igal Sapir wrote: > I want to embed Tomcat in a simple application that does not use JSP, and > that sets the default servlet's listings initParam to true. > > When I use the StandardContext, Tomcat.initWebappDefaults() [1] is called > and adds the default servlet and the JSP servlet. I would like to prevent > that, but hopefully without having to rewrite the whole Tomcat class nor to > subclass it. > > Further, when I try to override a setting in WEB-INF/web.xml, e.g. to > specify init-param of "listings" with value "true" for the servlet > "default", I get an error that "default" is not unique, but in a regular > Tomcat deployment that works just fine. > > Is there an easy way to override Tomcat.initWebappDefaults() or to prevent > it from being called? There are a couple few options. Sub-classing looks to be the simplest. You can use addContext() rather than addWebapp() but then you become responsible for all of the configuration. If the app is simple, this shouldn't be too much effort. Mark > > Thanks, > > Igal > > [1] > https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/startup/Tomcat.java#L918 > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org