Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boot Dashboard build cannot locate files #1186

Open
navy1978 opened this issue Feb 7, 2024 · 13 comments
Open

Boot Dashboard build cannot locate files #1186

navy1978 opened this issue Feb 7, 2024 · 13 comments

Comments

@navy1978
Copy link

navy1978 commented Feb 7, 2024

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!

@BoykoAlex
Copy link
Contributor

It smells a lot like then m2e issue consequences in Eclipse: #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.

@navy1978
Copy link
Author

navy1978 commented Feb 8, 2024

Thanks! Just installed I will keep you updated.

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

@martinlippert
Copy link
Member

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.

@navy1978
Copy link
Author

navy1978 commented Feb 8, 2024

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?

@martinlippert
Copy link
Member

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.

@navy1978
Copy link
Author

navy1978 commented Feb 8, 2024

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
Copy link
Author

navy1978 commented Feb 9, 2024

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 ...

@martinlippert
Copy link
Member

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
Copy link
Member

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.

@navy1978
Copy link
Author

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?

@BoykoAlex
Copy link
Contributor

@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

@navy1978
Copy link
Author

navy1978 commented Feb 28, 2024

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...

@martinlippert
Copy link
Member

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.

@BoykoAlex BoykoAlex modified the milestones: 4.22.0.RELEASE, Backlog Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants