You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Auke Noppe <au...@gmail.com> on 2007/10/22 11:40:28 UTC

Start tomcat without Connector

Hi there, 

 

Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don’t
get a response back.

 

public void startTomcat() throws LifecycleException {

        embedded = new Embedded();

        

        engine = embedded.createEngine();

        engine.setName("Catalina");

        

        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);

 

        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false); 

        host.addChild(context);

        String config = host.getConfigClass();

 
((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");

        

        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }

 

The other method calls context.invoke with a filled request and response.

 

 

 

Anyone an idea?

 

Regards,

 

Auke

 


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09
 

RE: Start tomcat without Connector

Posted by Auke Noppe <au...@gmail.com>.
Chris,

I'm making a kind of framework for my company, it must be able to measure the time tomcat needs to compile the jsp's. this enables us to optimize more accurate.
But, about starting tomcat etc. I am at a point that tomcat starts gracefully without connector, but the jsp's and Servlets don't have a wrapper. When I execute a request, like "/index.jsp" (which exists of course ;) ) then I get this error:

SEVERE: Allocate exception for servlet null
javax.servlet.ServletException: No servlet class has been specified for servlet null
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1016)

this is not the complete stacktrace.
Do you have an idea how I can solve this problem?

Auke


-----Oorspronkelijk bericht-----
Van: Christopher Schultz [mailto:chris@christopherschultz.net] 
Verzonden: maandag 22 oktober 2007 22:07
Aan: Tomcat Users List
Onderwerp: Re: Start tomcat without Connector

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Auke,

Auke Noppe wrote:
> Is it possible to start an instance of (embedded)tomcat without connector,
> and to invoke pages through the context.invoke(request, response) method?

Do you mind describing a scenario where this is useful? The only thing I
can think of is that JSPs might be easier to write than "real" Java, and
you want to allow your "programmers" to write JSP instead of Java, but
not use it in a web context. That sounds totally backward to me (but
I've heard crazier schemes), so I'm wondering what the motivation is.

My experience with Tomcat (non-embedded) is that if the connectors fail
to start, Tomcat itself shuts down. My guess is that there's a check for
useful connectors, and if there are none, Tomcat shuts down. I could be
totally wrong.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHHQL59CaO5/Lv0PARAihfAJ9ScHeDf3Db4O08MUrktTjV0aq2iwCgq2nI
qso401jWy/diffX0RA8OasA=
=yYBc
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007 19:57
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007 19:57
 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Start tomcat without Connector

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Auke,

Auke Noppe wrote:
> Is it possible to start an instance of (embedded)tomcat without connector,
> and to invoke pages through the context.invoke(request, response) method?

Do you mind describing a scenario where this is useful? The only thing I
can think of is that JSPs might be easier to write than "real" Java, and
you want to allow your "programmers" to write JSP instead of Java, but
not use it in a web context. That sounds totally backward to me (but
I've heard crazier schemes), so I'm wondering what the motivation is.

My experience with Tomcat (non-embedded) is that if the connectors fail
to start, Tomcat itself shuts down. My guess is that there's a check for
useful connectors, and if there are none, Tomcat shuts down. I could be
totally wrong.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHHQL59CaO5/Lv0PARAihfAJ9ScHeDf3Db4O08MUrktTjV0aq2iwCgq2nI
qso401jWy/diffX0RA8OasA=
=yYBc
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Start tomcat without Connector

Posted by Bill Barker <wb...@wilshire.com>.
It's actually the org.apache.catalina.connector.Request that handles getting 
the session.  For the first time the session is requested, tt does this by 
getting the manager from the context, and calls the findSession(String 
sessionid) method on the manager.  If this returns null, then it does much 
like the code below, except that it sets the JSESSIONID cookie as well.

The ability to get the connector Request object depends on timing.  As a 
result, depending on your test plan, it may be easier to create a custom 
Valve (added to, say, the context, but it doesn't really matter) which will 
have easy access to the connector Request.  However, if you will only ever 
need it for the second or higher times that you use the coyoteRequest, then 
you can get it via:
         org.apache.catalina.connector.Request tcreq =
                   (org.apache.catalina.connector.Request)coyoteRequest.getNote(CoyoteAdapter.ADAPTER_NOTES);

Then you can do something like (assuming that you have passed the cookie 
header/encoded the URL):
     Session session = tcreq.getSession();
     HttpSession hsession = session.getSession();
     // setup a bunch of attributes here

Again, depending on your testing plan, it may just be easier to deal with 
the manager directly.  I haven't seen it, so I can't comment on what is best 
for you :).

"Auke Noppe" <au...@gmail.com> wrote in message 
news:000401c8161b$947da750$bd78f5f0$@com...
I have an instance of the manager now. I forgot a reference. But, how can I
make a reference to the session in the coyoteRequest? Or does the context
manage the sessions (by the manager) and is the context the one who makes
the references between sessions and coyoteRequests?

Lots of thanks,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: woensdag 24 oktober 2007 3:41
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

Nope, this won't work.  The Request needs to be mapped before TC knows how
to find the Session.

After the Context is started, it should have a Manager (if you haven't
explicitly configured one).  I'm guessing that you are doing some sort of
Mock unit testing, and you want the Session configured before you run your
test.  In that case, you want something like (after you call start):
    Manager manager = context.getManager();
    Session session = manager.createSession("MySessionId");
    manager.add(session);
    HttpSession hsession = session.getSession();
    hsession.setAttribute(foo, bar);



"Auke Noppe" <au...@gmail.com> wrote in message
news:002c01c81582$3c952c00$b5bf8400$@com...
Hi,

I have the app working. But I want to set some attributes on the session
(like a user). Does anyone knows how I can get to the HttpSession? I tried
to create a org.apache.catalina.connector.Request via
connector.createRequest() and invoke the request.getSession() method, but I
always receive null from the request. The manager of the context is empty I
found out. Should it not be instantiated/set during startup?

I there another way to get a reference of a HttpSession?

Regards,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly
with the Catalina code now.  In particular, you can't just call the invoke
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a
reference to it by calling getProtocolHandler() on the Connector, and then
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don�t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.8/1089 - Release Date: 23-10-2007
19:39



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Start tomcat without Connector

Posted by Auke Noppe <au...@gmail.com>.
I have an instance of the manager now. I forgot a reference. But, how can I
make a reference to the session in the coyoteRequest? Or does the context
manage the sessions (by the manager) and is the context the one who makes
the references between sessions and coyoteRequests?

Lots of thanks,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: woensdag 24 oktober 2007 3:41
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

Nope, this won't work.  The Request needs to be mapped before TC knows how 
to find the Session.

After the Context is started, it should have a Manager (if you haven't 
explicitly configured one).  I'm guessing that you are doing some sort of 
Mock unit testing, and you want the Session configured before you run your 
test.  In that case, you want something like (after you call start):
    Manager manager = context.getManager();
    Session session = manager.createSession("MySessionId");
    manager.add(session);
    HttpSession hsession = session.getSession();
    hsession.setAttribute(foo, bar);



"Auke Noppe" <au...@gmail.com> wrote in message 
news:002c01c81582$3c952c00$b5bf8400$@com...
Hi,

I have the app working. But I want to set some attributes on the session
(like a user). Does anyone knows how I can get to the HttpSession? I tried
to create a org.apache.catalina.connector.Request via
connector.createRequest() and invoke the request.getSession() method, but I
always receive null from the request. The manager of the context is empty I
found out. Should it not be instantiated/set during startup?

I there another way to get a reference of a HttpSession?

Regards,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly
with the Catalina code now.  In particular, you can't just call the invoke
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a
reference to it by calling getProtocolHandler() on the Connector, and then
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don’t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.8/1089 - Release Date: 23-10-2007
19:39
 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Start tomcat without Connector

Posted by Bill Barker <wb...@wilshire.com>.
For Parameters, just include them in the query string, or the request body, 
and Tomcat will do it's thing with them.  For request Attributes, just set 
them on the coyoteRequest, and they will be picked up.

"Auke Noppe" <au...@gmail.com> wrote in message 
news:000001c81619$59032170$0b096450$@com...
Yes, is a kind of mock testing. But I have to instantiate a session, because
I don�t use a browser to access my instance of tomcat. My app just uses some
tomcat files to process jsp's and Servlets.
But, when my app is started, the manager is still null. (e.g. I get a NPE
when I call context.manager())
Maybe I have to instantiate the manager by hand, but I'll try that first.

Now I'm trying to add some parameters to the request, e.g. username and
password. And then I call the cookie, created by the app. (it should work
nicer ;-))

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: woensdag 24 oktober 2007 3:41
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

Nope, this won't work.  The Request needs to be mapped before TC knows how
to find the Session.

After the Context is started, it should have a Manager (if you haven't
explicitly configured one).  I'm guessing that you are doing some sort of
Mock unit testing, and you want the Session configured before you run your
test.  In that case, you want something like (after you call start):
    Manager manager = context.getManager();
    Session session = manager.createSession("MySessionId");
    manager.add(session);
    HttpSession hsession = session.getSession();
    hsession.setAttribute(foo, bar);



"Auke Noppe" <au...@gmail.com> wrote in message
news:002c01c81582$3c952c00$b5bf8400$@com...
Hi,

I have the app working. But I want to set some attributes on the session
(like a user). Does anyone knows how I can get to the HttpSession? I tried
to create a org.apache.catalina.connector.Request via
connector.createRequest() and invoke the request.getSession() method, but I
always receive null from the request. The manager of the context is empty I
found out. Should it not be instantiated/set during startup?

I there another way to get a reference of a HttpSession?

Regards,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly
with the Catalina code now.  In particular, you can't just call the invoke
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a
reference to it by calling getProtocolHandler() on the Connector, and then
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don�t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.8/1089 - Release Date: 23-10-2007
19:39



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Start tomcat without Connector

Posted by Auke Noppe <au...@gmail.com>.
Yes, is a kind of mock testing. But I have to instantiate a session, because
I don’t use a browser to access my instance of tomcat. My app just uses some
tomcat files to process jsp's and Servlets.
But, when my app is started, the manager is still null. (e.g. I get a NPE
when I call context.manager())
Maybe I have to instantiate the manager by hand, but I'll try that first.

Now I'm trying to add some parameters to the request, e.g. username and
password. And then I call the cookie, created by the app. (it should work
nicer ;-))

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: woensdag 24 oktober 2007 3:41
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

Nope, this won't work.  The Request needs to be mapped before TC knows how 
to find the Session.

After the Context is started, it should have a Manager (if you haven't 
explicitly configured one).  I'm guessing that you are doing some sort of 
Mock unit testing, and you want the Session configured before you run your 
test.  In that case, you want something like (after you call start):
    Manager manager = context.getManager();
    Session session = manager.createSession("MySessionId");
    manager.add(session);
    HttpSession hsession = session.getSession();
    hsession.setAttribute(foo, bar);



"Auke Noppe" <au...@gmail.com> wrote in message 
news:002c01c81582$3c952c00$b5bf8400$@com...
Hi,

I have the app working. But I want to set some attributes on the session
(like a user). Does anyone knows how I can get to the HttpSession? I tried
to create a org.apache.catalina.connector.Request via
connector.createRequest() and invoke the request.getSession() method, but I
always receive null from the request. The manager of the context is empty I
found out. Should it not be instantiated/set during startup?

I there another way to get a reference of a HttpSession?

Regards,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly
with the Catalina code now.  In particular, you can't just call the invoke
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a
reference to it by calling getProtocolHandler() on the Connector, and then
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don’t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.8/1089 - Release Date: 23-10-2007
19:39
 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Start tomcat without Connector

Posted by Bill Barker <wb...@wilshire.com>.
Nope, this won't work.  The Request needs to be mapped before TC knows how 
to find the Session.

After the Context is started, it should have a Manager (if you haven't 
explicitly configured one).  I'm guessing that you are doing some sort of 
Mock unit testing, and you want the Session configured before you run your 
test.  In that case, you want something like (after you call start):
    Manager manager = context.getManager();
    Session session = manager.createSession("MySessionId");
    manager.add(session);
    HttpSession hsession = session.getSession();
    hsession.setAttribute(foo, bar);



"Auke Noppe" <au...@gmail.com> wrote in message 
news:002c01c81582$3c952c00$b5bf8400$@com...
Hi,

I have the app working. But I want to set some attributes on the session
(like a user). Does anyone knows how I can get to the HttpSession? I tried
to create a org.apache.catalina.connector.Request via
connector.createRequest() and invoke the request.getSession() method, but I
always receive null from the request. The manager of the context is empty I
found out. Should it not be instantiated/set during startup?

I there another way to get a reference of a HttpSession?

Regards,

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly
with the Catalina code now.  In particular, you can't just call the invoke
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a
reference to it by calling getProtocolHandler() on the Connector, and then
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don�t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Start tomcat without Connector

Posted by Auke Noppe <au...@gmail.com>.
Hi,

I have the app working. But I want to set some attributes on the session
(like a user). Does anyone knows how I can get to the HttpSession? I tried
to create a org.apache.catalina.connector.Request via
connector.createRequest() and invoke the request.getSession() method, but I
always receive null from the request. The manager of the context is empty I
found out. Should it not be instantiated/set during startup?

I there another way to get a reference of a HttpSession?

Regards, 

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly 
with the Catalina code now.  In particular, you can't just call the invoke 
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the 
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a 
reference to it by calling getProtocolHandler() on the Connector, and then 
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message 
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don’t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57
 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Start tomcat without Connector

Posted by Auke Noppe <au...@gmail.com>.
Thanks for your reply.

Do you know what method really applies the mapping?
And, is it possible to make my  own implementation of the mapping
digester(?)?"

Regards, 

Auke

-----Oorspronkelijk bericht-----
Van: news [mailto:news@ger.gmane.org] Namens Bill Barker
Verzonden: dinsdag 23 oktober 2007 3:27
Aan: users@tomcat.apache.org
Onderwerp: Re: Start tomcat without Connector

It is possible, but not easy.  The Connector is integrated pretty tightly 
with the Catalina code now.  In particular, you can't just call the invoke 
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the 
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a 
reference to it by calling getProtocolHandler() on the Connector, and then 
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message 
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don’t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.6/1086 - Release Date: 22-10-2007
19:57
 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Start tomcat without Connector

Posted by Bill Barker <wb...@wilshire.com>.
It is possible, but not easy.  The Connector is integrated pretty tightly 
with the Catalina code now.  In particular, you can't just call the invoke 
method on the Context, since the mappings are done via the Connector.

It will probably be easier to create a Connector using the 
MemoryProtocolHandler (in org.apache.coyote.memory).  You're code can get a 
reference to it by calling getProtocolHandler() on the Connector, and then 
feed your request through the process method of MemoryProtocolHandler.

"Auke Noppe" <au...@gmail.com> wrote in message 
news:000001c8148f$95651e10$c02f5a30$@com...
Hi there,



Is it possible to start an instance of (embedded)tomcat without connector,
and to invoke pages through the context.invoke(request, response) method?

I have written a small application which starts embedded tomcat with a
server, engine, host and context, but without connector.

And the application invokes the invoke method of the context. But I don�t
get a response back.



public void startTomcat() throws LifecycleException {

        embedded = new Embedded();



        engine = embedded.createEngine();

        engine.setName("Catalina");



        host = embedded.createHost("localhost", getPath() + "/webapps");

        engine.addChild(host);



        context = embedded.createContext("",
"C:/stage_auke/workspace/trunk/web");

        context.setPrivileged(false);

        host.addChild(context);

        String config = host.getConfigClass();


((StandardContext)context).setDefaultWebXml(getPath()+"/conf/web.xml");



        context.setAvailable(true);

        embedded.addEngine(engine);

        embedded.start();

    }



The other method calls context.invoke with a filled request and response.







Anyone an idea?



Regards,



Auke




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21-10-2007
15:09





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org