0

I code Java 7 on Java 8 JDK When I run

mvn clean install

it show error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project foo: Compilation failure: Compilation failure:
[ERROR] /E:/bar/XmlUtils.java:[9,44] package com.sun.xml.internal.bind.marshaller does not exist
[ERROR] /E:/bar/XmlUtils.java:[11,34] cannot find symbol
[ERROR] symbol: class CharacterEscapeHandler
[ERROR] /E:/.../FooServiceImpl.java:[106,44] package com.sun.xml.internal.bind.marshall

This is line of code make error

CharacterEscapeHandler.class.getName()

Maven can't find import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;

Maven can't find CharacterEscapeHandle. How to fix it?

but when I build, package, run by Eclipse Neon, no problem. How to fix it?

Vy Do
  • 46,709
  • 59
  • 215
  • 313
  • Have you tried http://stackoverflow.com/questions/13068146/how-to-overcome-package-com-sun-xml-internal-xxx-does-not-exist-when-compiling..??? – Akshay Feb 14 '17 at 07:06

2 Answers2

1

Normally you should not use any code from package com.sun.xml.internal. And this fails intentionally. Here are more details: https://bugs.java.com/bugdatabase/view_bug.do;jsessionid=1711ee4eae3ff10565fc7a212018?bug_id=6778491

omilus
  • 1,176
  • 11
  • 9
  • As they're internal packages, they have absolutely no guarantees. They can be gone the next update. – Zoe Jul 11 '18 at 18:48
-2

This is temporary solution

    <dependency>
        <groupId>sun.jdk</groupId>
        <artifactId>rt.jar</artifactId>
        <version>1.8</version>
        <scope>system</scope>
        <systemPath>${java.home}/lib/rt.jar</systemPath>
    </dependency>
</dependencies>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <fork>true</fork>
                    <compilerArgument>-XDignore.symbol.file</compilerArgument>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Maven builds success.

Vy Do
  • 46,709
  • 59
  • 215
  • 313