• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JSP doesn't work in Linux server.

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

------------------------------------------------------------------------
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Smith Li
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Smith Li
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Smith Li
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Smith Li
    Ranch Hand
    Posts: 114
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It works okay now.
    Thanks for the help!

    ~ Rudy ~
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    What did you do?
     
    Smith Li
    Ranch Hand
    Posts: 114
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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 VI Editor Redhat
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Glad it's working.
    Thanks for posting back with your solution.
     
    You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic