3

I would like to develop using cumulocity api, so I downloaded the sources for java examples (https://bitbucket.org/m2m/cumulocity-clients-java) version 1004.7.0.

When trying to compile it with java 11 (openjdk 11.0.2) using maven I have the following exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project device-capability-model: Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project device-capability-model: Fatal error compiling
....
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags
    at java.lang.ClassLoader.findClass (ClassLoader.java:718)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
    at lombok.launch.ShadowClassLoader.loadClass (ShadowClassLoader.java:422)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:315)
    at lombok.javac.JavacTreeMaker$SchroedingerType.getFieldCached (JavacTreeMaker.java:156)
    at lombok.javac.JavacTreeMaker$TypeTag.typeTag (JavacTreeMaker.java:245)
    at lombok.javac.Javac.<clinit> (Javac.java:155)
    at lombok.javac.handlers.HandleGetter.<clinit> (HandleGetter.java:303)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:398)
    at lombok.core.SpiLoadUtil$1$1.next (SpiLoadUtil.java:111)
    at lombok.javac.HandlerLibrary.loadAnnotationHandlers (HandlerLibrary.java:171)
    at lombok.javac.HandlerLibrary.load (HandlerLibrary.java:156)
    at lombok.javac.JavacTransformer.<init> (JavacTransformer.java:44)
    at lombok.javac.apt.LombokProcessor.init (LombokProcessor.java:89)
    at lombok.core.AnnotationProcessor$JavacDescriptor.want (AnnotationProcessor.java:87)
    at lombok.core.AnnotationProcessor.init (AnnotationProcessor.java:140)
    at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init (AnnotationProcessor.java:69)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init> (JavacProcessingEnvironment.java:678)

For reference, the maven command used was:

mvn clean package -Dmaven.test.skip=true -e

Is there a version that compiles with java 11? Or what configurations do I need to make to compile this with java 11?

Mircea
  • 61
  • 1
  • 6

1 Answers1

0

In the maven pom.xml file comment the following two line.s

<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>

You will have to replace the following piece of code

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                </plugin>

with the following code in pom.xml.

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <release>11</release>
                    </configuration>
                </plugin>

You can check.

Sambit
  • 7,625
  • 7
  • 34
  • 65
  • I have tried your solution, but now I have: `[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project device-capability-model: Compilation failure: Compilation failure: [ERROR] /E:/data/git_repos/cumulocity/m2m-cumulocity-clients-java-3d14ee967178/device-capability-model/src/main/java/c8y/RemoteAccessCredentialsType.java:[16,46] cannot find symbol [ERROR] symbol: method getPassword() [ERROR] location: variable credentials of type c8y.RemoteAccessCredentials` These appear on device-capability-model. – Mircea May 28 '19 at 09:47
  • The error clearly says about the problem of credentials, it means either you are not passing the password or you are using a wrong password. – Sambit May 28 '19 at 14:20
  • I think somewhere you are using username and password to download the artifacts. As per your question, the problem regarding compilation is solved. If you post a new question regarding this, people will be able to help you. – Sambit May 28 '19 at 14:21
  • Credentials are not required when downloading Cumulocity artifacts with Maven. Just use the repositories provided in https://cumulocity.com/guides/microservice-sdk/java/ – driu Feb 10 '20 at 17:47