aspose file tools*
The moose likes JSP and the fly likes JSP doesn't work in Linux server. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP doesn Watch "JSP doesn New topic
Author

JSP doesn't work in Linux server.

Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
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

Joined: Dec 11, 2004
Posts: 13410

(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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Jun 25, 2001
Posts: 16012
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
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

Joined: Jun 01, 2006
Posts: 114
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

Joined: Dec 11, 2004
Posts: 13410

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

    Joined: Jun 01, 2006
    Posts: 114
    It works okay now.
    Thanks for the help!

    ~ Rudy ~
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    What did you do?
    Rudy Rusli
    Ranch Hand

    Joined: Jun 01, 2006
    Posts: 114
    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

    Joined: Dec 11, 2004
    Posts: 13410

    Glad it's working.
    Thanks for posting back with your solution.
     
    Don't get me started about those stupid light bulbs.
     
    subject: JSP doesn't work in Linux server.