java.lang.LinkageError: Loading JAXB 2.1 API Ultimate Solution from bootstrap classloader

The first: the conventional solution, that is, most of the methods seen on the Internet, get to the endorsed directory.

public class MainClass {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println(System.getProperty("java.endorsed.dirs"));
    }

}

 Find the corresponding location and put the jar file under apache-cxf-2.7.4\lib\endorsed in the corresponding directory. If there is no endorsed directory, create it manually. In fact, there are two jar packages, geronimo-jaxws_2.2_spec-1.1.jar and jaxb-api-2.2.6.jar files

 

2. The first method, many people say that it can't solve the problem, you can consider the jdk version, I encountered javase1.4.7 installed, but the java -version is also the 1.6 version, so here are the environment variables and jdk-version All are invalid, and the consistency of the version is solved. Next, look at the configuration file of cxf. This is the most critical and also the hurdle I encountered.

<jaxws:endpoint id="surveyService"
		implementor="ws.cxf.impl.SurveyService" address="/SurveyWebService" />

 With this sentence, it is still a boot package error when starting under tomcat. Try to put the above two jars under tomcat/lib, but it does not work, but there is another way to configure the file, but it is possible

<jaxrs:server id="categoryRESTService" address="/">
	<jaxrs:serviceBeans> <ref bean="categoryService" />
	</jaxrs:serviceBeans>
		<jaxrs:extensionMappings>
                   <entry key="json" value="application/json"/>
                   <entry key="xml" value="application/xml"/>
                </jaxrs:extensionMappings>
</jaxrs:server>

 In this case, there is a conflict. To delete a package, the package guide path is wrong.

Delete the package in the current lib of the item: jaxb-impl-2.2.5.jar, as expected, the startup was successful. As for the specific principle, I have not understood the specific principle in detail.

 ps: java.lang.LinkageError guides the class loader to load JAXB 2.1 AP, but if there is a jar package of jaxb-impl-2.2.5, which refers to the api of 2.2, the first one should be guided by jdk, and later depends on this The project works, so some solutions are to upgrade to the jdk7 version to solve the contradiction, there is no practice here, I hope the students who have practiced will give a positive answer. Thank you!

 

 

Guess you like

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