Re: Weirdest Tomcat Behavior Ever?

2020-11-13 Thread Paul Carter-Brown
lol, and there I was feeling ignored :-)

That was the first thing I would have looked at. Is the OS reporting errors
to the JVM writing data or is the JVM not writing the data. Strace will
tell you this quite easily.


On Fri, Nov 13, 2020 at 5:27 PM Eric Robinson 
wrote:

>
> > -Original Message-
> > From: Paul Carter-Brown 
> > Sent: Friday, October 16, 2020 6:11 AM
> > To: Tomcat Users List 
> > Subject: Re: Weirdest Tomcat Behavior Ever?
> >
> > Hi Eric,
> >
> > These weird situations are sometimes best looked at by confirming what
> the
> > OS is seeing from user-space.
> >
> > Can you run: sudo strace -r -f -e trace=network -p 
> >
> > You can then log that to a file and correlate and see if the kernel is
> in fact
> > being asked to send the response.
> >
> > It's very insightful to  see what is actually going on between the JVM
> and
> > Kernel.
> >
> > Paul
>
> Paul, this message went to spam and I just found it!
>
> I will try this suggestion immediately.
>
> -Eric
>
> >
> > On Fri, Oct 16, 2020 at 12:16 PM Mark Thomas  wrote:
> >
> > > On 16/10/2020 10:05, Eric Robinson wrote:
> > > > Hi Mark --
> > > >
> > > > Those are great questions. See answers below.
> > > >
> > > >
> > > >> -Original Message-
> > > >> From: Mark Thomas 
> > > >> Sent: Friday, October 16, 2020 2:20 AM
> > > >> To: users@tomcat.apache.org
> > > >> Subject: Re: Weirdest Tomcat Behavior Ever?
> > > >>
> > > >> On 16/10/2020 00:27, Eric Robinson wrote:
> > > >>
> > > >> 
> > > >>
> > > >>> The localhost_access log shows a request received and an HTTP 200
> > > >> response sent, as follows...
> > > >>>
> > > >>> 10.51.14.133 [15/Oct/2020:12:52:45 -0400] 57 GET
> > > >>> /app/code.jsp?gizmoid=64438=5=2020-10-
> > > >> 15
> > > >>>
> > > >>
> > lterId=0=0=71340=321072
> > > >> oc
> > > >> e
> > > >>> ssid=40696=0.0715816=15102020125245.789063
> > HTTP/1.0
> > > >>> ?gizmoid=64438=5=2020-10-
> > > >> 15=0
> > > >>>
> > > >>
> > ionDID=0=71340=321072=40696
> > > >> &
> > > >> rn
> > > >>> d2=0.0715816=15102020125245.789063 200
> > > >>>
> > > >>> But WireShark shows what really happened. The server received the
> > > >>> GET
> > > >> request, and then it sent a FIN to terminate the connection. So if
> > > tomcat sent
> > > >> an HTTP response, it did not make it out the Ethernet card.
> > > >>>
> > > >>> Is this the weirdest thing or what? Ideas would sure be
> appreciated!
> > > >>
> > > >> I am assuming there is a typo in your Java version and you are
> > > >> using
> > > Java 8.
> > > >>
> > > >
> > > > Yes, Java 8.
> > > >
> > > >> That Tomcat version is over 3.5 years old (and Tomcat 7 is EOL in
> > > >> less
> > > than 6
> > > >> months). If you aren't already planning to upgrade (I'd suggest to
> > > 9.0.x) then
> > > >> you might want to start thinking about it.
> > > >>
> > > >
> > > > Vendor constraint. It's a canned application published by a national
> > > software company, and they have not officially approved tomcat 8 for
> > > use on Linux yet.
> > > >
> > > >> I have a few ideas about what might be going on but rather than
> > > >> fire out random theories I have some questions that might help
> > > >> narrow things
> > > down.
> > > >>
> > > >> 1. If this request was successful, how big is the response?
> > > >>
> > > >
> > > > 1035 bytes.
> > > >
> > > >> 2. If this request was successful, how long would it typically take
> > > >> to complete?
> > > >>
> > > >
> > > > Under 60 ms.
> > > >
> > > >> 3. Looking at the Wireshark trace for a failed request, how long
> > > >> after
> > > the last
> > > >> byte of the request is sent by the client does

Re: Weirdest Tomcat Behavior Ever?

2020-10-16 Thread Paul Carter-Brown
Hi Eric,

These weird situations are sometimes best looked at by confirming what the
OS is seeing from user-space.

Can you run: sudo strace -r -f -e trace=network -p 

You can then log that to a file and correlate and see if the kernel is in
fact being asked to send the response.

It's very insightful to  see what is actually going on between the JVM and
Kernel.

Paul

On Fri, Oct 16, 2020 at 12:16 PM Mark Thomas  wrote:

> On 16/10/2020 10:05, Eric Robinson wrote:
> > Hi Mark --
> >
> > Those are great questions. See answers below.
> >
> >
> >> -Original Message-
> >> From: Mark Thomas 
> >> Sent: Friday, October 16, 2020 2:20 AM
> >> To: users@tomcat.apache.org
> >> Subject: Re: Weirdest Tomcat Behavior Ever?
> >>
> >> On 16/10/2020 00:27, Eric Robinson wrote:
> >>
> >> 
> >>
> >>> The localhost_access log shows a request received and an HTTP 200
> >> response sent, as follows...
> >>>
> >>> 10.51.14.133 [15/Oct/2020:12:52:45 -0400] 57 GET
> >>> /app/code.jsp?gizmoid=64438=5=2020-10-
> >> 15
> >>>
> >> lterId=0=0=71340=321072
> >> e
> >>> ssid=40696=0.0715816=15102020125245.789063 HTTP/1.0
> >>> ?gizmoid=64438=5=2020-10-
> >> 15=0
> >>>
> >> ionDID=0=71340=321072=40696&
> >> rn
> >>> d2=0.0715816=15102020125245.789063 200
> >>>
> >>> But WireShark shows what really happened. The server received the GET
> >> request, and then it sent a FIN to terminate the connection. So if
> tomcat sent
> >> an HTTP response, it did not make it out the Ethernet card.
> >>>
> >>> Is this the weirdest thing or what? Ideas would sure be appreciated!
> >>
> >> I am assuming there is a typo in your Java version and you are using
> Java 8.
> >>
> >
> > Yes, Java 8.
> >
> >> That Tomcat version is over 3.5 years old (and Tomcat 7 is EOL in less
> than 6
> >> months). If you aren't already planning to upgrade (I'd suggest to
> 9.0.x) then
> >> you might want to start thinking about it.
> >>
> >
> > Vendor constraint. It's a canned application published by a national
> software company, and they have not officially approved tomcat 8 for use on
> Linux yet.
> >
> >> I have a few ideas about what might be going on but rather than fire out
> >> random theories I have some questions that might help narrow things
> down.
> >>
> >> 1. If this request was successful, how big is the response?
> >>
> >
> > 1035 bytes.
> >
> >> 2. If this request was successful, how long would it typically take to
> >> complete?
> >>
> >
> > Under 60 ms.
> >
> >> 3. Looking at the Wireshark trace for a failed request, how long after
> the last
> >> byte of the request is sent by the client does Tomcat send the FIN?
> >>
> >
> > Maybe 100 microseconds.
> >
> >> 4. Looking at the Wireshark trace for a failed request, is the request
> fully sent
> >> (including terminating CRLF etc)?
> >>
> >
> > Yes, the request as seen by the tomcat server is complete and is
> terminated by 0D 0A.
> >
> >> 5. Are there any proxies, firewalls etc between the user agent and
> Tomcat?
> >>
> >
> > User agent -> firewall -> nginx plus -> upstream tomcat servers
> >
> >> 6. What timeouts are configured for the Connector?
> >>
> >
> > Sorry, which connector are you referring to?
> >
> >> 7. Is this HTTP/1.1, HTTP/2, AJP, with or without TLS?
> >>
> >
> > HTTP/1.1
> >
> >> 8. Where are you running Wireshark? User agent? Tomcat? Somewhere
> >> else?
> >
> > On the nginx proxy and both upstream tomcat servers. (On the user agent,
> too, but that doesn't help us in this case.)
> >
> > If you would like to see a screen shot showing all 4 captures
> side-by-size, I can send you a secure link. It will verify my answers
> above. It shows 4 separate WireShark captures taken simultaneously:
> >
> > (a) the request going from the nginx proxy to tomcat 1
> > (b) tomcat 1 receiving the request and terminating the connection
> > (c) nginx sending the request to tomcat 2
> > (d) tomcat 2 replying to the request (but the reply does not help the
> user because the tomcat server does not recognize the user agent's
> JSESSIONID cookie, so it responds "invalid session."
>
> Hmm.
>
> That rules out most of my ideas.
>
> I'd like to see those screen shots please. Better still would be access
> to the captures themselves (just the relevant connections not the whole
> thing). I believe what you are telling us but long experience tells me
> it is best to double check the original data as well.
>
> I have observed something similar ish in the CI systems. In that case it
> is the requests that disappear. Client side logging shows the request
> was made but there is no sign of it ever being received by Tomcat. I
> don't have network traces for that (yet) so I'm not sure where the data
> is going missing.
>
> I am beginning to suspect there is a hard to trigger Tomcat or JVM bug
> here. I think a Tomcat bug is more likely although I have been over the
> code several times and I don't see anything.
>
> A few more questions:
>
> Which HTTP connector are you using? BIO, NIO or APR/Native?
>
> Is the 

Re: Request for a tip with NoClassDefFoundError

2020-09-23 Thread Paul Carter-Brown
NoClassDefFoundError means that the class in question threw an exception
during its static initialisation phase. Then later on whenever some code
tries to access the class statically or create an instance the JVM will
throw a NoClassDefFoundError. This is not the same as a class not found
which relates to classloading issues.

To debug a NoClassDefFoundError, look at the logs when the class was first
used and see if it threw an error initialising. Also look at the source of
the class and see if any static blocks or static variables could fail e.g.:

public class MyClass {
private static String someString = doSomething();

private static String doSomething() {
  // access some server . If network is down an exception would be thrown
  throw new RuntimeException();
}
}

The above code would cause a NoClassDefFoundError whenever someone tries to
use MyClass.

Paul


On Wed, Sep 23, 2020 at 10:00 AM Michal Rysavy  wrote:

> Hello,
>
> I would like to ask for any tips that can help us to solve the problem with
> NoClassDefFoundError.
>
> We have a specific problem with an application (Documentum) on Tomcat
> (running as a container on OpenShift). Sometimes we have many
> NoClassDefFoundError on classes that are loaded via network from the
> backend application.
> The biggest problem is that an error is unpredictable, it occurs only when
> starting an application under high load and not always. Sometimes there are
> few occurrences and sometimes there are thousands occurrences and sometimes
> nothing (during the same load).
> But we can't repeat the problem in a non-production environment, even with
> the same or higher load of performance tests. More precisely, we had this
> error on non-prod several times, but with negligible occurrence, randomly
> and with different application configuration only that is not suitable for
> production.
>
> Class reported with NoClassDefFoundError is not always the same, but always
> this class can be found in the appropriate jar file in the application
> cache of received jars. When we had classloader verbose enabled, I think
> that we saw that the class was loaded (but we must recheck this). More
> precisely, at the same time the problematic class (stated as
> NoClassDefFoundError) is the same, but after the next restart under high
> load there is another problematic class.
>
> We are running Tomcat 9.0.29 on OpenJDK Runtime Environment (build
> 1.8.0_222-b10) - with almost the default configuration.
> We are planning a Tomcat & Java update but now we can't test it before
> production, because we can't reproduce this error on the non-prod.
>
> So I would like to ask if there are some tuning tips that we can try for a)
> prevention of occurrence in production and b) ensuring occurence in
> non-production
>
> Many thanks for any tips.
>
> Kind Regards,
> Michal Rysavy
>
> Some examples of occurence (other occurrences have another classes as
> NoClassDefFoundError / ClassNotFoundException):
>
> EXAMPLE 1/4
> ===
> com.emc.documentum.fs.rt.ServiceException:
> com/fasterxml/jackson/databind/deser/std/FactoryBasedEnumDeserializer.
> com.fasterxml.jackson.databind.deser.std.FactoryBasedEnumDeserializer
> at
> com.ness.documentum.csas.ws
> .v01.recordservice.CsRecordServiceWebService.esSearchRecord(CsRecordServiceWebService.java:662)
> 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:498)
> at
>
> com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)
> at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
> at
>
> com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
> at
>
> com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
> at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598)
> at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557)
> at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542)
> at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439)
> at
> com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
> at
>
> com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:471)
> at
> com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
> at
>
> com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
> at
>
> com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)
> at
>
> com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)
> at
> com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)
> at 

Re: Tomcat Handling close_waits

2020-08-16 Thread Paul Carter-Brown
Hi Norbert,

The TCP socket states and timers are managed by the underlying OS and not
by Tomcat. Can you paste a netstat -an result so I can see what you mean.
Also, is the client using HTTP 1.1 with keep-alive or not? What kind of
traffic is this?

Paul


On Sun, Aug 16, 2020 at 7:16 PM Norbert Elbanbuena 
wrote:

> I also noticed that while server receives the connection requests, we are
> seeing multiple requests from the same sources. Some same source requests
> (FIN-WAIT) are all in state while other same sources requests are in other
> state (some in FIN-WAIT or close_wait and some Established).
>
> Why are we seeing multiple requests from the same source at the same time?
> Doesn't each socket request exhaust a thread on the application?
>
>
> Warm regards,
>
> Norbert Elbanbuena
>
> -Original Message-
> From: Norbert Elbanbuena 
> Sent: Sunday, August 16, 2020 11:35 AM
> To: Tomcat Users List 
> Subject: Tomcat Handling close_waits
>
> Hi,
>
> We are experiencing a flood of close_waits in our server. Interestingly,
> all of the sessions stuck in close_waits are sourced from Amazon IP
> addresses. Our second server running the same setup (hardware spec, OS
> version, Tomcat version, etc.) and had almost the same session count and
> our application and Tomcat didn't go unresponsive.
>
> Is there any tuneable parameter for the APR connector for Tomcat to close
> the stuck sessions, rather than waiting for the application?
>
> Warm regards,
>
> Norbert Elbanbuena
>
>
> -
> 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: Wrong timezone in Date and Last-Modified-Headers

2020-06-10 Thread Paul Carter-Brown
At runtime, any code can call TimeZone.setDefault to change the timezone of
the JVM.

I'd suggest logging  TimeZone.getDefault().getDisplayName(Locale.ENGLISH);
intermittently and seeing if some code somewhere is changing the timezone.
Could be in any library...

Paul


On Wed, Jun 10, 2020 at 2:56 PM Stefan Mayr  wrote:

> Hi,
>
> today I've seen something I don't understand: our developers reported an
> application that was returning a non-GMT timezone in Date and
> Last-Modified headers.
>
> $ curl -v http://localhost:8080
> * Rebuilt URL to: http://localhost:8080/
> *   Trying 127.0.0.1...
> * TCP_NODELAY set
> * Connected to localhost (127.0.0.1) port 8080 (#0)
> > GET / HTTP/1.1
> > Host: localhost:8080
> > User-Agent: curl/7.58.0
> > Accept: */*
> >
> < HTTP/1.1 200
> < X-Correlation-Id: 68ef1063-dbbb-4216-a3a7-2acdb768abbd
> < Last-Modified: Tue, 12 May 2020 14:04:15 YEKT
> < Accept-Ranges: bytes
> < X-Content-Type-Options: nosniff
> < X-XSS-Protection: 1; mode=block
> < Cache-Control: no-cache, no-store, max-age=0, must-revalidate
> < Pragma: no-cache
> < Expires: 0
> < Strict-Transport-Security: max-age=31536000
> < X-Frame-Options: DENY
> < Content-Type: text/html;charset=UTF-8
> < Content-Language: en-US
> < Content-Length: 5409
> < Date: Wed, 10 Jun 2020 20:42:26 JST
> ...
>
> There you can see Date with JST and Last-Modified with YEKT instead of GMT
>
> All other locales (LANG, LC_*, /etc/localtime) of this system are okay
> and after a restart everything is correct again and I'm not able to
> reproduce it
>
> $ curl -vs http://localhost:8080 2>&1|egrep -i "Date|Last-Modified"
> *  start date: Mar 25 10:50:00 2020 GMT
> *  expire date: Mar 30 23:59:59 2021 GMT
> < cache-control: no-cache, no-store, max-age=0, must-revalidate
> < date: Wed, 10 Jun 2020 11:52:42 GMT
> < last-modified: Tue, 12 May 2020 09:04:15 GMT
>
>
> This is a Spring Boot application with an embedded Tomcat (9.0.16)
> running in a Cloud Foundry Container.
>
> Reading through the source code of
> org.apache.tomcat.util.http.FastHttpDateFormat I don't understand how
> this is even possible.
>
> Has anybody ever seen this or an idea what could have happened there?
> After the restart I can't reproduce it.
>
> Thanks,
>
>Stefan
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: Tomcat 9.0.0 multiple thread issue

2020-06-09 Thread Paul Carter-Brown
I assume a servlet request is kicking off this process? If this is correct
then are you 100% sure that something is not calling the servlet more than
once? Perhaps a retry after a timeout or something?

Turn your access log on and look at what requests are coming in to the
server

Paul


On Tue, Jun 9, 2020 at 2:04 PM Ripu Daman  wrote:

> Hello everyone,
>
> I work in an IT firm as a software engineer. I don't know whether it's a
> right platform to ask questions based on personal projects but i believe i
> will get some help from here.
>
> We are facing an issue regarding multiple threads being created for a
> servlet execution running in tomcat 9.0.0
>
> Servlet's job is to publish customer leads to salesforce via soap protocol.
> The logic has been designed in such a way that in a single thread it can
> publish multiple leads to salesforce one by one. However we recently
> migrated our java application to kubernetes adopting containerized
> approach.
> Post this we are facing an issue in which, when the process starts
> publishing leads to salesforce one by one, after a few uploads a new thread
> gets created and it starts the whole process from beginning and then after
> a few seconds another thread kicks off repeating the whole process. It
> keeps going on until session timeout exceeds and we get a 504 error. But
> the upload process keeps going on in the background and stops after 2-3
> threads.
>
> Before moving to kubernetes, the process was working fine. In order to
> serve multiple requests at the same time, servlet is not designed to be
> thread safe.
>
> But now we are facing this issue and unable to identify the root cause.
>
> Here's a sample of threads from the logs :
>  [http-nio-8080-exec-9] INFO
>  [http-nio-8080-exec-9] INFO
>  [http-nio-8080-exec-9] INFO
>  [http-nio-8080-exec-7] INFO
>  [http-nio-8080-exec-7] INFO
>  [http-nio-8080-exec-9] INFO
>  [http-nio-8080-exec-9] INFO
>
>  [http-nio-8080-exec-7] INFO
>  [http-nio-8080-exec-7] INFO
>  [http-nio-8080-exec-7] INFO
>  [http-nio-8080-exec-3] INFO
>  [http-nio-8080-exec-7] INFO
>  [http-nio-8080-exec-3] INFO
>
> The configurations for tomcat remains same as default. Session timeout is
> set as 30 min (default).
>
> For more info please let me know.
>
> Hope will get some help from here.
>
> Thanks!
>
> regards,
> Ripu daman
>


Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

2019-10-09 Thread Paul Carter-Brown
Hi Anthony

Have you turned debug logging on to see what it is picking up as modified?

On Wed, 09 Oct 2019, 22:24 Rhuberg,Anthony,
 wrote:

> Thanks for your responses.
>
> I understand that re-reading the static files is not optimal, but how does
> reading files from the jar affect them being reloaded... In Tomcat 7, that
> seemed to prevent the jars from being reloaded since the accessTime was
> changed; in Tomcat 8, it seems the modified() method uses the file modified
> time - not sure what we are doing to cause the modified time to change -
> the files on the filesystem are not changing - unless there is something
> happening in the classes folder.
>
> Thanks
>
> -Original Message-
> From: Mark Thomas 
> Sent: Wednesday, October 09, 2019 3:56 PM
> To: users@tomcat.apache.org
> Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk usage
> because of repeated opening/closing of jars in WEB-INF/lib
>
> On 09/10/2019 20:08, Rhuberg,Anthony wrote:
> > On the other thread: Is this genuine class loading (in which case the
> > response below is correct) or is the application reading the .class
> files as if they were resources (in which case a different answer applies)?
> > Mostly, we are talking about the default class loader; however, the
> application does read resources from the jar files - mostly static files
> that are stored within the package structure are read (for example: log4j,
> property files, other static content). Would this affect the reload of the
> jar files?
>
> If an application was reading the same resource from a JAR over and over
> again, that may have a performance impact. Increasing the TTL for cached
> resources would probably address that although, arguably, the better
> solution in that case would be to fix the app to load it once and cache it.
>
> > -Original Message-
> > From: Rhuberg,Anthony
> > Sent: Wednesday, October 09, 2019 2:53 PM
> > To: Tomcat Users List 
> > Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk
> > usage because of repeated opening/closing of jars in WEB-INF/lib
> >
> > Just noticed another thread on this topic: RE: Tomcat discards and
> reloads the jar files from the webapps folder.
> >
> > Setting the Engine attribute backgroundProcessorDelay to 90s does reduce
> the open/close cycle of the jars.
>
> Thanks for the confirmation.
>
> > The other thread also mentioned a potential configuration to keep the
> jars open longer by default. This could be helpful - not sure we need to
> close them at all.
>
> If the JARs aren't closed it can cause file locking issues. We could
> include a disable option if we did make the Jar unload frequency
> configurable.
>
> > Alternatively, would there be any gain to 'explode' the jars into class
> files on the filesystem?
>
> Maybe. Best bet it to try it for your app and see.
>
> Mark
>
>
> > -Original Message-
> > From: Rhuberg,Anthony 
> > Sent: Wednesday, October 09, 2019 2:17 PM
> > To: users@tomcat.apache.org
> > Subject: Performance test with Tomcat 9 shows increased cpu/disk usage
> > because of repeated opening/closing of jars in WEB-INF/lib
> >
> > Background:
> > In the last few months we migrated our web application from Tomcat
> 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively
> straightforward until we reviewed the results of our performance tests.
> Those tests showed an increase in CPU usage and disk I/O on our Windows
> 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk
> usage were significantly lower (similar to previous tests).
> >
> > As we investigated the cause of the increase in cpu/disk usage we found
> the tomcat process was repeatedly opening and closing the jars of our web
> application. The process profile showed all the jars in WEB-INF/lib being
> closed and reopened within seconds while the application was processing
> requests (and to some extent when quite). Now we are trying to determine
> why.
> >
> > We have a general understanding that the WebappClassLoaderBase.java
> implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided
> for the configuration of  jarOpenInterval (which we used the default =
> 90s). The latest implementation appears to track the jar modification times
> with a hash map called jarModificationTimes, but we are unable to find a
> similar time-to-live configuration or what triggers the lifecycle listener
> to close the jars (what calls WebappClassLoaderBase.modified() or
> destroy()) - assuming we understand this lifecycle behavior.
> >
> > The server is configured mostly with default settings. The Context
> reloadable property is NOT set. We have tried increasing the cache time of
> the Resources cacheTtl property as the default of 5s seemed close to the
> time the jars were reloaded. We have not been successful.
> >
> > Question:
> > What is the cause of the repeated reloading of our web application jars?
> What can trigger the class loader to close all the 

Re: Add jar to catalina base / tomcat instance classpath (Tomcat 9)

2019-09-04 Thread Paul Carter-Brown
Can you not just put the jar in the /lib folder of tomcat


On Wed, Sep 4, 2019 at 5:17 PM Stephane Passignat 
wrote:

> I may misread the catalina.sh (else instead of elif).
>
> I try to add a setenv.sh in the catalina_home.
>
> -Original Message-
> From: Stephane Passignat  stephane%20passignat%20%3cpassig...@hotmail.com%3e>>
> Reply-To: Tomcat Users List  tomcat%20users%20list%20%3cus...@tomcat.apache.org%3e>>
> To: Tomcat Users List  tomcat%20users%20list%20%3cus...@tomcat.apache.org%3e>>
> Subject: Add jar to catalina base / tomcat instance classpath (Tomcat 9)
> Date: Wed, 4 Sep 2019 14:54:53 +
>
>
> Hi,
>
>
> I would like to add a jar to tomcat system classloader (applicable to
> tomcat instance and its applications but not to all tomcat instances).
>
>
> I read the catalina.sh files but I can't find a solution. Are there any ?
>
>
> thanks
>
> stephane
>
>
>


Re: Tomcat Server Using 100% CPU

2019-08-08 Thread Paul Carter-Brown
Please post a jstack of the pid 10 seconds apart. That will reveal all.

On Thu, 08 Aug 2019, 20:22 Coty Sutherland,  wrote:

> I'd suggest writing a small script to loop about 10 times and capture top
> and thread dumps with jstack at the same time, then wait a few seconds then
> repeat. After that you can grab the pid/tid from the top output and compare
> that with your thread dump to see exactly what the thread is doing for the
> iteration/duration you specify.
>
> Other questions that I haven't seen asked, how long does the CPU usage
> persist? Is it only at startup or does it randomly start after some uptime?
> Have your webapps or dependencies changed around the time the issue
> started? Do the working and nonworking servers run the same webapps with
> the same workload?
>
> On Thu, Aug 8, 2019 at 2:09 PM Eric Robinson 
> wrote:
>
> > Utkarsh and John, thank you for your feedback.
> >
> > Since everything was originally on Windows, and we built a new Linux
> > server with fresh tomcat installs, and the only thing we moved over from
> > the old Windows servers was the tomcat application folder itself, and the
> > 100% CPU problem persisted, I can't imagine what else could be causing it
> > except the tomcats, but I'm open to ideas.
> >
> > When it happens, all the tomcats start using high CPU at the same time.
> > See the following top output.
> >
> > top - 11:06:44 up 1 day,  6:59,  7 users,  load average: 36.85, 32.67,
> > 34.89
> > Tasks: 245 total,   4 running, 241 sleeping,   0 stopped,   0 zombie
> > %Cpu(s): 80.7 us, 13.5 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  5.7 si,
> > 0.0 st
> > KiB Mem : 48132572 total, 11677420 free,  5572688 used, 30882464
> buff/cache
> > KiB Swap: 15626236 total, 15584324 free,41912 used. 41859232 avail
> Mem
> >
> >   PID USER  PR  NIVIRTRESSHR S  %CPU %MEM TIME+
> COMMAND
> > 19379 site211   20   0 3529072 447444  24632 S 120.4  0.9   3:37.19 java
> > 20092 site555   20   0 2530376 375500  24496 S  72.4  0.8   2:01.44 java
> > 21077 site450   20   0 2530292 298260  24292 S  69.6  0.6   1:10.92 java
> > 20378 site436   20   0 3262200 347160  24096 S  68.3  0.7   2:47.26 java
> > 19957 site522   20   0 2596856 373532  24364 S  52.0  0.8   2:37.13 java
> > 19537 site396   20   0 2862724 386860  23820 S  51.1  0.8   2:34.25 java
> > 19228 site116   20   0 3595652 490032  24640 S  50.5  1.0   5:03.28 java
> > 20941 site456   20   0 2596996 338740  24488 S  49.2  0.7   1:32.89 java
> > 20789 site354   20   0 2596920 327612  24480 S  42.9  0.7   1:30.47 java
> > 20657 site327   20   0 3123004 346308  24540 S  41.4  0.7   1:50.97 java
> > 20524 site203   20   0 2458376 340400  25416 S  39.8  0.7   1:48.01 java
> > 19675 site487   20   0 2530296 390948  24408 S  35.7  0.8   2:37.95 java
> > 20233 site535   20   0 2530292 324112  24360 S  32.9  0.7   1:54.31 java
> > 19809 site514   20   0 2530216 400308  24340 S  25.7  0.8   2:35.97 java
> >44 root  20   0   0  0  0 R  19.1  0.0 159:46.15
> > ksoftirqd/7
> >  3926 root  20   0  208512  22668   4128 S  16.9  0.0 242:45.07 iotop
> >  2036 root  20   0   0  0  0 R  13.2  0.0   1:38.31
> > kworker/7:0
> >
> > I'll check the localhost_access logs and see if something suspicious
> > stands out.
> >
> > --Eric
> >
> >
> > -Original Message-
> > From: Utkarsh Dave 
> > Sent: Thursday, August 8, 2019 12:33 PM
> > To: Tomcat Users List 
> > Subject: Re: Tomcat Server Using 100% CPU
> >
> > Did you reviewed the localhost_access log file. Which web-application is
> > using tomcat the most ?
> >
> > On Thu, Aug 8, 2019 at 9:53 AM Eric Robinson 
> > wrote:
> >
> > > We have a farm of VMs, each running multiple instances of tomcat (up
> > > to 80 instances per server). Everything has been running fine for
> > > years, but recently one server has started nailing the CPU to 100%
> > utilization.
> > >
> > > We have tried:
> > >
> > >
> > >   *   Different versions of tomcat and JDK
> > >   *   Doubling the resources to 16 cores and 56 GB RAM
> > >   *   Moving the VM to different physical server
> > >   *   Rebuilding the tomcat instances on a brand new VM using Windows
> > > Server 2019
> > >   *   Rebuilding the tomcat instances on a brand new VM using Red Hat
> > > Enterprise Linux 7.5
> > >
> > > Nothing has worked. No matter where we run the tomcats, they drive CPU
> > > up to 100%. Meanwhile the other six servers are still running fine.
> > > They all run the same canned tomcat applications.
> > >
> > > We would appreciate some guidance on getting to the bottom of this
> > problem.
> > >
> > > --Eric
> > >
> > >
> > > Disclaimer : This email and any files transmitted with it are
> > > confidential and intended solely for intended recipients. If you are
> > > not the named addressee you should not disseminate, distribute, copy or
> > alter this email.
> > > Any views or opinions presented in this email are solely those of the
> > > author and might not represent 

Re: java.lang.NoClassDefFoundError: Could not initialize class net.sf.ehcache.Element

2019-07-10 Thread Paul Carter-Brown
NoClassDefFoundError is not the same as ClassNotFoundException

Typically a NoClassDefFoundError is due to a class failing its static
initialisation when first loaded by the classloader. Can you check in your
logs for any prior errors (even at bootup) relating to class failing to be
loaded

Paul



On Wed, Jul 10, 2019 at 6:42 PM Hua, Gary - Saint Louis, MO - Contractor
 wrote:

> Tomcat Experts:
>
> I have a web application deployed to our DEV Tomcat server
> 9.0.13.   I try to put all the hibernate jars files to version
> Hibernate-3.6.10.  The following is the jar files under WEB-INF/lib:
>
>
> /opt/TomCat/tomcat/webapps/TOPS-WEB/WEB-INF/lib>ls -l
> total 56844
> -rw-r--r-- 1 atadmin atadmin   443432 Feb  8  2012
> antlr-2.7.6.jar
> -rw-r--r-- 1 atadmin atadmin16777 Jun 18 15:58
> asm-attrs.jar
> -rw-r--r-- 1 atadmin atadmin26360 Jun 18 15:58  asm.jar
> -rw-r--r-- 1 atadmin atadmin   281998 Jun 18 15:58
>  cglib-2.1.jar
> -rw-r--r-- 1 atadmin atadmin  4604132 Jun 18 15:58
> com.ibm.ws.webcontainer.jar
> -rw-r--r-- 1 atadmin atadmin   188671 Jun 18 15:58
> commons-beanutils.jar
> -rw-r--r-- 1 atadmin atadmin   559366 Feb  8  2012
> commons-collections-3.1.jar
> -rw-r--r-- 1 atadmin atadmin   165119 Jun 18 16:00
> commons-collections.jar.old
> -rw-r--r-- 1 atadmin atadmin   205318 Mar 19 11:12
> commons-dbcp2-2.6.0.jar
> -rw-r--r-- 1 atadmin atadmin   168446 Jun 18 15:58
> commons-digester.jar
> -rw-r--r-- 1 atadmin atadmin70604 Jun 18 15:58
> commons-fileupload-1.3.3.jar
> -rw-r--r-- 1 atadmin atadmin   214788 Jun 18 15:58
> commons-io-2.6.jar
> -rw-r--r-- 1 atadmin atadmin   207723 Jun 18 15:58
> commons-lang-2.1.jar
> -rw-r--r-- 1 atadmin atadmin   315805 Jun 18 15:58
> commons-lang3-3.1.jar
> -rw-r--r-- 1 atadmin atadmin26388 Jun 18 15:58
> commons-logging.jar
> -rw-r--r-- 1 atadmin atadmin84462 Jun 18 15:58
> commons-validator.jar
> -rw-r--r-- 1 atadmin atadmin  4239628 Jun 18 15:58  db2jcc4.jar
> -rw-r--r-- 1 atadmin atadmin 2068 Jun 18 15:58
> db2jcc_license_cu.jar
> -rw-r--r-- 1 atadmin atadmin  2125577 Jun 18 15:58
> db2jcc_V9FP6.jar
> -rw-r--r-- 1 atadmin atadmin   210432 Jun 18 15:58
> displaytag-1.1.jar
> -rw-r--r-- 1 atadmin atadmin12590 Jun 18 15:58
> displaytag-export-poi-1.1.jar
> -rw-r--r-- 1 atadmin atadmin   312509 Jun 18 16:00
> dom4j-1.5.2.jar.old
> -rw-r--r-- 1 atadmin atadmin   313898 Feb  8  2012
> dom4j-1.6.1.jar
> -rw-r--r-- 1 atadmin atadmin 10237841 Jul  9 12:29
> ehcache-2.10.6.jar
> -rw-r--r-- 1 atadmin atadmin   989884 Jul  9 16:57
> ehcache-core-2.4.2.jar
> -rw-r--r-- 1 atadmin atadmin  4162825 Jul  3 10:43
> hibernate3.jar
> -rw-r--r-- 1 atadmin atadmin  3123360 Jul  9 12:44
> hibernate-core-3.6.10.Final.jar
> -rw-r--r-- 1 atadmin atadmin56287 Jul  9 12:29
> hibernate-ehcache-5.4.3.Final.jar
> -rw-r--r-- 1 atadmin atadmin65425 Jun 18 15:58
>  jakarta-oro.jar
> -rw-r--r-- 1 atadmin atadmin  1979523 Dec 17  2018
> javaee-api-8.0.jar
> -rw-r--r-- 1 atadmin atadmin   633312 Feb  8  2012
>  javassist-3.12.0.GA.jar
> -rw-r--r-- 1 atadmin atadmin   153115 Jun 18 15:58  jdom.jar
> -rw-r--r-- 1 atadmin atadmin64597 Jun 18 15:58
> json-20180813.jar
> -rw-r--r-- 1 atadmin atadmin10899 Feb  8  2012  jta-1.1.jar
> -rw-r--r-- 1 atadmin atadmin   367444 Jun 18 15:58  log4j.jar
> -rw-r--r-- 1 atadmin atadmin  3698857 Jul  6 21:11  ojdbc7.jar
> -rw-r--r-- 1 atadmin atadmin   105355 Jun 18 15:58
> old_lcms-webtools.jar
> -rw-r--r-- 1 atadmin atadmin   795231 Jun 18 15:58
> poi-2.5-final-20040302.jar
> -rw-r--r-- 1 atadmin atadmin55210 Jun 18 15:58
> poi-contrib-2.5-final-20040302.jar
> -rw-r--r-- 1 atadmin atadmin   188942 Jun 18 15:58
> poi-scratchpad-2.5-final-20040302.jar
> -rw-r--r-- 1 atadmin atadmin   475943 Jun 18 15:58
> proxool-0.8.3.jar
> -rw-r--r-- 1 atadmin atadmin25496 Feb  8  2012
> slf4j-api-1.6.1.jar
> -rw-r--r-- 1 atadmin atadmin 7669 Mar 26 20:33
> slf4j-simple-1.6.1.jar
> -rw-r--r-- 1 atadmin atadmin   543706 Jun 18 15:58  struts.jar
> -rw-r--r-- 1 atadmin atadmin   495271 Jun 18 15:58
> Struts-Layout.jar
> -rw-r--r-- 1 atadmin atadmin68046 Jun 18 15:58
> struts-menu-2.4.3.jar
> -rw-r--r-- 1 atadmin atadmin39427 Jun 18 15:58
> taglibs-request.jar
> -rw-r--r-- 1 atadmin atadmin44061 Jun 18 15:58
> USPS-Framework-1.0.8-alpha.jar
> -rw-r--r-- 1 atadmin atadmin   364425 Jun 18 15:58
> usps_tools.jar
> -rw-r--r-- 1 atadmin atadmin   834966 Jun 18 15:58
> xercesImpl.jar
>
>
>
>
> After I started the Tomcat 9.0.13 server,  login as  topsadmin user, our
> Postal TOPS application GUI main page show up.   When I click the "Serach"
> button on the Transportation Search screen after entering the origin and
> destination values, I get the following error:
>
> 81036 [https-jsse-nio-9443-exec-8] ERROR actions.DispatchAction  -
> Dispatch[/TransportationInquiryResults] to method
> 'searchTransportationViewResults' returned an 

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread Paul Carter-Brown
Hi John,

See original request. It's pretty much a Kafka/Servlet proxy/gateway:

I'm trying to design a Kafka consumer and producer that will run inside the
tomcat jvm and pick up messages off a Kafka topic and translate them into a
servlet request and pass it through tomcat and then when the response is
complete then translate it into a Kafka message and put it onto another
topic as a reply. This way I can reuse our existing jax-rs rest services
and expose them as an async api over Kafka. The idea is to make the Kafka
messages similar to http in that they would consist of headers and a body.
The body would be json.


On Mon, May 6, 2019 at 6:13 PM John Dale  wrote:

> You could try debugging the tomcat code and find out how, right after
> it parses the TCP request, it invokes the servlet.  You can then
> create your own harness for tomcat code after initializing the
> appropriate context for the request to tomcat.  I don't know off hand
> where in the tomcat code this cut point can be found.
>
> Is this a performance issue, or are you building a proxy?
>
> What is the problem you're trying to solve?
>
> On 5/6/19, Paul Carter-Brown  wrote:
> > Yea, but the issue is that only works when calling in the context of a
> > current servlet call.
> >
> > Here is the kind of problem I want to solve:
> >
> > @WebServlet(name = "MyExample", urlPatterns = {"/example"},
> loadOnStartup =
> > 1)
> > public class Example extends HttpServlet {
> >
> > @PersistenceContext
> > private EntityManager em;
> >
> > @Override
> > public void init(ServletConfig config) {
> > Thread t = new Thread(() -> {
> > while (true) {
> > try {
> > // Do a GET to /example/ and get the response without
> > going out on localhost and back in
> > // We cant just call doGet as we want the request to
> > flow through the servlet filters, do the entitymanager injection etc
> > Thread.sleep(1);
> > } catch (Exception e) {
> > }
> > }
> > });
> > t.start();
> >
> > }
> >
> > @Override
> > protected void doGet(HttpServletRequest req, HttpServletResponse
> resp)
> > throws ServletException, IOException {
> > // do stuff like use em
> > resp.setStatus(200);
> > resp.getWriter().write("Hello World");
> > }
> >
> > }
> >
> >
> >
> >
> > On Mon, May 6, 2019 at 5:35 PM John Dale  wrote:
> >
> >> For reference, I did find this after searching "calling a servlet
> >> programmatically":
> >> https://docs.oracle.com/cd/E19146-01/819-2634/abxbn/index.html
> >>
> >> On 5/6/19, Paul Carter-Brown  wrote:
> >> > I think we are completely missing each other. Forget sockets - that
> was
> >> > just an example. I have code running in a Tomcat App server which is
> >> > not
> >> > managed by Tomcat and is not initiated by anything within Tomcat. That
> >> code
> >> > now wants to call a servlet hosted in that very same JVM. Any way to
> do
> >> > that without going out and back in on TCP?
> >> >
> >> >
> >> > On Mon, May 6, 2019 at 5:14 PM John Dale  wrote:
> >> >
> >> >> Sockets are an implementation of TCP/UDP inherently.
> >> >>
> >> >> Perhaps a mountaintop signal fire?
> >> >>
> >> >> ;)
> >> >>
> >> >> John
> >> >>
> >> >>
> >> >> On 5/6/19, Paul Carter-Brown  wrote:
> >> >> > lol on the Semaphore Telegraph,
> >> >> >
> >> >> > I can't use a request dispatcher as the request is being initiated
> >> from
> >> >> > code that has no context. I already have it working with HTTP using
> >> >> > asynchttp library, but I want to avoid the overhead. E.g. lets say
> I
> >> >> wrote
> >> >> > my own server socket listener on port 1 running in the Tomcat
> >> >> > JVM
> >> >> > and
> >> >> > got some request in some propriatary protocol called X. Now I want
> >> >> > to
> >> >> call
> >> >> > a Tomcat servlet in the current JVM with some info I got over X
> >> without
> >> >> > going out on TCP and back in
> >&g

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread Paul Carter-Brown
Yea, but the issue is that only works when calling in the context of a
current servlet call.

Here is the kind of problem I want to solve:

@WebServlet(name = "MyExample", urlPatterns = {"/example"}, loadOnStartup =
1)
public class Example extends HttpServlet {

@PersistenceContext
private EntityManager em;

@Override
public void init(ServletConfig config) {
Thread t = new Thread(() -> {
while (true) {
try {
// Do a GET to /example/ and get the response without
going out on localhost and back in
// We cant just call doGet as we want the request to
flow through the servlet filters, do the entitymanager injection etc
Thread.sleep(1);
} catch (Exception e) {
}
}
});
t.start();

}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// do stuff like use em
resp.setStatus(200);
resp.getWriter().write("Hello World");
}

}




On Mon, May 6, 2019 at 5:35 PM John Dale  wrote:

> For reference, I did find this after searching "calling a servlet
> programmatically":
> https://docs.oracle.com/cd/E19146-01/819-2634/abxbn/index.html
>
> On 5/6/19, Paul Carter-Brown  wrote:
> > I think we are completely missing each other. Forget sockets - that was
> > just an example. I have code running in a Tomcat App server which is not
> > managed by Tomcat and is not initiated by anything within Tomcat. That
> code
> > now wants to call a servlet hosted in that very same JVM. Any way to do
> > that without going out and back in on TCP?
> >
> >
> > On Mon, May 6, 2019 at 5:14 PM John Dale  wrote:
> >
> >> Sockets are an implementation of TCP/UDP inherently.
> >>
> >> Perhaps a mountaintop signal fire?
> >>
> >> ;)
> >>
> >> John
> >>
> >>
> >> On 5/6/19, Paul Carter-Brown  wrote:
> >> > lol on the Semaphore Telegraph,
> >> >
> >> > I can't use a request dispatcher as the request is being initiated
> from
> >> > code that has no context. I already have it working with HTTP using
> >> > asynchttp library, but I want to avoid the overhead. E.g. lets say I
> >> wrote
> >> > my own server socket listener on port 1 running in the Tomcat JVM
> >> > and
> >> > got some request in some propriatary protocol called X. Now I want to
> >> call
> >> > a Tomcat servlet in the current JVM with some info I got over X
> without
> >> > going out on TCP and back in
> >> >
> >> > On Mon, May 6, 2019 at 4:40 PM John Dale  wrote:
> >> >
> >> >> If you're wanting to forward control to another servlet deployed in
> >> >> the same context:
> >> >> https://www.javatpoint.com/requestdispatcher-in-servlet
> >> >>
> >> >> If you are okay going through TCP to facilitate some future or
> current
> >> >> distribution of services, Use HTTPURLConnection (not sure what you're
> >> >> wanting to do with the result of the request, if anything):
> >> >>
> >> >>
> >>
> https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests
> >> >>
> >> >> If you need more sophisticated HTTP interactions, Apache maintains a
> >> >> very useful library for that:  http://hc.apache.org/
> >> >>
> >> >> If these don't work-out for you, rather than using .NET, PHP, Python,
> >> >> or some other Java facsimile at best, I recommend using the semaphore
> >> >> telegraph:
> >> >> https://en.wikipedia.org/wiki/Semaphore_telegraph
> >> >>
> >> >> Sincerely,
> >> >>
> >> >> John
> >> >> DB2DOM
> >> >>
> >> >> On 5/6/19, Paul Carter-Brown  wrote:
> >> >> > Hi John,
> >> >> >
> >> >> > Thanks for your feedback.
> >> >> >
> >> >> > The request I'm initiating should not or need not carry any context
> >> >> > from
> >> >> > the originating code. There is also no session to worry about as
> its
> >> >> > just
> >> >> > for rest calls. So basically I have the headers, path and body and
> >> need
> >> >> to
> >>

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread Paul Carter-Brown
I think we are completely missing each other. Forget sockets - that was
just an example. I have code running in a Tomcat App server which is not
managed by Tomcat and is not initiated by anything within Tomcat. That code
now wants to call a servlet hosted in that very same JVM. Any way to do
that without going out and back in on TCP?


On Mon, May 6, 2019 at 5:14 PM John Dale  wrote:

> Sockets are an implementation of TCP/UDP inherently.
>
> Perhaps a mountaintop signal fire?
>
> ;)
>
> John
>
>
> On 5/6/19, Paul Carter-Brown  wrote:
> > lol on the Semaphore Telegraph,
> >
> > I can't use a request dispatcher as the request is being initiated from
> > code that has no context. I already have it working with HTTP using
> > asynchttp library, but I want to avoid the overhead. E.g. lets say I
> wrote
> > my own server socket listener on port 1 running in the Tomcat JVM and
> > got some request in some propriatary protocol called X. Now I want to
> call
> > a Tomcat servlet in the current JVM with some info I got over X without
> > going out on TCP and back in
> >
> > On Mon, May 6, 2019 at 4:40 PM John Dale  wrote:
> >
> >> If you're wanting to forward control to another servlet deployed in
> >> the same context:
> >> https://www.javatpoint.com/requestdispatcher-in-servlet
> >>
> >> If you are okay going through TCP to facilitate some future or current
> >> distribution of services, Use HTTPURLConnection (not sure what you're
> >> wanting to do with the result of the request, if anything):
> >>
> >>
> https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests
> >>
> >> If you need more sophisticated HTTP interactions, Apache maintains a
> >> very useful library for that:  http://hc.apache.org/
> >>
> >> If these don't work-out for you, rather than using .NET, PHP, Python,
> >> or some other Java facsimile at best, I recommend using the semaphore
> >> telegraph:
> >> https://en.wikipedia.org/wiki/Semaphore_telegraph
> >>
> >> Sincerely,
> >>
> >> John
> >> DB2DOM
> >>
> >> On 5/6/19, Paul Carter-Brown  wrote:
> >> > Hi John,
> >> >
> >> > Thanks for your feedback.
> >> >
> >> > The request I'm initiating should not or need not carry any context
> >> > from
> >> > the originating code. There is also no session to worry about as its
> >> > just
> >> > for rest calls. So basically I have the headers, path and body and
> need
> >> to
> >> > generate a http servlet request and get an http servlet response (or
> >> > similar) back. I have this working by calling into localhost but
> >> > ideally
> >> > want to skip the trombone out and back in.
> >> >
> >> > Have you got any basic code examples?
> >> >
> >> > Paul
> >> >
> >> > On Tue, Apr 30, 2019 at 5:27 PM John Dale  wrote:
> >> >
> >> >> Another thought .. you can do some request dispatching, but without
> >> >> knowing more about the tools you're using, I can't say for sure if
> >> >> this is the direction you'll want to go.
> >> >>
> >> >> On 4/29/19, Paul Carter-Brown  wrote:
> >> >> > Hi
> >> >> >
> >> >> > I'm trying to design a Kafka consumer and producer that will run
> >> inside
> >> >> the
> >> >> > tomcat jvm and pick up messages off a Kafka topic and translate
> them
> >> >> into a
> >> >> > servlet request and pass it through tomcat and then when the
> >> >> > response
> >> >> > is
> >> >> > complete then translate it into a Kafka message and put it onto
> >> another
> >> >> > topic as a reply. This way I can reuse our existing jax-rs rest
> >> >> > services
> >> >> > and expose them as an async api over Kafka. The idea is to make the
> >> >> > Kafka
> >> >> > messages similar to http in that they would consist of headers and
> a
> >> >> body.
> >> >> > The body would be json.
> >> >> >
> >> >> > Now I know this could be done by calling localhost with an http
> call
> >> to
> >> >> > trombone the requests back into tomcat but I'd like to avoid the
> >> >> associated
> >> >> > latency and overhead. Is it possible to call tomcat directly
> >> >> > in-process.
> >> >> > This does not need to be portable to other containers so can be
> >> >> > proprietary.
> >> >> >
> >> >> > I'm using tomcat 8. In fact its tomee 8 but guessed this is more a
> >> >> > tomcat
> >> >> > question than tomee but have sent to both groups just in case.
> >> >> >
> >> >> > Thanks for any insights.
> >> >> >
> >> >> > Paul
> >> >> >
> >> >>
> >> >
> >>
> >> -
> >> 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: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread Paul Carter-Brown
lol on the Semaphore Telegraph,

I can't use a request dispatcher as the request is being initiated from
code that has no context. I already have it working with HTTP using
asynchttp library, but I want to avoid the overhead. E.g. lets say I wrote
my own server socket listener on port 1 running in the Tomcat JVM and
got some request in some propriatary protocol called X. Now I want to call
a Tomcat servlet in the current JVM with some info I got over X without
going out on TCP and back in

On Mon, May 6, 2019 at 4:40 PM John Dale  wrote:

> If you're wanting to forward control to another servlet deployed in
> the same context:
> https://www.javatpoint.com/requestdispatcher-in-servlet
>
> If you are okay going through TCP to facilitate some future or current
> distribution of services, Use HTTPURLConnection (not sure what you're
> wanting to do with the result of the request, if anything):
>
> https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests
>
> If you need more sophisticated HTTP interactions, Apache maintains a
> very useful library for that:  http://hc.apache.org/
>
> If these don't work-out for you, rather than using .NET, PHP, Python,
> or some other Java facsimile at best, I recommend using the semaphore
> telegraph:
> https://en.wikipedia.org/wiki/Semaphore_telegraph
>
> Sincerely,
>
> John
> DB2DOM
>
> On 5/6/19, Paul Carter-Brown  wrote:
> > Hi John,
> >
> > Thanks for your feedback.
> >
> > The request I'm initiating should not or need not carry any context from
> > the originating code. There is also no session to worry about as its just
> > for rest calls. So basically I have the headers, path and body and need
> to
> > generate a http servlet request and get an http servlet response (or
> > similar) back. I have this working by calling into localhost but ideally
> > want to skip the trombone out and back in.
> >
> > Have you got any basic code examples?
> >
> > Paul
> >
> > On Tue, Apr 30, 2019 at 5:27 PM John Dale  wrote:
> >
> >> Another thought .. you can do some request dispatching, but without
> >> knowing more about the tools you're using, I can't say for sure if
> >> this is the direction you'll want to go.
> >>
> >> On 4/29/19, Paul Carter-Brown  wrote:
> >> > Hi
> >> >
> >> > I'm trying to design a Kafka consumer and producer that will run
> inside
> >> the
> >> > tomcat jvm and pick up messages off a Kafka topic and translate them
> >> into a
> >> > servlet request and pass it through tomcat and then when the response
> >> > is
> >> > complete then translate it into a Kafka message and put it onto
> another
> >> > topic as a reply. This way I can reuse our existing jax-rs rest
> >> > services
> >> > and expose them as an async api over Kafka. The idea is to make the
> >> > Kafka
> >> > messages similar to http in that they would consist of headers and a
> >> body.
> >> > The body would be json.
> >> >
> >> > Now I know this could be done by calling localhost with an http call
> to
> >> > trombone the requests back into tomcat but I'd like to avoid the
> >> associated
> >> > latency and overhead. Is it possible to call tomcat directly
> >> > in-process.
> >> > This does not need to be portable to other containers so can be
> >> > proprietary.
> >> >
> >> > I'm using tomcat 8. In fact its tomee 8 but guessed this is more a
> >> > tomcat
> >> > question than tomee but have sent to both groups just in case.
> >> >
> >> > Thanks for any insights.
> >> >
> >> > Paul
> >> >
> >>
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread Paul Carter-Brown
Hi John,

Thanks for your feedback.

The request I'm initiating should not or need not carry any context from
the originating code. There is also no session to worry about as its just
for rest calls. So basically I have the headers, path and body and need to
generate a http servlet request and get an http servlet response (or
similar) back. I have this working by calling into localhost but ideally
want to skip the trombone out and back in.

Have you got any basic code examples?

Paul

On Tue, Apr 30, 2019 at 5:27 PM John Dale  wrote:

> Another thought .. you can do some request dispatching, but without
> knowing more about the tools you're using, I can't say for sure if
> this is the direction you'll want to go.
>
> On 4/29/19, Paul Carter-Brown  wrote:
> > Hi
> >
> > I'm trying to design a Kafka consumer and producer that will run inside
> the
> > tomcat jvm and pick up messages off a Kafka topic and translate them
> into a
> > servlet request and pass it through tomcat and then when the response is
> > complete then translate it into a Kafka message and put it onto another
> > topic as a reply. This way I can reuse our existing jax-rs rest services
> > and expose them as an async api over Kafka. The idea is to make the Kafka
> > messages similar to http in that they would consist of headers and a
> body.
> > The body would be json.
> >
> > Now I know this could be done by calling localhost with an http call to
> > trombone the requests back into tomcat but I'd like to avoid the
> associated
> > latency and overhead. Is it possible to call tomcat directly in-process.
> > This does not need to be portable to other containers so can be
> > proprietary.
> >
> > I'm using tomcat 8. In fact its tomee 8 but guessed this is more a tomcat
> > question than tomee but have sent to both groups just in case.
> >
> > Thanks for any insights.
> >
> > Paul
> >
>


Initiating httpservletrequest from inside Tomcat / TomEE

2019-04-29 Thread Paul Carter-Brown
Hi

I'm trying to design a Kafka consumer and producer that will run inside the
tomcat jvm and pick up messages off a Kafka topic and translate them into a
servlet request and pass it through tomcat and then when the response is
complete then translate it into a Kafka message and put it onto another
topic as a reply. This way I can reuse our existing jax-rs rest services
and expose them as an async api over Kafka. The idea is to make the Kafka
messages similar to http in that they would consist of headers and a body.
The body would be json.

Now I know this could be done by calling localhost with an http call to
trombone the requests back into tomcat but I'd like to avoid the associated
latency and overhead. Is it possible to call tomcat directly in-process.
This does not need to be portable to other containers so can be proprietary.

I'm using tomcat 8. In fact its tomee 8 but guessed this is more a tomcat
question than tomee but have sent to both groups just in case.

Thanks for any insights.

Paul