Home > Java > javaTutorial > How to Resolve Java Access Restriction Errors When Using IBM WSDL2Java Generated Code with Java 5?

How to Resolve Java Access Restriction Errors When Using IBM WSDL2Java Generated Code with Java 5?

Linda Hamilton
Release: 2024-12-18 01:15:13
Original
409 people have browsed it

How to Resolve Java Access Restriction Errors When Using IBM WSDL2Java Generated Code with Java 5?

Resolving Access Restrictions on Classes Due to Library Restrictions

In an attempt to compile Java 1.4 code generated by IBM's WSDL2Java using Java 5 without regenerating the stubs, users encountered an access restriction error in Eclipse. This error stemmed from the inability to access the QName type due to a restriction on the required library rt.jar.

To resolve this issue, there are multiple possible solutions:

Recreate Stubs:

One potential route is to regenerate the stubs using the latest version of WSDL2Java. While this approach ensures compatibility with the Java version being used, it may introduce additional complications if the generated code differs significantly from the original.

Reordering Classpath:

An alternative solution that has proven effective is to modify the project's build path settings:

  1. Navigate to the "Build Path" settings in the project properties.
  2. Remove the "JRE System Library".
  3. Add the "JRE System Library" back by selecting "Add Library" and choosing the default option.

This process reorders the classpath, giving precedence to the appropriate classes and resolving the access restriction issue.

Excluding Duplicate JARs:

For a more comprehensive solution, ensure that duplicate JAR files containing identical classes are excluded from the project. This prevents conflicts and ensures that the correct classes are being used.

In the provided example, the issue is resolved by excluding the axis-saaj-1.4.jar and saaj-api-1.3.jar files, which both contain the javax.xml.soap.SOAPPart class.

The above is the detailed content of How to Resolve Java Access Restriction Errors When Using IBM WSDL2Java Generated Code with Java 5?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template