Remember a project startup error problem

I ran into a problem today that has been bugging me for hours, although it ended up being caused by a small problem. Recording it is also a solution to the problem.

  Premise: reference when calling webservice

        <dependency>
            <groupId>org.codehaus.xfire</groupId>
            <artifactId>xfire-all</artifactId>
            <version>1.2.6</version>
        </dependency>

 The project uses springboot. The code is completely developed, and there is no problem with starting it locally and in the idea, but the following error is always reported after it is packaged as a jar package or started with a war:

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:53)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.isPresent(Ljava/lang/String;Ljava/lang/ClassLoader;)Z
        at org.springframework.boot.SpringApplication.deduceWebEnvironment(SpringApplication.java:257)
        at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:248)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:225)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
        at com.drore.cloud.tdp.DataInterfaceApplication.main(DataInterfaceApplication.java:13)
        ... 6 more

 It can be seen from the error that a method cannot be found. Then start troubleshooting:

 1. Determine the problem, comment out this dependency and you can start it. If you add it, there will be a problem, so it can be determined that it is the problem of this dependency.

 2. According to the error message, there should be some missing method, and then I found it on the Internet. There are various answers, but none of them can solve the fundamental problem. It is finally determined that it should be a jar reference problem, and the specific jar is uncertain. Later, I specifically searched for this method and found that it is a method in a jar package of spring. Then follow up the introduced dependency to see which dependency packages have been introduced indirectly, and finally found that a spring jar package has indeed been introduced. So exclude:

      <dependency>
            <groupId>org.codehaus.xfire</groupId>
            <artifactId>xfire-all</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.xfire</groupId>
                    <artifactId>xfire-spring</artifactId>
                </exclusion>
            </exclusions>
            <version>1.2.6</version>
        </dependency>

 Start the project again, the result is still the same problem as above. But it was repeatedly determined that the problem was indeed here. So I suspect that this dependency is still there, and then I make a war package and publish it to the local tomcat, and then go to the webapp to find the lib package of this project. Sure enough, the outdated version of spring-1.2.6 is still in it, so the project starts. It will always conflict with this dependency, and an error will be reported. So remove this jar in lib, restart tomcat, the problem is solved.

 

The above problem is simple to say, but it took several hours. The main reason is that the idea of ​​​​starting to solve the problem is wrong, and only the next idea is recorded. I hope that if you have similar problems to yourself and others in the future, you can step on the pits less.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326128509&siteId=291194637