when I Proxy Pass I lose the java session.

hi,

I have searched the web for two days without getting answer to this, so I turn to the experts :)

I'm using Sun Java System Application Server (Platform Edition 8.0.0_01) to run my java programs on, and they work on it.

Then I have an apache running on port 80 and proxypass my application server on that apache.
here is how I do that:

<VirtualHost *:80>
    ServerAdmin webmaster@aripall.com
    DocumentRoot c:\\www\\aripall.com\\htdocs
    ServerName www.aripall.com
    ServerAlias aripall.com
    ErrorLog c:\\www\\aripall.com\\logs\\error.log
    CustomLog c:\\www\\aripall.com\\logs\\acces.log common
       
    ProxyRequests Off
    ProxyPass / http://www.aripall.com:8001/myapp/
    ProxyPassReverse / http://www.aripall.com:8001/myapp/

</VirtualHost>


With the configuration above I always get a new session when I go to www.aripall.com (through the proxy pass) , but when I access the "orginal" location of it with  http://www.aripall.com:8001/myapp/ I do not lose the session.

to simplify the problem. If I write in a jsp page, out.println("sessionId: "+session.getId()) I always get the same sessionId when I refresh the page if I go straigth to the application server, but do always get a different sessionId when I go through the proxy pass.

cheers from Iceland
 Kjarri
KjarrialbertsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

petmagdyCommented:
alright
I will try to help hopfully we can find out the solution.
 I used Apache mode_proxy before with OC4J and it works fine and the session is maintain but the only difference was not throught virtual host but like this:

make sure those was not commented
LoadModule proxy_module
AddModule mod_proxy.c

<IfModule mod_proxy.c>
    ProxyRequests On
    ProxyPass /myroot                   http://www.aripall.com:8001/myapp/
    ProxyPassReverse /myroot   http://www.aripall.com:8001/myapp/
</IfModule>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KjarrialbertsAuthor Commented:
hi and thank you very much for your answer.
Because of time different I haven't been able to answer you sooner.

I can't access the server for the next 8 hours to try out your solution, but I think it does not work for me.

I think I have to use virtual host since I'm hosting 5 domains on that server and I want each of them to point to a different java application on the application server (which is running on the same macine).
Isn't that correct that I have to use virtual host if I'm going to proxy pass diffent "roots" (for different domains) to different java applications?
that is, I could have two applications on the application server working (with the session working) on:
www.mydomain.com:8001/myapp
www.mydomain.com:8001/myotherapp

and I would like to map the root of two different domains to these apps, so:
www.mydomain.com  would proxy pass to www.mydomain.com:8001/myapp 
and
www.mydomain2.com  would proxy pass to www.mydomain.com:8001/myotherapp 
as stated before, this proxy passing works, except I always get a new session for each refresh of the jsp page.

hope this explained why I think I have to use virtual host and proxy pass there.
But I will try out your solution after 8 hours.

thanks again
  Kjarri
0
petmagdyCommented:
yes give it a shot
and one more thing, in ut virtual host proxy why  ProxyRequests is Off?
0
Managing Security & Risk at the Speed of Business

Gartner Research VP, Neil McDonald & AlgoSec CTO, Prof. Avishai Wool, discuss the business-driven approach to automated security policy management, its benefits and how to align security policy management with business processes to address today's security challenges.

KjarrialbertsAuthor Commented:
hi, wow that was a quick answer!
Yes I will try your solution soon as I can.

ProxyRequests  Off  was just something I saw on a page somewhere when I was trying to find a solution on this.
First I was  with this line NOT in, but it did not change anything to add it.... It probably should not be there, it did at least not solve my problem.
So without this line, I don't see any changes on the java session behavior.

thanks again
  Kjarri
0
petmagdyCommented:
then can u try it on first? I think the correct value is On
0
KjarrialbertsAuthor Commented:
thanks, I will try it in about 7-8 hours.
0
KjarrialbertsAuthor Commented:
hi,

setting ProxyRequests to On, did not change anything.

by adding your lines, then calling mydomain.com/myroot have the same effect as before, the proxy pass works, but I always get different session for each refresh.

additional info:
I'm using apache2.
I (ofcourse) reboot the apache after each change before I try.

cheers
  Kjarri
0
petmagdyCommented:
well
 I began to think this is something related to Sun AS

When i test this on OC4J it was apache 2 also
maybe it is better to use Sun AS plugin for apache
0
KjarrialbertsAuthor Commented:
I'm going to install OC4J to check if it works there.
0
KjarrialbertsAuthor Commented:
hi,
When I use OC4J this works!
the session in "unharmed" when I refresh the page.
I'm just going to use OC4J since the Sun Server is not working for this.
This is ofcouse ratical change, but it's ok for me.... the problem where not solved with the Sun Server, but this is enough for me.
cheers from Iceland
  Kjarri
0
petmagdyCommented:
cheers welcome :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Application Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.