Spring Boot Micro-service fails Kerberos Authentication when deployed on Pivotal Cloud Foundry Platform - spring-boot

We have developed a Spring Boot Application to query data from Hbase on HDP 2.5.
The application works fine when we run it on our local windows machines as it is able to find the jaas.conf & krb5.conf file which have been kept under resources folder of the application and we have provided them as system properties in our code as e.g.
System.setProperties("javax.security.auth.useSubjectCredsOnly","false");
System.setProperty("java.security.krb5.conf","D:\\host\\workspace\\projectname\\src\\main\\resources\\krb5.conf");
However when we deploy in PCF it is unable to read those file which are set as system properties.
Question
What is the way to set environment variables in PCF ?
How do we place files in PCF so that they are available to the classpath of an application ?

You can specify an environment variable in your deployment manifest file.
Here are the details.
This is assuming your jar file was packaged with krb5.conf file.
The other option is to use Config Server. Here is an introduction on Spring Cloud Config

Related

Additional config file with Spring boot cloud config

I have a requirement to split application properties into 2. Some viewable from cloud and some hidden and specified by file on a Rancher environment.
When running locally the default config file successfully honors spring.config.import property which points to a different file.
When fetching the configs from cloud it seams the spring.config.import property is completely ignored and the additional file doesn't get loaded or even checked for.
It there a way to achieve this requirement? Even if different from using the spring.config.import property.
I have upgraded from Spring 2.1.7 to 2.7.7 to be able to use the latest application config loading.

How to make my spring boot application online on my domain?

I have recently learned how to work with Spring boot. Now, I have an application which works locally without any problem. Now, I would like to know how I can make it available as a website.
I have got a free web host from here and have followed the instructions to create a war file for my project. But I don't know what I should do with this war file and how I should use it to have my web page online.
In the meantime, my code is using Atlas Mongodb in it. Is using a database problematic? Should I consider something special for that?
Thanks in advance,
Shared hosting like 000webhost do not support Spring boot Hosting. As it was said earlier to host spring boot you have two choices either you host jar or war file. War is the traditional way of hosting it which needs Apache tomcat server and Jar is the Modern way which supports cloud based solutions. To host your solution you can create an account with AWS(Amazon web services) or GCP (Google Cloud Platform) and you will get free credits to use for a while or you can use Heroku(https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku) which is pretty much easier to use, its free also. For the database if you are using (https://www.mongodb.com/cloud/atlas) then you are good. All the best
If you are using Spring Boot, which have an embedded tomcat. You can just pack your project to a jar file, put the jar file to the server, and then simply execute it on the network interface that can connect to the outside world.
If you would like to pack your project as a war file, then you should first install the environment (application server) like tomcat, glassfish, jboss, etc. After that, you can deploy the war file on the application server.
Likewise, you should install the database server on your host, and edit the spring application.properties to let your spring application connect to the database.

Spring cloud config server not honoring logging.file property and not logging external file

I'm using spring-boot-starter 2.3.3.RELEASE version. I'm running my spring cloud configuration server in native profile (looking for configuration files in file system). I added
logging.file = /var/log/config.log in application.properties file. But my application is not logging logs to this file.(All other microservices are logging to this location). Am I missing any additional settings for Spring cloud config server? Thank you so much for your help.
In the spring boot 2.3.3 RELEASE documentation the logging properties that specify where the location should be is indicated using the property:
logging.file.path={path}
The documentation:
https://docs.spring.io/spring-boot/docs/2.3.3.RELEASE/reference/htmlsingle/#boot-features-logging-file-output
This modification from logging.path to logging.file.path appears as a deprecation in Spring Boot 2.2:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.2-Release-Notes#deprecations-in-spring-boot-22
One way to do it with spring-boot application is, setting it from command line argument as default it will dump every thing on console.
logging.file=logs/test.log
Old school but far effective, save path in application.properties
logging.file=logs/test.log

Passing configuration from yaml file to spring boot application without rebuilding it

How to pass configuration through yaml file to a running spring boot application so that there is no need of rebuilding the application and changes are reflected while the application is runnig?
I think this can help you:
How to hot-reload properties in Java EE and Spring Boot?
Take a look at Spring Boot Cloud Config. It allows you to manage your config files centralized and has the ability to push new configurations to the connected applications.

Can a Library jar read properties from Spring Cloud Config Server?

I have a shared Library that needs some properties from a .properties file. This shared Library will be used by a Spring Boot application. We already have a Spring Cloud Config server which is serving the properties to this Spring Boot application.
Now, we want the properties for the Library also to be fetched from the Config Server, rather than packaging it's properties file along with the library jar file.
Can I let my Library file pick-up properties from the Spring Cloud Config server ? The Spring Cloud Config server documentation states the following.. seeing it, looks like only a 'Spring Boot' application can talk to the Spring Cloud Config Server to fetch properties from there.
Any pointers or suggestions ?
can be used with any application running in any language
To use these features in an application, just build it as a Spring
Boot application that depends on spring-cloud-config-client
Ref: http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_client
No, a Library cannot talk to the Spring Cloud Config Server to get the properties file. Instead the config server should have those Library file's properties define din the using application's properties file.
Library: x.jar
Application: y.jar
Property file in Config Server: y.properties / y.yml
This property file will have the properties for classes present both in x.jar and in y.jar

Resources