vukosyst Posted January 14, 2018 Posted January 14, 2018 Hi there, Thanks for moving my account to Tommy and enabling Java! I uploaded a ROOT.war file through cPanel and then deployed it, but apparently I had to ask you to do this, because I want this deployment to run in the root-folder of Tomcat (tomcat/webapps, which I have no access to). Could you move the contents of the tomcat/webapps/ROOT folder up one level, as I think this makes the servlet run on http://inschrijven-vukamerorkest.heliohost.org/ is that correct? Is it possible to run Java servlets in the public_html directory, so that we don't have to upload .WAR files after each change of the webapp, but only those files that changed? Thanks, Martijn
wolstech Posted January 14, 2018 Posted January 14, 2018 Tomcat runs as a different user that doesn't have access to your home directory, which is why it can't see the contents of public_html. To my knowledge, we don't support running a war on the root of a domain.
Krydos Posted January 14, 2018 Posted January 14, 2018 You're on a multi-user server which means that each servlet must run in a subdirectory to keep them separate from each other. If everyone tried to run their application in the root folder you would get conflicts and files like index.jsp would get written and overwritten constantly. If you need to run your application in the root folder we recommend getting a VPS so that you'll be the only person using the whole server so there will be no conflicts. https://www.heliohost.org/partners/vps
vukosyst Posted January 15, 2018 Author Posted January 15, 2018 Ah, I see. The fact that I can't run a servlet in root is pretty logical, indeed! I now deployed to /web and the resulting servlet has references to /[username]_[foldername], which, in our case, is /vukosyst_web instead of just /web. This causes the servlet to misbehave, as the vukosyst_web folder does not exist, at least not on our host/domain. Do you have any idea how to solve this? Then, there's another thing that I don't (yet) understand: if Tomcat runs as a different user, is there any way I can make a full backup of my Java web app? Will a full backup from cPanel include the webapps folder? If so, sorry for not trying that earlier... Thanks again, keep up the good work! Martijn
Krydos Posted January 15, 2018 Posted January 15, 2018 The reason we append your username to your .war file before it's deployed is because otherwise we would have conflicts. Say one user deployed test.war and a second user then also deployed test.war the first one would be overwritten and suddenly user1.heliohost.org/test/ would change to someone else's site. To prevent this we append the username to the front of the file. test.war becomes user1_test.war or user2_test.war depending on who deploys it. Sometimes this name change causes issues within the .war file when it's hard coded to only work with one name. To get around this issue we recommend writing your .war so it will work with any name, but if that isn't possible for you just simply name it vukosyst_web.war yourself. If your .war file already has your username and an underscore in front it won't be added again. When you create a full backup anything in /home/vukosyst/ will be backed up as well. That is the directory that .war files are uploaded to prior to deployment. 1
vukosyst Posted January 15, 2018 Author Posted January 15, 2018 I understand what you describe. It's somewhat different than on our previous host: RHcloud/OpenShift v2. So I did what you suggested: I renamed the war file to vukosyst_web.war and deployed, but after deploying, cPanel still tells me the deployment location is /web and the wrong references are still there... It's great that the entire /home/vukosyst/ folder will be backed up, but we use a SQLite db in our servlet which is our most important object to backup as it changes over time. Will the .war file be updated accordingly? My simple knowledge tells me it won't, but I hope you prove me wrong. Sorry for keeping you busy! As soon as our webapp is fully operational, you won't hear from me again, I promise Thanks, Martijn
Krydos Posted January 15, 2018 Posted January 15, 2018 No, the sqlite database won't be backed up as the .war file isn't deployed in a location that your user has access to. We strongly recommend using a non-file based database system like mysql or postgresql.
vukosyst Posted January 15, 2018 Author Posted January 15, 2018 Ok, that's clear. And my other question? Renaming to vukosyst_web.war didn't make any difference...
Krydos Posted January 15, 2018 Posted January 15, 2018 Does http://inschrijven-vukamerorkest.heliohost.org/vukosyst_web/ work as expected?
vukosyst Posted January 16, 2018 Author Posted January 16, 2018 Yes, it does! What did you change? Can we deploy from vukosyst_web.war from now on? Is Tomcat able to find files in /home/vukosyst? If so, we can place the SQLite db there, otherwise we'll need to take care of a MySQL connection.
Krydos Posted January 16, 2018 Posted January 16, 2018 I manually edited the deploy.conf file. As long as you don't change the name of the .war file it won't overwrite my manual changes. If you do need to change the name just deploy it and then let me know and I can make the edit again. Yes, tomcat should be able to find files in /home/vukosyst/ but you'll need to have your permissions just right. Tomcat runs as a user named nobody which isn't in the group vukosyst, so you'll need to allow read and write for other. I don't think you need the execute flag for sqlite databases. Let us know if you need help with permissions. Most people find sqlite to be too much of a pain to set up so they switch to mysql which is much easier.
vukosyst Posted January 19, 2018 Author Posted January 19, 2018 (edited) Thanks Krydos! We tried to connect to our SQLite DB in /home/vukosyst (the db file received CHMOD 0666), but the webapp now gives a 500 error. Is the relative location /home/vukosyst/[dbname].db correct or did we perhaps make a mistake there? As we now have a (sort of) drag-and-droppable webapp that requires minimal configuration, we prefer to keep the solution with the SQLite DB. If it's not possible to connect to it from the web app, is it possible for you to - on request - copy the db file to a folder that we can reach as we cannot reach it within the tomcat web-inf folder? Edited January 19, 2018 by vukosyst
Krydos Posted January 19, 2018 Posted January 19, 2018 (edited) I just tested your database as the tomcat user and it should be able to read/write to the file. Are you specifying the full path to the database in your servlet? /home/vukosyst/<removed>.db Edited January 20, 2018 by Krydos removed database name
vukosyst Posted January 20, 2018 Author Posted January 20, 2018 Nevermind, we had an error in our code. I'm able to read/write to the db-file, indeed. Could you please remove/edit your previous post as others now also know the db-name and have access to it through Tomcat? Thanks for all the support. we're up and running now! Next episode: configuring a cron job that sends the db to an e-mail address once a week...
Krydos Posted January 20, 2018 Posted January 20, 2018 Thanks for letting us know that you got it working. Removed database name.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now