Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP doesn't work in Linux server.

 
Rudy Rusli
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tested my jsp codes in my local machine and it works great.

I then deploy the code to a linux server and encounter the error below.
I'm not sure how to approach this situation. I gave the permission for user, group, and others to be rwx for myFile.jsp also for the directories where the file kept.

Any advice?
Thanks in advance for the help.

------------------------------------------------------------------------
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Permission denied)


Pretty much sums it up.
Looks like the user under which your container is running doesn't have sufficient permissions to read or write the necessary files to the OS's file system.
 
Rudy Rusli
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thanks for the lead.
I'm new in JSP development.

Should I change something in tomcat or this is a problem in the linux permission system?

Thanks again,
~ Rudy ~
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like Tomcat was installed by one user and is now being run under another username.

You could either:
Start tomcat from the same login under which it was installed
or
ease the permissions for the tomcat/work directory.
Tomcat must be able to read and write to the directories under the work directory and the logs directory. It only needs read permissions for the rest.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Odds are that root installed and you're testing under your own user account. I've been bitten by this myself.

The best way to test Tomcat under linux seems to be just unpacking your your own personal tomcat (e.g. under your home directory) and using that one.

For system (production server) use, I prefer to create a user/group named tomcat and "chown tomcat:tomcat --recursive /usr/local/tomcat" so that Tomcat won't have to run as root. In my case, my tomcat init scripts su to be the tomcat user before starting the production server.
 
Rudy Rusli
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I have in /webapps/ directory of tomcat.

tomcat tomcat app1 --> /myDirectory/app1/ (symbolic links)
tomcat tomcat app2 --> /myDirectory/app2/
tomcat tomcat app3 --> /myDirectory/app3/

app1 and app2 work just fine. then i added app3. but app3 didn't seem to work and it gave me that error.

so i don't think it's because i run tomcat under different user from what it is originally installed? since app1 and app2 seem to work just fine?
 
Rudy Rusli
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put one jsp file from /myDirectory/app3/ to /myDirectory/app2/ and I didn't get the error when displaying it in the browser.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first time a request is made to a JSP (or if the JSP file has changed since the last request) the servlet container will:
  • Parse the JSP and generate a servlet source file.
  • Compile the source file into a java class file
  • Instanciate the class and load it into memory
  • Serve up the results from the loaded class file.

  • Subsequent hits go straight to the last step.
    If you change the JSP file, the process starts over again.
    In Tomcat the source and class files get written to directories under the tomcat/work directory.

    If, for whatever reason, tomcat can't write to or read from that directory, you're going to see the above exception.
    One way or another, you will need to insure that the user under which Tomcat is running can read and write to that directory structure.
    It will also need to be able to write to the tomcat/logs directory.
     
    Rudy Rusli
    Ranch Hand
    Posts: 114
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It works okay now.
    Thanks for the help!

    ~ Rudy ~
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser Redhat VI Editor
     
    Rudy Rusli
    Ranch Hand
    Posts: 114
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Tomcat is being run under username: "tomcat".

    Then I checked the /work/Catalina/localhost/myApp3 permission which appparently belong to username:root, group:root. I changed them to "tomcat: and it worked.
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser Redhat VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Glad it's working.
    Thanks for posting back with your solution.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic