springboot

 Failed to bind properties under 'spring.data.mongodb.password' to char[]:


    Reason: java.lang.IllegalStateException: either 'jasypt.encryptor.password', one of ['jasypt.encryptor.private-key-string', 'jasypt.encryptor.private-key-location'] for asymmetric encryption, or one of ['jasypt.encryptor.gcm-secret-key-string', 'jasypt.encryptor.gcm-secret-key-location', 'jasypt.encryptor.gcm-secret-key-password'] for AES/GCM encryption must be provided for Password-based or Asymmetric encryption



this issue resolved only after


manullay giving pass to application.proprties



Action:


for password only to encrypt pass


root@server2:/home/vms.krishit/web/vms.krishit.com/public_html/VMSApplication/VMS/src/main/resources# ls
application.properties  static  templates


root@server2:/home/vms.krishit/web/vms.krishit.com/public_html/VMSApplication/VMS/src/main/resources# cat application.properties 
jasypt.encryptor.password=@#$890@#$890JsonWebToken
spring.data.mongodb.password=ENC(JfKQfpA4gTn2sdQaFFHnAbUz85y56WTPdLKfZZGIlaJlvwgFKQ2XF2MJqhxLtiKS)
spring.data.mongodb.uri=mongodb://mongoAdmin2:${spring.data.mongodb.password}@192.227.112.108:27017/
spring.data.mongodb.database=KrishitDB_VMS_Dev
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username= maxvrnkatesan@gmail.com
spring.mail.password=ENC(ptQ8XQ0BOETsMGG3qU7mLglgA5qFwIm3ZSF4FmRFoOoYM9xyytARBcw/kFsCU/EGHq2Hp7/tgP2nElQvKdOj6Q==)
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.datasource.authorizationData =ENC(ZTYoU8na9RFfdZFBuYMbXWgv+w1vDyTQmVUC468bK0Z2x3nVttzn8NZosJtdh2w/culXabI5h6nI+CIbK9edVQ==)

VMS/src/main/resources/static tempaltes application.proerties


mvn jasypt:encrypt-value -Djasypt.encryptor.password='@#$890@#$890JsonWebToken' -Djasypt.plugin.value='h44qEBAXqs2'

the aove cmd will give encrypted password that needs to be replaced in 

VMS/src/main/resources/static tempaltes application.proerties



to decrypt pass

mvn jasypt:decrypt-value -Djasypt.encryptor.password="@#$890@#$890JsonWebToken" -Djasypt.plugin.value="ZTYoU8na9RFfdZFBuYMbXWgv+w1vDyTQmVUC468bK0Z2x3nVttzn8NZosJtdh2w/culXabI5h6nI+CIbK9edVQ=="

spring-boot-app-as-a-service

3.2. Systemd
The systemd service setup is very simple as well. Firstly, we create a script named your-app.service using the following example and put it in /etc/systemd/system directory:
[Unit]
Description=A Spring Boot application
After=syslog.target

[Service]
User=root
ExecStart=/path/to/your-app.jar SuccessExitStatus=143 

[Install] 
WantedBy=multi-user.target

Remember to modify DescriptionUser and ExecStart fields to match your application. You should be able to execute the aforementioned standard service commands at this point as well.

As opposed to the System V init approach described in the previous section, the process ID file and console log file should be configured explicitly using appropriate fields in the service script. An exhaustive list of options may be found here.

 vi /etc/systemd/system/springbootapp.service


[Unit]

Description=A Spring Boot application

After=syslog.target


[Service]

User=root

ExecStart=/usr/bin/java -jar /home/vms.krishit/web/vms.krishit.com/public_html/VMSApplication/VMS/target/VMS-0.0.1-SNAPSHOT.jar SuccessExitStatus=143 


[Install] 

WantedBy=multi-user.target



systemctl start springbootapp.service

systemctl status springbootapp.service

systemctl enable springbootapp.service

Created symlink /etc/systemd/system/multi-user.target.wants/springbootapp.service → /etc/systemd/system/springbootapp.service.

root@server2:/home/vms.krishit/web/vms.krishit.com/public_html/VMSApplication/VMS/target# systemctl status springbootapp.service


Failed to execute command: Exec format error


add shebang to the script

#!/bin/bash

or

Your spring-start.sh is executed by bash you need to explicit your ExecStart in springboot.service file like this : ExecStart=/bin/bash /home/ubuntu/spring-start.sh

Build jar and run spring boot from cmd


  1. In pom.xml add tag <packaging>jar</packaging>.
  2. you can build the maven project using command mvn package or maven install. It will create the .jar file inside target folder.
  3. run command from location where .jar is present - java -jar jarName.jar

Now you can access your system



----------------------

on 17 oct 2022

getting 404 after uploading some files in 

/home/vms.krishit/web/vms.krishit.com/public_html/VMSApplication/VMS/src/main/java/com/example/VMS_App/vmsController

had ro rebuild jar file specfied in springbootapp.service

/usr/bin/java -jar /home/vms.krishit/web/vms.krishit.com/public_html/VMSApplication/VMS/target/VMS-0.0.1-SNAPSHOT.jar SuccessExitStatus=143 


SockJsClient is disconnected

enable spring boot error log

/usr/bin/java -jar /home/vms.krishit/web/vms.krishit.com/public_html/VMSApplication/VMS/target/VMS-0.0.1-SNAPSHOT.jar > /var/log/springboot/error.log 2>&1
 2022-12-08 15:17:35.388 ERROR 2101 --- [io-8080-exec-10] o.s.w.s.s.s.DefaultHandshakeHandler      : "Handshake failed due to invalid Upgrade header: null"

vi vmsapi.krishit.com.apache2.ssl.conf

ProxyPreserveHost On
   ProxyRequests       Off
      ProxyPass / http://localhost:8080/
      ProxyPassReverse / http://localhost:8080/
RewriteEngine       On
    RewriteCond         %{HTTP:Upgrade} websocket [NC]
    RewriteCond         %{HTTP:Connection} upgrade [NC]
    RewriteRule         ^/?(.*) "ws://127.0.0.1:8080/$1" [P,L]


I finally managed to find the error. The order of statements in the apache.conf does matter! The working conf file looks like so:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName  app.myapp.biz

    ProxyPreserveHost   On
    ProxyRequests       Off
    ProxyPass           / http://127.0.0.1:8096/
    ProxyPassReverse    / http://127.0.0.1:8096/

    RewriteEngine       On
    RewriteCond         %{HTTP:Upgrade} websocket [NC]
    RewriteCond         %{HTTP:Connection} upgrade [NC]
    RewriteRule         ^/?(.*) "ws://127.0.0.1:8096/$1" [P,L]

    SetEnv mongo_username           aUser
    SetEnv mongo_password           aPassword
</VirtualHost>

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation