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:
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!