Deploy Spring Boot jar to Azure, and make Azure restart - java

I build a Spring Boot jar on Jenkins, and upload through FTP to Azure, but since the app is still running, and I get error below. What is the recommended way to handle this on azure? I assume I somehow should shut the server down before uploading the jar, and start it again after upload.
..........
FTP: Connecting from host [ip-172-20-20-20]
FTP: Connecting with configuration [Back-End-Azure-FTP] ...
FTP: Disconnecting configuration [Back-End-Azure-FTP] ...
ERROR: Exception when publishing, exception message [Could not write file. Server message: [550 The process cannot access the file because it is being used by another process.
]]
Build step 'Send build artifacts over FTP' changed build result to UNSTABLE
Notifying upstream projects of job completion
Finished: UNSTABLE
Thanks in advance

One way of implementing this can be using spring actuator. They are documented here . They have a lot of handy instrumentation API and shutdown is one of the ways. You can drop in a simple POM dependency and that should do it (also enable shutdown in application yaml)
Before you run your FTP part , you will have to execute a post call through cURL to stop it and then deploy the new version package.

Related

How to package a spring boot project using spring data elastcsearch with maven without skiping test?

I'm putting together a spring boot project that uses spring boot elasticsearch, the plan is to package the project on my local machine as a .jar file, send it to my offsite server, and run it.
On my server, elasticsearch is set to accept connections via local network's ip addresses only (i.e. curl localhost:9200 won't work but curl 172.168.0.7:9200 does), which i'm not able to access on my local machine.
When i run the project, i set the elasticsearch uris in my yml files to localhost, and it works fine. But when i try to package the project with maven, it runs test, which then connects to 172.168.0.7:9200 and of course fails, leaving me with a failed message like can't connect to that address.
The workaround is to set maven to skip tests altogehter, but that does't seem to be the right way to do it.
What should i do so that i can package the project with test?
Did a little research and most of them were about unit test, but in my case i didn't write any test classes, don't have surefire, i'm just stuck in the process of packaging.

WebLogic: Unrecognized Callback

After migrating my JAVA EE app. (Spring Web model-view-controller (MVC) framework) from Ant to Maven I am getting this message while starting my app by WebLogic Server Version: 12.1.2.0.0
Error 403--Forbidden
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.4 403 Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable
I've extracted an ear that is working with the new ear that is not working and I don't see any differences. Only a folder (jsp_servlet) that is not present in the new ear
..\myApp\myAppWeb\WEB-INF\classes\jsp_servlet
I went to the console http://localhost:7001/console and login.
I invokeed the test page for the application using the console with the same result
/wls-cat/index.jsp (Classloader Analysis Tool on server myserver)
I see this error in the server logs
javax.security.auth.callback.UnsupportedCallbackException: Unrecognized Callback
at weblogic.management.mbeanservers.internal.JMXAuthenticator$JMXCallbackHandler.handle(JMXAuthenticator.java:135)
at com.bea.common.security.internal.service.CallbackHandlerWrapper.handle(CallbackHandlerWrapper.java:76)
at weblogic.security.service.internal.WLSJAASLoginServiceImpl$CallbackHandlerWrapper.handle(WLSJAASLoginServiceImpl.java:154)
at javax.security.auth.login.LoginContext$SecureCallbackHandler$1.run(LoginContext.java:947)
at javax.security.auth.login.LoginContext$SecureCallbackHandler$1.run(LoginContext.java:944)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext$SecureCallbackHandler.handle(LoginContext.java:943)
If you didn't change anything except ant conf file to mvn pom, make sure you clean the project and build that one more time from mvn command. I will suggest to use gradle for migration, because mvn and ant are slightly different. In gradle you can combine the both functionalities.

Magnolia CMS with Spring MVC maven project publish

When I want to publish my newly created Page in author mode, I got the following error in a popup:
error detected: Not able to send the activation request [http://localhost:8080/magnoliaPublic/.magnolia/activation]: cannot retry due to server authentication, in streaming mode.
I runned the project with mvn jetty:run-war. The maven projects are based of the "Getting started with Blossom" magnolia tutorial.
Could it be because you have just single instance? Go to Configuration App, there in the tree to /server/activation/subscribers/<your subscriber>. Under subscriber, check the url it points to. Most likely it is invalid. If yes, you can just switch off the subscriber by setting its enabled value to false. That way you disable publishing completely.

How to debug war dependency?

I am working on a web-app front end (spring mvc) which depends on war file (created also by me).
Both module web and core communicate via REST (Jersey).
Both modules are separate maven projects.
On some occasions during development I screw up something in the core and exception is thrown. Many times I need to setup a breakpoint there and trap the issue.
The problem is: I start the debug when running the web-app fine. But will never stop on any breakpoint in core (doooh). (core is build using maven package command, to generate war file).
I could start only the core and debug it. Problem some complex functions expect many attributes (form object json format).
Any ideas?
Tnx
Start the core on debug mode, if you can do this in your IDE then you are all set, otherwise you can set up your IDE for remote debugging, There are instructions to do this for popular Ide's. Set up for eclipse, Set up for Intellij
You can debug the core and start web-app regularly and make it send the request you want to debug on the core side.
Have the core source code open in your IDE. Configure it for remote debug of the JVM that the servlet container/app server is running the app. Enable remote debugging on the servlet container/app server. Start the server, start the remote debugging in the IDE. Set a break point and enjoy.

"Error invoking method check" when deploying a WAR on Tomcat

When I deploy my WAR generated with Ant on my local system (copy/paste under /webapps), everything works fine.
The thing is, when I deploy the WAR on a remote server for test purposes, I got this error message:
There was an error thrown by Tomcat during deployment: "Error invoking method check". This however may not mean that you application failed to deploy. Please check the status in the application list
But the application is not deployed at all.
I have to use Probe (lambaprobe.org) to manage and deploy applications on Tomcat on the remote server I'm talking. And I don't have access to the filesystem, only probe.
Any idea would be much appreciated!
Thanks
I often encountered this problem and after checking the log this was caused by an OutOfMemoryError with tomcat
Impossible to check the log... We managed to restart tomcat and it works now.
Weird.
Thank you anyway!
Check the log files of tomcat; they contain the full error message.
If you can't access them easily, write a small webapp which allows you to browse and/or download the logs and deploy that.

Categories

Resources