I created 3 servers for Tomcat (ip is x.x.x.10), web (ip is x.x.x.11) and db (ip is x.x.x.12). These 3 are co-ordinating manually. I gave full access to Tomcat server to create tables in database server. If I'm connecting manually from tomcat server to database server, it is working perfectly.
Then I created a Jenkins job for deploy war on Tomcat server.
In my svn server, I kept database server (x.x.x.12) info in "jdbc.properties" file and committed. My "jdbc.properties" file looks like below.
jdbc.driverClassName = com.mysql.jdbc.Driver
jdbc.dialect = org.hibernate.dialect.MySQLDialect
jdbc.databaseurl = jdbc:mysql://x.x.x.12:3306/epsilon
jdbc.username = mysql
jdbc.password = mypassword
Then I'm running job on Jenkins to build war and deploy on Tomcat server. Jenkins not showing any errors and job ran successfully.
But in Tomcat server catalina.log file showing that there is no permission to create database on x.x.x.10. But I kept x.x.x.12 in "jdbc.properties" file. Why Tomcat server assumig that as a database server is it self and why it is not considering "jdbc.properties" file.
I removed Jenkins workspace and job plugins. But still issue is same.
You should review your build process and the generated binaries to make sure that the application package (ear, war, whatever) contains precisely the properties file you have pasted and not a local development version.
For example, if you had a Maven project based on profiles (LOCAL, AVE, UAT, etc.) and you had built a binary specifying LOCAL profile instead of any other, then you would be finding similar effects when trying to deploy it to your tomcat server.
Finally, I found root cause for this. I.E., spaces issue in configuration file. While creating your jdbc.properties file with scripts / manually please check spaces at last of your values. Don't keep any space for db username and pass and db hosts name etc..
Related
I've been developing a Java Web Project in IntelliJ IDEA - it consists of a few Java classes for logic, a few JSP files for the web-based UI, and uses a MySQL database - all hosted on my own computer (MySQL server for the database, and Apache Tomcat 9 for the web app).
How would I export this project, including the database, so I can set up a dedicated machine (say a desktop running Ubuntu Server or Debian, or even a Raspberry Pi, perhaps) to run it?
I've done some research on this, and what I've found is that I need to export a WAR file, but I can't seem to find that option in IntelliJ - all the guides I found were focused on Eclipse. I also have no idea what to do about the database.
To setup dedicated machine for your application, you need to install web server(ex. Tomcat) and MySQL server on a machine.
Make sure that, when you are creating database connection in your WEB application, the MySQL server details should not be hardcoded. I would suggest you to use properties file to store Database details and use them for database connections.
Ex.database.properties
mks.dynamicPool.config=\
url=jdbc:jtds:sqlserver://[yourmachinehost]:[SQL Server port]/[yourdatabase name];useCursors=true,\
driver=mks.frame.sql.jdbc.mssql.Driver,\
initialCapacity=5,\
maxCapacity=100,\
testTable=VersionIdentity
mks.dbUser=user1
mks.dbPassword=user1
To create war file of you application follow the steps :
Click on Edit Configurations.
Click on Deployment and add your artifact.
Apply these changes.
You can see a Build Artifacts under Build.
Click on Build Artifacts and it will create a war/jar to the respective folder.
To deploy your application into tomcat server,
Copy/Extract your war file into [TomcatInstallDir]/webapps
To import and export your database:
I hope you have set MYSQL Server into your path.(if not then set using command: set path=c:\wamp\bin\mysql\mysql5.1.36\bin)
i. To export database, following command can be used:
mysqldump -u YourUser -p YourDatabaseName > dumpfilename.sql
Note: This command should prompt you for password and with correct password it would export the database.
ii. To restore/import above exported database use following command:
mysql -u YourUser -p YourDatabaseName < dumpfilename.sql
Update your database.properties file with your new Database details and start the tomcat server.
Install on your dedicated server MySQL and Tomcat.
Import your database into sql script and export it into dedicated server.
After that use some build automation tools, maven or gradle for example to build war package and deploy it (copy to ../tomcat/webapp directory)
Do you use some web-based framework?
I have made a project and I made it online through Openshift.My project is still online on openshift URL http://easynote-sansari.rhcloud.com/ , but due to mistake is deleted from my local server.
I want to get back my project in my local server for further improvement. Please help me to get my project back from Openshift.
thanks in Advance.
Depending on how you uploaded your project to OpenShift Online, you have a couple of options for recovering your files.
SCP/SFTP : You can use a file transfer program that supports the SCP or SFTP protocols to download the files for your website, which should be located in your ~/app-root/repo directory.
Git : If you were using Git to add/push your files to your OpenShift online application, you can re-clone your application to your local machine using the rhc git-clone command.
Download an Archived Backup : You can use the rhc snapshot-save command to created an archived backup of your application, which will then be downloaded to your local machine. You can then decompress the archive and extract your files.
I am new in web development, please help about the uploading the java website on live server with mysql database.Please tell all the steps.
It you want to test your application on live server.
Try it with Jelastic, a free trial for 2-weeks which gives you better understanding on deploying and testing your java web application on live server.
Unrelated
If you are using JBoss Application Server 7, deploy your application over LAN network (deploy on 1 system and access from any other device)
Export your application in EAR or WAR from IDE
Just copy and paste you WAR/EAR file in deployment path like(D:\jboss-as-7.1.1.Final\standalone\deployments)
open cmd, change directory to bin folder of JBossAS7
Write command standalone.bat -b 0.0.0.0
Access your application like: http://192.168.1.9:8080/YourApplication
Obviously put your own PC's ip over here. Hoped helped. It gives you an Idea of hosting
To deploy java on live server
firstly convert your java project to war file. Then rename it to root.war.Now open the tomcat manager provided by hosting service provider.Browse the root.war file and deploy it.
Secondly,for mysql db... Create mydb.sql file.Now go to your cpanel and create the database .And after that add the username and pass to myconnection utility java program.Now in cpanel go to phpmyadmin ,Click on the db created and import the mydb.sql created.And now you have successfully deployed the java project.
I am able to get the spring blazeds examples and war (http://docs.spring.io/spring-flex/docs/1.5.2.RELEASE/reference/html/#pre-built-samples) working locally in tomcat 7 webapps directory (i initially had problems with this but now it works fine locally), however when I upload the same war file to amazon ec2, tomcats starts up fine and i can see the project's index page but none of the projects scripts are executing. According to the catalina.out log, the server started up successfully without any errors. Please help.
thanks,
tone
*Update
I am assuming that the problem resides in the blazeds portion of the project? Not sure if it is executing properly. i have enabled ports 8080 and 8400 in the security group.
Nevermind I found out the issue. i had to recompile the swf files that comes with the project to point to my ec2 instance url instead of localhost.
I have CruiseControl.net setup on a machine which is currenly being used for Microsoft Projects.
I needed to add a java project to the same build server.
The java war files generated need to be copied to another server under Tomcat.
However, I face a lot of problems when it tries to copy to that network location, due to file access denied messages, as certain jar files are being used.
I tried to remotely stop tomcat before attempting to copy the files but wasnt successful doing that.
There are Ant tasks that allow you to admin Tomcat using build.xml. Maybe those can help.