I'm trying to dockerize my spring boot app and then connect it to a mongodb docker container sitting at 172.17.0.2:27017.
Sadly when the ./mvnw clean package tries running the app, it fails while trying to connect to the container at new MongoClient("172.17.0.2", 27017) (since it cannot connect form localhost perhaps), and so the JAR file is never created.
I believe if I could somehow put my app in a docker container, it might connect to the mongodb container (since another mongo container instance can connect to the first one. see docs) .
So the question is that is it possible force spring boot to create the Jar without running the app itself?
probably you have a test with #SpringBootTest annotation.
To generate JAR file you can try to do ./mvnw -DskipTests=true clean package
Related
I am using latest Jhipster vesion v7.0.1 and generated monolithic client application [angular] and separate monolithic server application.
I want to create separate docker image for these two application.
But observed that Docker Folder is not generated in client application.
Can any one please help me here to achieve this dockerization.
I have an error in application deployment with "git push master heroku" while locally it works fine.
I want to use my persistence.xml for access to my data base of H2 (I will be use maybe PostgreSQL) all with my data source on WildFly 10.
I found no reference other than the Spring. (I can not use it)
Thank you!
I've deployed JavaEE web app (with jsf, javabean, ejb, di etc) on Heroku. Heroku will allow you to run shell script for starting your application like class with a main method or executable .jar file. Not on the pre installed fullstack application server. Also if you gonna run java app on Heroku your project should be maven.
To make it work from command line you can use cloud ready run anywhere tiny servers like payara-micro, wildfly-swarm, spring-boot. It turns your app and server into single executable jar (Uber JAR). Also tomcat and jetty have wrappers for build uberJar.
I use payara-micro and it's great that very little jar can run almost all of JavaEE features with session replication. Follow this link for instructions payara-micro how to (read also maven parts).
When you git push to Heroku(with heroku cli tool) it will automatically builds your project and run script from file called Procfile from your project root directory. Sample procfile:
web: java -jar target/myapp.jar --port $PORT
Consider $PORT part from above snippet. When Heroku runtime (dyno) starts it will open random port (I think so) and bind to $PORT environment variable. So here I'm passing that accessibe port to payara-micro server for listen. Other mentioned servers should work with similar procedures. You can find documentations at heroku devcenterr
For JPA and database connectivity Heroku provides JDBC_DATABASE_URL and DATABASE_URL environment variables that have connection information (url etc) for you to connect database. I couln't find the way to hook up those variables into persistence.xml. But you can create and configure EntityManagerFactory and EntityManager programmatically.
Hope it helps.
I'm working on apache camel's fuse project .
I'm trying to deploy my application by Fabric8. I have installed all the stuffs required .
I also created a container . i deployed my application via the command
fabric8:deploy
On the web-based console, after creating a child container (under the root container) i found out that container not running even the start button for this child is disabled so i could'nt run it.
What should i do ?.
What things have to taken care for deploy a web appl ( war ) in glassfish v3.1.1 ( glassfish-3.1.1-web-windows.exe installer ) , the appl. is developed using netbeans 7.0.1. I am using postgresql database . Developement machine and Production machine is different and is not connected to each other. Any detailed step by step instruction ?
It all depends on what resources your application would need to run successfully on the application server.
e.g. If your application uses container managed persistence then you have to make sure that you create the required JDBC connection pool and resource on the server before you can deploy your application server. If you check the persistence.xml file you will see if your application uses some jta-datasource (the value provided there is actually the JNDI name of the JDBC resource created on the server). Here you might also have to supply the required JDBC driver to the server if it is not package within the application.
What you can do is install the same application server on your local machine and deploy the application there and see if it fails. If it fails then you can check the stacktrace to find out the reason for failure.
Is there a way to embed mongodb in the java application instead of running a daemon.
I have downloaded mongodb jdbc drivers and added them to classpath.
You can not embed mongodb in the java process. It is a separate process.
You can start and stop it when your program starts/stops by spawning the process. This is generally not suggested as mongodb is meant to run as a background server; if you do this is probably best you pick a random port to start it on so it doesn't affect any other mongodb instances. You will also need to make sure you include the correct binaries for the platform your java app is deployed on since it requires more than the JVM.
In java unit tests we can use Test Containers to spawn a Docker container with embedded MongoDB.
See autoconfiguration for Spring Boot projects: https://github.com/testcontainers/testcontainers-spring-boot#embedded-mongodb