How to specify JDBC URL in spring boot application in case of the MySQL running as a Kubernetes Service? - spring-boot

I have a java application with maven build. I have provided the k8 service name of the mysql in the application properties of the spring boot application. However, I get error as unknown host and the maven build fails. How do I overcome this?
Application properties:
spring.datasource.url=jdbc:mysql://mymysqlk8servicename/testdb
When I build the application using mvn clean install, the build fails with error as java.net.UnknownHostException.
For the record, I am running the maven build in the master machine of the Kubernetes cluster. Should I run the java application only as a Kubernetes service? Is it possible to just run the java application without deploying in the Kubernetes cluster?

If you do
kubectl get service
You should be able to see the servicename. Pay attention to the port too.

Related

Debug Spring Boot app from Intellij where service is started in a multi service docker-compose file?

I have a docker-compose YML file that includes multiple Spring Boot apps.
Is it possible to debug one of these Spring Boot apps from Intellij?
I guess it depends how the apps are started within the Docker container. One option could be starting the application in debug mode with the following in the Dockerfile of the app you want to debug:
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar myApp.jar
Remember to build your container again and then attach a remote debugger with IntelliJ to the port 8000.

Jhipster Webpack failure for Jhipster Maven Microservice Gateway application in Dev environment

I have generated a Sample Microservice application and a Microservice gateway application using Jhipster. Both applications are built using maven and are using Jhipster registry for identification and routing. I am successfully able to build the Micro service application and able to reach it in the assigned localhost port.
I have build issues while building ./mvnw for gateway application. But it builds properly for gradle application and the API's are up. I have issues only for maven in org.springframework.boot:spring-boot-maven-plugin:2.0.5.
Its running on Windows 10 machine, latest version of Jhipster.
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.5.RELEASE:run (default-cli) on project api-contact-gateway: Could not exec java: Cannot run program "C:\Program Files\Java\jdk1.8.0_181\jre\bin\java.exe": CreateProcess error=206, The filename or extension is too long
I have debugged further and could see that the Classpath passed as a part of JVM arguments is too long. But my system variables are properly set.
I coudn't find any specific solution. I just lowered my Jhipster version to 4.14

How to use Websphere liberty in spring boot application

I want to use Websphere liberty in spring boot application instead of tomcat server. If I am correct it is not supported out of the box. How can I configure spring boot/websphere liberty to achieve this?
Using the Liberty app accelerator you can download a zip containing a Maven buildable 'Spring Boot with Spring MVC' app as your starting point. Just run mvn install and you'll get the app running at http://localhost:9080/myLibertyApp/
Actually, you can now create runnable jar files with WebSphere Liberty. You need v8.5.5.9 or higher. Create a runnable jar this way:
server package {server name} --archive={jar name}.jar --include=minify,runnable
Resultant jar can be run as you'd expect:
java -jar {jar name}.jar
Since very recently (May 2018) you can deploy a Spring Boot jar with Liberty, as it seems. See https://developer.ibm.com/wasdev/blog/2018/05/11/spring-boot-applications-on-liberty/. Haven't tried it out yet, though.

Spring Maven rest web service - What is the URL when deploying on real web server?

I followed this tutorial https://spring.io/guides/gs/rest-service/ by creating maven project in intellij, addind pom.xml etc. Then I run on localhost exactly as written in the tutorial and all works:
http://localhost:8080/greeting
When greeting came from the annotation of method in the controller #RequestMapping("/greeting").
Then I made JAR artifact & deployed it to Tomact on 'real server' (Elastic beanstalk environment running EC2 instance on AWS).
I got from AWS the base URL of my webserver running Tomact. What is now the suffix to my service? This is NOT working:
http://someEnvironmentName.elasticbeanstalk.com/greeting
EDIT: How I made the artifact JAR
In intellij I can compile & run maven project and then test it in localhost. So what I did:
Right click on the project name->Open Module Settings->Artifacts->Add->Jar
Build->Build Artifacts->Selecting the Jar from above
Maybe I need to build WAR? And how to deal with the POM.xml? Now my pom is exactly as in the linked tutorial.
Thanks,
If you use spring-boot, you donĀ“t need a tomcat because spring include an embedded tomcat. Only you run the application with Maven. So, the advantage of spring-boot is not dependent on an application server and using other containers such as Docker.
Do you put the port in the call to your webserver?
On the other hand, check your server logs to see if there are any problem.
Solution (Thanks to #JBNizet suggestion):
Follow this link http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
Modify the Application.java file
Modify the pom.xml (By adding one more dependency)
Then if you are using Intellij IDE under Build->Build Artifacts will be automatically option for WAR file.
Just deploy to AWS elasticbeanstalk instance running EC2 in the usual way. The URL is:
http://someEnvironmentName.elasticbeanstalk.com/greeting

Deploy to weblogic using maven and jenkins

We are using Jenkins in our project for build and deployment on dev environments. I have sucessfullly created a war file using maven in jenkins and now I have to create another job to deploy that war file into the weblogic server.
However, I am not aware of the required steps for configuring this job in jenkins. Will it be a matter of just invoking a maven deploy command? Can some one please tell me what will be the required steps to deploy a war file into weblogic 10.3.5 using jenkins?
edit : The approach we are following is after creating the war file we are cheking the war file created into svn and then the deploy job will take the war file from there and deploy it into the weblogic. Does some one thing there is a better way of doing thhings than this?
Thanks,
Manish
Use the Jenkins "Weblogic Deployer Plugin". This will do the deployment for you. All you need to do is specify:
Task Name: Give the deployment a name; Eg. Webapp WL Deployment
Environment: Specify the environment you are deploying to. Make sure you are using the AdminServer port number and not the Managed Server port number; default is 7001
Name: The name weblogic should use for your webapp to display the deployed component
Built resource to deploy: The file name of your webapp. You can use also use regular expressions for this
Targets: The name of the managed server you want to deploy the webapp to
Weblogic libraries: Whether or not the webapp should be deployed as a library component.

Resources