Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-08 Thread John Dale
This was in the spirit of one of my suggestions and probably how I would approach the problem to save them/me having to create a Tomcat request harness .. encapsulate the service in a static method and call that (cohesive). Have a super day, John On 5/8/19, Christopher Schultz wrote: > -BE

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Terence and Paul, On 5/6/19 14:36, Terence M. Bandoian wrote: > On 5/6/2019 10:45 AM, Paul Carter-Brown wrote: 2) Can the servlets > you want to use be refactored so that the underlying functionality > is exposed in a way that doesn't require any co

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-08 Thread Mark Thomas
On 06/05/2019 17:47, Owen Rubel wrote: > I didn't think that TomEE was Tomcat. Wasn't it it's own thing??? I mean > TomEE is this separate project maintained by this up here in Seattle vs > Tomcat which is an Apache Project. Apache Tomcat are Apache TomEE are both Apache projects. Apache TomEE sp

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread Terence M. Bandoian
On 5/6/2019 10:45 AM, 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 Ht

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread Owen Rubel
I didn't think that TomEE was Tomcat. Wasn't it it's own thing??? I mean TomEE is this separate project maintained by this up here in Seattle vs Tomcat which is an Apache Project. Owen Rubel oru...@gmail.com On Mon, May 6, 2019 at 9:16 AM Paul Carter-Brown wrote: > Hi John, > > See original re

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread John Dale
I would trace tomcat and recreate a servlet request .. see if I could hack it in that way (assuming that localhost traffic isn't fast enough). Normalizing on HTTP/TCP will be more maintainable, though? Can somebody suggest a good place for a breakpoint? Any other suggestions? John On 5/6/19,

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 respo

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread John Dale
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 c

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

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread John Dale
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

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread John Dale
Another thought is that servlets maintain contextual information and resources .. that's nice, saves a lot of time. As soon as you need a database resource or an extension of your pruned-back HTTP implementation on the server socket, you'll be rebuilding what Tomcat has already done? On 5/6/19,

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread John Dale
Class loaders maintain isolation of contexts, so calling a method on a different servlet can be tricky, but that is possible. Although, take into account that the container maintains pools of servlets, so something like a static service method, assuming you can crack the class loader nut, might wo

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 w

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread John Dale
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 worki

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

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-05-06 Thread John Dale
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 w

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

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-04-30 Thread John Dale
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

Re: Initiating httpservletrequest from inside Tomcat / TomEE

2019-04-30 Thread John Dale
This is one of my favorite things. You'll need to retransmit headers, but by and large it's doable. Management of contexts can be tricky. Don't forget that the target service will have a difference context (database connection context has bitten me in the past on this type of task). I do my sess

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 anothe