How to troubleshoot IDEA's own error? | Take the problem that IntelliJ IDEA 2023.1.4 cannot refresh the project Maven module as an example

This problem was encountered on July 26, 2023. At that time, it was still IDEA 2023.1.4. As a result, the article was not finished yet, and IDEA 2023.2 was automatically updated on July 27. The problem is estimated to be resolved.
Therefore, this article simply mentions the troubleshooting method of IDEA's own error reporting.

Avoidance/solution

Let me talk about how to deal with the problem first:

IDEA settings changed from Maven wrapper to use built-in Maven.
insert image description here

Troubleshooting steps

After the Maven project module is adjusted, IDEA does not correctly identify the new module

There are some adjustments to the Maven module of the project, and a new database module is added under fixture. It stands to reason that usually IDEA will automatically recognize new modules and automatically remove deleted modules. However, the newly added database module has not been added to the source code, and the deleted module is still in the module list.
insert image description here

Using the Maven command to install is normal, but when IDEA builds the project, compilation errors such as packages and classes cannot be found will occur.
insert image description here
Check the pom.xml file of the database module, no errors were found in it. (Otherwise, there will be problems with the execution of Maven install)

IDEA tries to execute Reload All Maven Projects
insert image description here

The problem was not solved after execution, but an error was reported in the Build window:

insert image description here
This error doesn't have any details.

Tried clearing the cache and other means can not solve the problem.
insert image description here

Since IDEA has reported an error and the problem has not been resolved, we must find a way to know what is wrong.

Check the IDEA log

There are many ways to find IDEA logs, which can be opened directly in the Help menu, or navigated through the Actions window.
insert image description here

You can directly tail IDEA log under Linux, and other platforms may need to manually open the IDEA log file.
insert image description here

Search the exception thrown in the Build window java.lang.reflect.InvocationTargetExceptionand find the complete information in the log:

2023-07-26 16:31:47,659 [  59616]   INFO - #o.j.i.m.p.MavenProjectsProcessor - [maven import] MavenProjectsProcessorReadingTask took 3303ms
2023-07-26 16:31:47,765 [  59722]   WARN - #o.j.i.maven - java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.jetbrains.idea.maven.server.MavenRemoteObject.wrapToSerializableRuntimeException(MavenRemoteObject.java:28)
	at org.jetbrains.idea.maven.server.Maven3XServerEmbedder.<init>(Maven3XServerEmbedder.java:239)
	at org.jetbrains.idea.maven.server.Maven36ServerEmbedderImpl.<init>(Maven36ServerEmbedderImpl.java:8)
	at org.jetbrains.idea.maven.server.Maven36ServerImpl.createEmbedder(Maven36ServerImpl.java:22)
# 省略部分链路
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.jetbrains.idea.maven.server.Maven3XServerEmbedder.<init>(Maven3XServerEmbedder.java:229)
# 省略部分链路
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	... 1 more
Caused by: java.io.FileNotFoundException: The specified global settings file does not exist: /home/wuweijie/conf/settings.xml
	at org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor.process(SettingsXmlConfigurationProcessor.java:117)
	at org.apache.maven.cli.MavenCli.configure(MavenCli.java:1169)
	at org.apache.maven.cli.MavenCli.loadCoreExtensions(MavenCli.java:758)
	at org.apache.maven.cli.MavenCli.container(MavenCli.java:633)
	... 24 more

The reason for the error may be that Maven is trying to read the configuration file at the path /home/wuweijie/conf/settings.xml, but the path confdirectory does not exist, and I have never .m2placed any Maven configuration outside the directory.

Check Maven configuration

Profile is not specified.
insert image description here

Although the use is checked .mvn/maven.confg, the path file does not exist.
insert image description here

So where did IDEA get a path that doesn't exist?

Retrieve IDEA's YouTrack (similar to GitHub Issues)

It is found that someone has indeed reported the same problem, which has been resolved in 2023.1.5 and 2023.2.

https://youtrack.jetbrains.com/issue/IDEA-322338/maven-reimport-fails-with-java.io.FileNotFoundException-The-specified-global-settings-file-does-not-exist-conf-settings.xml

insert image description here

summary

In fact, the problem of checking IDEA itself is not much different from usual:

  • Check the log to find out the specific reason;
  • Check issues to see if there are similar problems or solutions; if there is no similar problem, please raise a new issue.
  • Those who are interested can investigate in depth by themselves.

Guess you like

Origin blog.csdn.net/wu_weijie/article/details/131942527