I am doing migration using flyway. I have used flyway configuration file which can be changed based on environment (dev/test/prod). But for application I am using JNDI lookup for database connectivity in tomcat's server.xml file.
But the problem is I want to make it common for both flyway and application so that we don't make mistakes to change some configuration at one file and forget in another one.
Also I am looking for a solution which can be applied with any Java or PHP application irrespective of framework used(e.g. spring)
Any help???
Related
I have a springboot project with default structure. I have an excel file under resources/data. My program need to load excel file and dump data into different tables from each sheet.
When I run from Eclipse, program loads excel file correctly and everything looks good. However, when I deploy the same App on Docker, it fails to read the File from resources.
Have anyone encountered this issues? How have you solved it?
First of all try to check whether the Docker is a reason, or there is an issue with java code. Spring boot creates an artifact that can be run with just java -jar <your-spring-boot-artifact.jar>
If this doesn't run even without docker, then you should change the way you access Excel files from spring boot application (your java code):
if the file is in resources folder, it should be packaged into the spring boot artifact.
In this case, you have to use getClass().getResourceAsStream() to access the file, and not rely on java.io.File API, because File API doesn't allow working with files inside a Jar, its not a regular filesystem.
My Grails app is based on
Gradle with Grails 2.4.4,
Tomcat plugin 7.0.55,
and MySQL plugin(mysql:mysql-connector-java:5.1.29).
Do I need to install Tomcat on the server?
Do I need to install MySQL on the server?
Both Tomcat and MySQL are not installed on dev environment(on my PC), but it seems working.
Container
While all the other answers pointed out, that you need already a container (which of course is true) there is also the option to use one of the "standalone" plugins (like e.g. https://grails.org/plugin/standalone). This will package your app as a fat jar, where the container and your app are part of a jar, that you simply run by java -jar myapp.jar (of course your would integrate that into your regular startup scripts on the server).
This is in general no bad option, since many WAR-deployed apps don't need any of the full blown container features anyway and you would be able to configure everything in place for your workload and don't have to compromise for all running wars (or your ops team). On the downside, if there is a security problem etc. with the container you would have to roll a new jar.
/With grails 3, which uses Spring Bootstrap, this even is a default option, since the preferred way of deploying. Spring Boot 1.2 supports Tomcat, Jetty, and Undertow by default./
Database
You can use a MySQL from "somewhere" else. But this is nitpicking, since you really need a MySQL somewhere (BTW: you really should start using MySQL also for your dev env, or you will be in for a few surprises once you put your stuff over to production).
Also be aware, that you can also keep using your H2 (see your datasource config) with files. This is an OK option (that saves you from installing a DB server) for small amounts of data you are storing and also there are other free database servers like PostgreSQL.
Obviously you have to install mysql and tomcat on the server.
During development you run grails from console, so you dont need tomcat as it will use embedded tomcat but still you need to have mysql installed, if you want to use mysql.
But on production, you create a war of your app using 'grails war command' and you deploy this war to a web container just like any other war, so you need tomcat and you will need mysql installed too.
In one word answer is 'Yes'.
Fact is when you are in development environment grails uses as an embedded tomcat server provided by the 'Apache Tomcat plugin' which version corresponds to grails version.
You've not installed mysql and you claimed 'it seems working'. That's funny! But it's not mysql who is working without being installed(!), rather it's also an integrated database provided by the 'H2 Database Plugin'.
So, when you'll deploy your grails app in Linux or another server certainly you need a tomcat server to handle user request to that app and a database where your data will be saved.
I am trying to deploy my grails application on an openshift server. I have created an instance using command "rhc app create MyApp jbossews-2.0". When I ssh to the server, I see a jboss folder but no tomcat folder. How can I deploy my .war file onto the server?
I think the Docs on how to deploy a binary file will help you with this, however what the docs do not say is that with Tomcat the deployments directory is called webapps but they work the same way (except for the marker files, tomcat does not use those).
You may want to check out https://github.com/gssOpenShiftsupportExamples/JavaSample as it shows an example of how to do this with JBoss (the same thing will work for Tomcat if you change the directory as denoted above).
I am following this tutorial on Grails and Cloudbees And it says :
"to use CloudBees databases locally from your application, you first need to add the CloudBees SDK's appserver.jar file to your grails classpath"
Does anyone know what is this appserver.jar? Where can I find it?
Yes, as mentioned in the comment - you can get that jar file from the SDK you download.
However, it is perfectly find (and possibly better) to use the mysql driver directly as mentioned.
When running on cloudbees, you can bind your app to a database - so that at runtime the right database is injected - using the bees db:bind SDK command.
I want to have a automatic deployment of my test system on every night to the dev#cloud system of cloudbees.
The problem is now that I use the dbm-update goal on grails and its trying to update the database from Jenkins. This is a problem because the com.cloudbees.jdbc.Driver is not available in this context. Only if the app is deployed to the test sytem.
Does somebody tried this already and can help me out with some tips how to solve or workaround this problem?
Thanks
You can set the updateOnStart flags in the plugin for your application in the test context,
grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']
This will run the migrations when your test application starts, making you not need to do a separate dbm-update. Since this uses the same JDBC drivers as your running application, it should work.
Look at the RUN console (https://run.cloudbees.com) - there you will find your MySQL settings
You can just use a standard MySQL JDBC driver to connect to the MySQL database from anywhere (including from DEV#cloud and your test cases).