womd
womd

Reputation: 3453

Spring CLI v2.1.0.RELEASE - encrypt -> NoSuchMethodError

when i run:

spring encrypt totallysecretpassword --key=insanity

Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) Caused by: java.lang.NoSuchMethodError: org.springframework.cloud.cli.command.encrypt.BaseEncryptOptionHandler.option(Ljava/util/Collection;Ljava/lang/String;)Ljoptsimple/OptionSpecBuilder; at org.springframework.cloud.cli.command.encrypt.BaseEncryptOptionHandler.options(BaseEncryptOptionHandler.java:53) at org.springframework.boot.cli.command.options.OptionHandler.getParser(OptionHandler.java:68) at org.springframework.boot.cli.command.options.OptionHandler.run(OptionHandler.java:83) at org.springframework.boot.cli.command.OptionParsingCommand.run(OptionParsingCommand.java:54) at org.springframework.boot.cli.command.CommandRunner.run(CommandRunner.java:219) at org.springframework.boot.cli.command.CommandRunner.runAndHandleErrors(CommandRunner.java:171) at org.springframework.boot.cli.SpringCli.main(SpringCli.java:63) ... 8 more

i re-installed JCE as told here: https://cloud.spring.io/spring-cloud-cli/

basically, what i want is this: https://blog.novatec-gmbh.de/encrypted-properties-spring/

but in 1.3.2 it was the same error, so i used the latest ... but still no success ... what am i missing ?

-- did not get to run 2.0.8's encrypt on my windows box, @jtim 's answer wored for me when doing that on an ubuntu-box !

Upvotes: 1

Views: 3495

Answers (4)

Zafrullah Syed
Zafrullah Syed

Reputation: 1268

Use lower version of Spring boot cli. The following configuration worked for me:

Springboot cli version: 2.1.6.RELEASE

Create System variable,

name: SPRING_HOME

value: C:\Users\zafrullahsyed\Downloads\spring-2.1.6.RELEASE

Add the bin folder to System path: %SPRING_HOME%\bin

Open CMD as admin else the jars are not created on spring-2.1.6.RELEASE\lib\ext folder

Check the Spring --version

Spring CLI v2.1.6.RELEASE

Then install sping cloud plugin:

spring install org.springframework.cloud:spring-cloud-cli:2.1.0.RELEASE

spring encrypt mysecret --key foo

Encrypted value: 1c656a1a4617146a7e76d977ca5fa2cfeb0afecc5655677193f53ab43578dd4d

spring decrypt --key foo 1c656a1a4617146a7e76d977ca5fa2cfeb0afecc5655677193f53ab43578dd4d

Decrypted value:

mysecret

Upvotes: 1

reflexdemon
reflexdemon

Reputation: 902

I too bumped to this issue and here is what I did,

# Step 1: Download the binaries to install (https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/)
$ wget https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/2.0.8.RELEASE/spring-boot-cli-2.0.8.RELEASE-bin.tar.gz

# Step 2: Extract the tar.gz
$ tar xvf spring-boot-cli-2.0.8.RELEASE-bin.tar.gz

# Step 3: Enable execute permissions
$ chmod +x spring-2.0.8.RELEASE/bin/spring

# Install Spring Cloud
$ spring install org.springframework.cloud:spring-cloud-cli:2.0.0.RELEASE

# Step 5: Add it to your PATH
$ cd spring-2.0.8.RELEASE/bin
$ echo "PATH=$(pwd):\$PATH" >> .bashrc or  .zshrc

This usually works for Mac and any Linux based systems. I have personally tried this on Mac and Linux Mint

Output:

$ spring encrypt totallysecretpassword --key=insanity
f5a7944890c871ef58971eeaf123bbc750727b012cce8f7072def5bf71b000fb00089e106775ac0306b5f15b8f17d233

Hope this helps someone.

Upvotes: 0

jtim
jtim

Reputation: 246

Just ran into the same problem. Using Sdkman you can quickly downgrade to a version that works fine:

sdk ls springboot
sdk use springboot 2.0.8.RELEASE
spring install org.springframework.cloud:spring-cloud-cli:2.0.0.RELEASE

Upvotes: 4

James Lan
James Lan

Reputation: 266

It is a breaking change from spring-boot-cli. Just wait for the release of a compatible version of spring-cloud-cli (the request of the new release).

Or you could install an older version of spring-boot-cli that doesn't have the change, such as 2.0.8.RELEASE

Upvotes: 4

Related Questions