Results 1 to 16 of 16
  1. #1
    Join Date
    Jul 2009
    Posts
    8

    Default Tomcat WAR deployment

    Hello,

    I have just purchased cPanel (copper) hosting & domain and I'm having trouble figuring out how I can setup / deploy a JSP web application using apache tomcat. I created a simple questionnaire that saves answers to a database, now all I need to do is deploy it so that everyone can access it... but I have 2 questions:

    1. My application makes use of a MySQL database and I have created one using my development machine. Everything runs fine locally. But how do I create a database using cPanel, and more specifically, how do I run the SQL script I have to create the tables?

    2. Once I have generated my war file, in which directory do I upload the file to?

    Sorry if these seem very trivial, but I am completely new to website creation and deployment.

    Thanks for your help

    Ko

  2. #2
    Join Date
    Sep 2008
    Posts
    101

    Default

    Hello,

    Your account is not hosted on Tomcat server, so you may need to open up a support ticket with our support dept to get your account migrated onto a server having Tomcat server installed..

    1) You can create database from cPanel. Please upload your mysql script on the server so
    we will execute it for you. You can also restore database from PHPMYADMIN.

    2) You need to upload .war file in public_html folder(/home/username/public_html). We have setup automatically deployment for any newly uploaded .war file. Once you upload .war file it will be deployed automatically. If any by chance it will not deployed then contact us. We will restart tomcat service for you.. so that it will be deployed manually..

    Regards,
    Eric

  3. #3
    Join Date
    Jul 2009
    Posts
    8

    Default

    Thanks for your help Eric.

    I've put in a support ticket. I'm sure I'll be back with more questions later.


    Regards,

    Ko

  4. #4
    Join Date
    Jul 2009
    Posts
    8

    Default

    hi,

    As I understand, my account has now been migrated onto a Tomcat server. I have uploaded my .war file into the /home/username/public_html directory as instructed. However, it doesn't seem as if the file was automitically deployed.

    www. strathegy .com still shows the default index page.

    Furthermore, I think I still need to make changes to my hibernate.cfg.xml so that it can properly connect to the correct database. But one step at a time first...

    Also, Eric, whereabouts would you like me to upload my SQL script to so that you will be able to find it and execute it for me?

    Again, I really appreciate the helpfulness of the support team here. It's encouraging for somebody that's as new to this as me.

    Thanks,
    -Ko

  5. #5
    Join Date
    Sep 2008
    Posts
    101

    Default

    Hello,

    I have deployed your application on the server. You can access it on URL

    Please upload mysql script or database backup file under public_html folder, so that i will restore it for you.

    Regards,
    Eric

  6. #6
    Join Date
    Jul 2009
    Posts
    8

    Default

    Hi Eric,

    That's me uploaded the create_tables.sql script as instructed.

    I assume that you had to manually restart the tomcat service in order to deploy the application? If so, wouldn't this be a little troublesome if I wanted to make changes to the application... which is very likely since I am still very much in the experimenting stages of app design... lol

    Also, how do I actually access my application? www. strathegy .com still points to default eukhost index page. I thought that once my application was deployed, then the index page in my .war file would automatically become the home page?

    Thanks
    -Ko

  7. #7
    Join Date
    Sep 2008
    Posts
    101

    Default

    Ok...Your database has been restored on the server.

    I have manually deployed your application on the server. Your script creates new Questionnaire folder so that we need to restart tomcat service manually every time to deploy your application.

    I have created new index.jsp page to point your Tomcat application. Please confirm site is pointing correctly to your application.

    Regards,
    Eric

  8. #8
    Join Date
    Jul 2009
    Posts
    8

    Default

    Hi Eric,

    Thanks so much for your help.

    Yes, I can confirm the site is now pointing correctly to the application.

    With regard to the .war file creating a new Questionnaire folder, I guess I could just upload the Questionnaire folder to the public_html directory uncompressed. Would this mean that no manual restart would be needed?

    Also, I've been having a look at the phpMyAdmin accessible from the cPanel, can I simple execute my sql scripts via that application? Again this would mean that I wouldn't need to bother you if I wanted to make changes to the database.

    Finally, now that my application is up and running, all I need to do now is connect it to the database. Correct me if I am wrong, but I think I need to update my hibernate.cfg.xml file located at /public_html/Questionnaire/WEB-INF/classes/com/questionnaire/core/hibernate to make it connect to the newly created database... Can you confirm this and do you know what parameters needs to be set?

    Thanks
    -Ko

  9. #9
    Join Date
    Sep 2008
    Posts
    14

    Default

    Hi Kwok,

    yes, you can execute sql scripts from PhpMyAdmin and changes done to the databases are reflected directly on the server , except for change of database username and password has to be updated in the configuration scripts, if any.

    Any updates that are done to Files under Questionnaire folder may require the manual restart of Tomcat service, in this case contact our Live chat support to have this done in a moment.

    We've also updated your ticket with all the database details.

    Thank you.
    Nancy J
    Linux Support Team.

  10. #10
    Join Date
    Jul 2009
    Posts
    8

    Default

    First I'd like to thank everyone for their help so far. The application is now accessible and connecting to the database.

    Problem I am now facing however, is trying query or save to the database.

    I get the following error message whenever I try to save.

    Code:
    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
    	sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    The application is written using Struts, JSP, and Hibernate to connect to a MySQL database. Everything works perfectly on my local machine. However, whenever I try to run it on the hosted site I get the above error.

    This is the code I use for saving to the database:

    Code:
    package com.questionnaire.core.manager;
    
    import org.hibernate.HibernateException;
    import org.hibernate.Session;
    import org.hibernate.Transaction;
    
    import com.questionnaire.core.dto.Questionnaire;
    import com.questionnaire.core.hibernate.HibernateSessionFactory;
    
    public class QuestionnaireManager {
    
    	public void saveQuestionnaire(Questionnaire questionnaire) throws HibernateException {
    		Session hibernateSession = null;
    		Transaction transaction = null;
    		try {
    			hibernateSession = HibernateSessionFactory.getSession();
    			transaction =hibernateSession.beginTransaction();
    			this.saveQuestionnaire(questionnaire, hibernateSession);
    			transaction.commit();
    		} catch (HibernateException he) {
    			if (transaction != null) {
    				transaction.rollback();
    			}
    			throw he;
    		} finally {
    			hibernateSession.close();
    		}
    		
    	}
    	
    	private void saveQuestionnaire(Questionnaire questionnaire, Session hibernateSession) throws HibernateException {
    		try {
    			hibernateSession.save(questionnaire);
    		} catch (HibernateException he) {
    			throw he;
    		}
    	}
    
    }

    Any help is much appreciated.

    Thanks,
    Ko

  11. #11
    Join Date
    Sep 2008
    Posts
    101

    Default

    Hi,

    I am updated for the same in your ticket. Please update me all required information in same ticket.

    Regards,
    Eric

  12. #12
    Join Date
    Jul 2009
    Posts
    8

    Default

    Just to update this thread and for future reference in case anyone faces a similar problem...

    Essentially the problem I was having was with my connection between my application and MySql database kept being disconnected. This meant that whenever my application tried to query the database an exception was thrown. Doing some tests, I found out that there is a session timer set on the server that closes any database connections that are open and that have been idle for 30 seconds.

    To overcome this problem, I used Hiberanate C3P0 to re-establish my connection whenever it detected it was lost.

    Just like to thank all the support staff at EUKHost for their help. And I especially want to thank Eric who has been on live chat looking over the problem with me and really going out of his way to help find a solution. Just want to apologise to him for appearing to have ignored him last night as I was trying to set-up myPhpAdmin on my local machine... it was my first time setting it up and it took me longer than expected.

    Cheers guys

  13. #13
    Join Date
    Jul 2009
    Posts
    16

    Red face tomcat war deployment fails

    hey guys

    my tomcat fails to deploy the webapp:it gives this msg:"fails to deploy...already exists"
    notes that in the directory of webapp of tomcat he creates the .war for this app but without the directory,(in normal case tomcat creates two directory:webapp and webapp.war)

    why tomcat refuse to deploy?

  14. #14
    Join Date
    Jul 2009
    Posts
    16

    Red face war deployment fails

    hey guys

    my tomcat fails to deploy the webapp with this msg:"failed to deploy ..already exist",
    but i noticed the server just creates after deploy one directory in webapp directory of tomcat,
    for example:
    in normal case:every web app has two directory in tomcat webbapp directory: web1,web1.war
    in my case:tomcat creats just one directory: webb1.war!!

    why tomcat dont creates the other diretory, and fails to deploy?

  15. #15
    Join Date
    Oct 2008
    Posts
    123

    Default war deployment fails

    Hi,

    When you have uploaded your .war file under your account then this .war file is automatically deployed within the few second . So you don't need to deploy it manually.

    Regards,
    Ronnie

  16. #16
    Join Date
    Jul 2009
    Posts
    16

    Exclamation

    hi ronie
    i deployed my application automaticaly not manually in tomcat web application manager-->browse-->deploy,
    but the the deploy fails for just this application!,other application are deplyed properly,
    Notes that when i changed the name of the application it was deplyed normally.

    so the problem for this application only.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •