sts4 icon indicating copy to clipboard operation
sts4 copied to clipboard

Boot Dashboard build cannot locate files

Open navy1978 opened this issue 1 year ago • 13 comments

Hi, We encountered a perplexing issue while utilizing STS 4.21.0. Although the system generally (99% of the time) functions smoothly, we intermittently encounter an error when attempting to start a microservice from the Boot Dashboard. The error message is as follows:

Field mapper in xxx.yy.MyService required a bean of type 'xxx.yy.MyMapper' that could not be found.

Our project employs mapstruct, and the necessary Mapper is generated and located within the directory: target/generated-sources/annotations.

Interestingly, manually editing the file that cannot be found within STS resolves the issue temporarily, but the application subsequently fails to locate another required file.

Our suspicion is that the build process triggered when starting the microservice from the Dashboard becomes corrupted, resulting in an inability to locate these files.

Once this error occurs it doesn't go away (recompiling refreshing , maven update, restart of STS, whatever doesnt work), but strangely, executing the following command via the command line:

mvn spring-boot:run

Allows the microservice to start successfully. Upon stopping the service and returning to STS, starting the microservice from the Dashboard works flawlessly. It appears that executing the command via the command line initiates a process that somehow rectifies the issue.

It's worth noting that occasionally, instead of the previously mentioned error, we encounter the following:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'my.uri' in value "${my.uri}"
	at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180) ~[spring-core-6.0.15.jar:6.0.15]
	at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-6.0.15.jar:6.0.15]

This error suggests an inability to locate the application.properties file. Again it looks like the build cannot locate some files

Please be aware that this issue began occurring with the 4.21.0 version of STS, as we had no such problems with version 4.15.0.

Unfortunately I cannot provide the steps to reproduce this. I hope what I described makes sense to you.

Thank you so much for your work!

navy1978 avatar Feb 07 '24 18:02 navy1978

It smells a lot like then m2e issue consequences in Eclipse: https://github.com/spring-projects/sts4/issues/929. Do you mind giving m2e latest snapshot a try? (M2E snapshot update site: https://download.eclipse.org/technology/m2e/snapshots/latest/) Might solve your issue. Also Cleaning the project and building from scratch ideally should help as well.

BoykoAlex avatar Feb 07 '24 19:02 BoykoAlex

Thanks! Just installed I will keep you updated.

(FYI : till now Cleaning the project and building from scratch didn't help)

navy1978 avatar Feb 08 '24 08:02 navy1978

Thanks! Just installed I will keep you updated.

That is awesome, thanks for giving this a try. Would be extremely interesting to know whether this new m2e snapshot version solves this issue for you. Please keep us updated on that.

martinlippert avatar Feb 08 '24 08:02 martinlippert

Unfortunatlty it didn't work.

FYI:

  1. lanching the app from the Boot Dashborad produces again this error: _*************************** APPLICATION FAILED TO START

Description: Field mapper in xxxx.yyy.MyService required a bean of type 'xxxx.yyy.MyMapper' that could not be found. Action: Consider defining a bean of type 'xxxx.yyy.MyMapper' in your configuration._

  1. if I create a "maven build" in Eclipse/STS and I put: goals: spring-boot:run

this works fine, and it was working well even before having updated m2e to the latest snapshot.

This issue is a little bit frustrating because it doesnt occur all the time and it's complicated to provide the steps to reproduce it. Do you have other suggestions?

navy1978 avatar Feb 08 '24 14:02 navy1978

Hmmm... 🤔 If you startup the application via the dashboard and the error message appears, could you take a look at the target output folder and its content to see if there is anything missing from it? Maybe some files missing in that folder that you would expect to be there? (like application.prpoerties, .class files for the mapstruct generated sources, etc.) That might point us in some direction.

martinlippert avatar Feb 08 '24 14:02 martinlippert

The files are all there, but somehow STS/Eclipse cannot find them. FYI: once I got this error I have modified the created, modified and accessed date of all files in the target folder with a little software, this somehow made STS/Eclipse locate the files again and the app started form Boot Dashboard with no issue. I cannot guarantee this was not a coincidence . I will keep you updated.

navy1978 avatar Feb 08 '24 15:02 navy1978

Just a little update on this, I can confirm that using this little app: https://www.petges.lu/download/ and changing the created, modified and accessed date of all files in the target folder seems a workaround for this issue. At least it solved it 3 times in a row.

Anyway whould be nice to understand the cause ...

navy1978 avatar Feb 09 '24 17:02 navy1978

Just a little update on this, I can confirm that using this little app: https://www.petges.lu/download/ and changing the created, modified and accessed date of all files in the target folder seems a workaround for this issue. At least it solved it 3 times in a row.

This is quite puzzling. If I understand you correctly, you are changing the modification timestamp of the files with the tool you mentioned and then it works?

Another test here could be to run the application from the command line instead of the boot dashboard to see if just running java with the classpath and main class specified works fine or not (without modifying those file attributes upfront).

martinlippert avatar Feb 14 '24 16:02 martinlippert

Another test here could be to run the application from the command line instead of the boot dashboard to see if just running java with the classpath and main class specified works fine or not (without modifying those file attributes upfront).

There is a show command line button on the launch config dialog that would give you this command for your convenience.

martinlippert avatar Feb 14 '24 16:02 martinlippert

Another test here could be to run the application from the command line instead of the boot dashboard to see if just running java with the classpath and main class specified works fine or not (without modifying those file attributes upfront).

There is a show command line button on the launch config dialog that would give you this command for your convenience.

I cannot find this button , can you give me more info where to find this?

navy1978 avatar Feb 16 '24 18:02 navy1978

@navy1978 it is on the Java launch config not on the spring boot launch config (perhaps we should have it on the spring boot launch tab as well). Screenshot 2024-02-16 at 13 13 11

BoykoAlex avatar Feb 16 '24 18:02 BoykoAlex

Sorry I was busy and I had no time to test. In any case I didnt get what you were suggesting. If you wanted me to test the command executed by STS to launch the microservice, that Java launch config is not helping , I found an alternative way to see the command executed. Since I see the pid on the Eclipse console I can use this command in Window:

wmic.exe path Win32_Process where handle='<pid_in_the_window_console>' get name, commandline /format:list

this returns the command executed by STS to launch the microservice. I can try to run this from command line next time I will have the the issue, if is what you were suggesting...

navy1978 avatar Feb 28 '24 07:02 navy1978

this returns the command executed by STS to launch the microservice. I can try to run this from command line next time I will have the the issue, if is what you were suggesting...

Yes, if you run into the issue, it would be interesting to see if executing the command from the command line works while the IDE fails to launch the app. This is not meant as a workaround, just as another step in debugging this strange problem.

martinlippert avatar Feb 28 '24 09:02 martinlippert