Scala/Java Project not finding Dependencies during Maven compile - java

I have a Java/Scala hybrid project. When building in Intellij, things work fine. However, trying to run Maven builds from command line is giving me this error when running 'mvn clean install':
[ERROR] /IdeaProjects/user-lib-common/src/main/scala/com/test/userlib/rest/UserServiceRestClient.scala:12: error: object model is not a member of package com.test.userlib
[ERROR] import com.test.userlib.model.cte.{ItemResponse, CteUser}
[ERROR] ^
[ERROR] /IdeaProjects/user-lib-common/src/main/scala/com/test/userlib/rest/UserServiceRestClient.scala:13: error: object utils is not a member of package com.test.userlib
[ERROR] import com.test.userlib.utils.UserLibProperties
[ERROR] ^
[ERROR] /IdeaProjects/user-lib-common/src/main/scala/com/test/userlib/rest/UserServiceRestClient.scala:26: error: not found: value UserLibProperties
[ERROR] .hosts(UserLibProperties.CTE_USERSERVICE_HOST + ":" + UserLibProperties.CTE_USERSERVICE_PORT)
[ERROR] ^
[ERROR] /IdeaProjects/user-lib-common/src/main/scala/com/test/userlib/rest/UserServiceRestClient.scala:32: error: not found: value UserLibProperties
[ERROR] ClientAuthTlsConfigUtil.createSslContext(new File(UserLibProperties.CTE_USERSERVICE_KEYSTORE),UserLibProperties.CTE_USERSERVICE_KEYSTORE_PASSWORD,new File(UserLibProperties.CTE_USERSERVICE_TRUSTSTORE),UserLibProperties.CTE_USERSERVICE_TRUSTSTORE_PASSWORD)
[ERROR] ^
[ERROR] /IdeaProjects/user-lib-common/src/main/scala/com/test/userlib/rest/UserServiceRestClient.scala:35: error: not found: type CteUser
[ERROR] protected def getUser(dn :String) :CteUser = {
[ERROR] ^
[ERROR] /IdeaProjects/user-lib-common/src/main/scala/com/test/userlib/rest/UserServiceRestClient.scala:36: error: not found: value UserLibProperties
[ERROR] val rb = RequestBuilder().url(s"${UserLibProperties.CTE_USERSERVICE_ENDPOINT}/user?dn=${URLEncoder.encode(dn,"utf-8")}&aacAttribs=true").buildGet
[ERROR] ^
[ERROR] /IdeaProjects/user-lib-common/src/main/scala/com/test/userlib/rest/UserServiceRestClient.scala:42: error: not found: type ItemResponse
[ERROR] case HttpResponseStatus.OK => new ObjectMapper().readValue(respTry.get.getContent.toString("UTF-8"), classOf[ItemResponse]).getItem.getUser
[ERROR] ^
[ERROR] 7 errors found
So, clearly my Scala class isn't finding the Java dependencies it needs. Here's my project's structure:
And here is the build portion of my pom.xml:
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Do I have to add the classpath to the Scala compiler somehow?

I think UserLibProperties file should be in proper file extension UserLibProperties.scala. Please check you folder and do a list command and check for file extensions, in Intelij it will work without proper extension.

I think, SBT is best way to build a hybrid project.
For example:
https://github.com/databricks/learning-spark/blob/master/build.sbt
It has little learning curve, but worth to invest time in SBT.

Related

Why does using limit modules am getting namespace error?

I am getting below error while using mvn clean package. Even after limiting modules in pom.xml
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.7.0:compile (default-compile) on project com.binding.rest.runtime.schema: Compilation failure: Compilation failure: [ERROR] C:\Users\runtime\plugins\com.binding.rest.runtime.schema\src\com\runtime\schema\Wsdl4JsonUtils.java:[5] [ERROR] import javax.xml.namespace.QName;
I tried to limit modules in below manner:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<compilerArgs>
<arg>-warn:none</arg>
<arg>-err:none</arg>
<arg>-warn:+discouraged,forbidden</arg>
<arg>--limit-modules</arg>
<arg>java.base,java.compiler,....</arg>
</compilerArgs>
</configuration>
</plugin>

Javadoc with Java17 gives package X is declared in module Y error

I'm using maven-javadoc-plugin to produce Javadoc with Java 17. Since there is a class in my code that uses jdk.internal.reflect.Reflection class, Javadoc gives an error. I tried using to pass --add-opens flag but it's no use.
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase>
<goals><goal>jar</goal></goals>
</execution>
</executions>
</plugin>
It get the error below.
import jdk.internal.reflect.Reflection;
[ERROR] ^
[ERROR] (package jdk.internal.reflect is declared in module java.base, which does not
export it to the unnamed module)
[ERROR] 1 error
[ERROR]
[ERROR] Command line was: cmd.exe /X /C ""C:\Program Files\Java\jdk-17.0.1\bin\javadoc.exe" #options #packages"

kapt not working with maven and dagger in mixed kotlin/java project

Kapt doesnt work with maven, if we dont use kapt and just use the maven compiler for java it generates dagger code perfectly fine, but the problem is that java compiles after kotlin compiles and kotlin gives and error because it can't use dagger components before they are created, so the solution would be to use kapt.
this is the plugin configuration
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
<annotationProcessorPaths>
<!-- Specify your annotation processors here. -->
<annotationProcessorPath>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.9</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</execution>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.example.myanimelist/com.example.myanimelist.HelloApplication</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
and this is the error that gives
"C:\Program Files\BellSoft\LibericaJDK-17-Full\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList -Dmaven.home=C:\Users\Roberto\.m2\wrapper\dists\apache-maven-3.8.4-bin\52ccbt68d252mdldqsfsn03jlf\apache-maven-3.8.4 -Dclassworlds.conf=C:\Users\Roberto\.m2\wrapper\dists\apache-maven-3.8.4-bin\52ccbt68d252mdldqsfsn03jlf\apache-maven-3.8.4\bin\m2.conf "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\lib\idea_rt.jar=63596:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Roberto\.m2\wrapper\dists\apache-maven-3.8.4-bin\52ccbt68d252mdldqsfsn03jlf\apache-maven-3.8.4\boot\plexus-classworlds-2.6.0.jar;C:\Users\Roberto\.m2\wrapper\dists\apache-maven-3.8.4-bin\52ccbt68d252mdldqsfsn03jlf\apache-maven-3.8.4\boot\plexus-classworlds.license org.codehaus.classworlds.Launcher -Didea.version=2022.1 compile
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.example:MyAnimeList >-----------------------
[INFO] Building MyAnimeList 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- kotlin-maven-plugin:1.6.21:kapt (kapt) # MyAnimeList ---
[WARNING] 'tools.jar' was not found, kapt may work unreliably
[WARNING] C:\Users\Roberto\.m2\repository\org\checkerframework\checker-compat-qual\2.5.5\checker-compat-qual-2.5.5.jar: (-1, -1) The root is ignored because a module with the same name 'org.checkerframework.checker.qual' has been found earlier on the module path at: C:/Users/Roberto/.m2/repository/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar
[WARNING] C:\Users\Roberto\.m2\repository\org\openjfx\javafx-base\17.0.1\javafx-base-17.0.1-win.jar: (-1, -1) The root is ignored because a module with the same name 'javafx.base' has been found earlier on the module path at: C:/Program Files/BellSoft/LibericaJDK-17-Full
[WARNING] C:\Users\Roberto\.m2\repository\org\openjfx\javafx-controls\17.0.1\javafx-controls-17.0.1-win.jar: (-1, -1) The root is ignored because a module with the same name 'javafx.controls' has been found earlier on the module path at: C:/Program Files/BellSoft/LibericaJDK-17-Full
[WARNING] C:\Users\Roberto\.m2\repository\org\openjfx\javafx-fxml\17.0.1\javafx-fxml-17.0.1-win.jar: (-1, -1) The root is ignored because a module with the same name 'javafx.fxml' has been found earlier on the module path at: C:/Program Files/BellSoft/LibericaJDK-17-Full
[WARNING] C:\Users\Roberto\.m2\repository\org\openjfx\javafx-graphics\17.0.1\javafx-graphics-17.0.1-win.jar: (-1, -1) The root is ignored because a module with the same name 'javafx.graphics' has been found earlier on the module path at: C:/Program Files/BellSoft/LibericaJDK-17-Full
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\ControllersComponent.java:12: error: cannot find symbol
#Component(modules = {FiltersModule.class})
^
symbol: class Component
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\ControllersComponent.java:13: error: cannot find symbol
#Singleton
^
symbol: class Singleton
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\RepositoriesComponent.java:13: error: cannot find symbol
#Component(modules = {RepositoriesModule.class})
^
symbol: class Component
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\RepositoriesComponent.java:14: error: cannot find symbol
#Singleton
^
symbol: class Singleton
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\dto\AnimeDTO.java:13: error: cannot find symbol
#Data
^
symbol: class Data
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\dto\BackupDTO.java:12: error: cannot find symbol
#Data
^
symbol: class Data
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\modules\FiltersModule.java:12: error: incompatible types: Module cannot be converted to Annotation
#Module(includes = RepositoriesModule.class)
^
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\modules\RepositoriesModule.java:17: error: incompatible types: Module cannot be converted to Annotation
#Module
^
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\kotlin\com\example\myanimelist\controllers\inicio\LoginController.kt: (4, 46) Unresolved reference: DaggerControllersComponent
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\kotlin\com\example\myanimelist\controllers\inicio\RegisterController.kt: (3, 46) Unresolved reference: DaggerControllersComponent
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.254 s
[INFO] Finished at: 2022-05-16T00:29:31+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.6.21:kapt (kapt) on project MyAnimeList: Compilation failure: Compilation failure:
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\ControllersComponent.java:12: error: cannot find symbol
[ERROR] #Component(modules = {FiltersModule.class})
[ERROR] ^
[ERROR] symbol: class Component
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\ControllersComponent.java:13: error: cannot find symbol
[ERROR] #Singleton
[ERROR] ^
[ERROR] symbol: class Singleton
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\RepositoriesComponent.java:13: error: cannot find symbol
[ERROR] #Component(modules = {RepositoriesModule.class})
[ERROR] ^
[ERROR] symbol: class Component
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\components\RepositoriesComponent.java:14: error: cannot find symbol
[ERROR] #Singleton
[ERROR] ^
[ERROR] symbol: class Singleton
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\dto\AnimeDTO.java:13: error: cannot find symbol
[ERROR] #Data
[ERROR] ^
[ERROR] symbol: class Data
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\dto\BackupDTO.java:12: error: cannot find symbol
[ERROR] #Data
[ERROR] ^
[ERROR] symbol: class Data
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\modules\FiltersModule.java:12: error: incompatible types: Module cannot be converted to Annotation
[ERROR] #Module(includes = RepositoriesModule.class)
[ERROR] ^
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\java\com\example\myanimelist\di\modules\RepositoriesModule.java:17: error: incompatible types: Module cannot be converted to Annotation
[ERROR] #Module
[ERROR] ^
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\kotlin\com\example\myanimelist\controllers\inicio\LoginController.kt:[4,46] Unresolved reference: DaggerControllersComponent
[ERROR] C:\Users\Roberto\IdeaProjects\ProyectoFinal1DAM\MyAnimeList\src\main\kotlin\com\example\myanimelist\controllers\inicio\RegisterController.kt:[3,46] Unresolved reference: DaggerControllersComponent
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Process finished with exit code 1
I have tried using older jdks versions but nothing changed

XJC Maven Plugin(jaxb2-maven-plugin) Java 11 Migration Issues

I am currently working on java 11 migration project where jaxb2-maven-plugin has been used for XJC task. As XJC executable is not present in the JDK 11 version, I am getting below mentioned errors.
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc (xjc-schema1) on project paymaster-service: Execution xjc-schema1 of goal org.codehaus.mojo:jaxb2-maven-plugin:2.2
:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc: com/sun/codemodel/CodeWriter
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:jaxb2-maven-plugin:2.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/voletis/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/2.2/jaxb2-maven-plugin-2.2.jar
[ERROR] urls[1] = file:/C:/Users/voletis/.m2/repository/javax/xml/bind/jaxb-api/2.2.11/jaxb-api-2.2.11.jar
[ERROR] urls[2] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-core/2.2.11/jaxb-core-2.2.11.jar
[ERROR] urls[3] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
[ERROR] urls[4] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
[ERROR] urls[5] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-jxc/2.2.11/jaxb-jxc-2.2.11.jar
[ERROR] urls[6] = file:/C:/Users/voletis/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M3/qdox-2.0-M3.jar
[ERROR] urls[7] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[8] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[9] = file:/C:/Users/voletis/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
[ERROR] urls[10] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[11] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[12] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[13] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[14] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.5/plexus-compiler-api-2.5.jar
[ERROR] urls[15] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[16] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : com.sun.codemodel.CodeWriter
[ERROR] -> [Help 1]
[ERROR]
Below is my pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>xjc-schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<target>2.2</target>
<schemaFiles>SubmitPaymentBatch/SubmitPaymentRequest.xsd</schemaFiles>
<packageName>app.test.services.submitpayment.request</packageName>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</plugin>
I have added necessary dependencies like JAXB, JAXB-IMPL, etc., as per java 11 requirements. But still not able to fix the issues. Do you have any suggested fix for this ? Thank in Advance.
jaxb2-maven-plugin 2.5.0 is now compatible with Java 11:
https://github.com/mojohaus/jaxb2-maven-plugin/issues/43
https://github.com/mojohaus/jaxb2-maven-plugin/releases/tag/jaxb2-maven-plugin-2.5.0
I had issues with making jaxb working with maven and Java 11 too. My solution looks as follows:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>xjc</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>de.powerstat.my.generated</packageName>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
</plugin>
Hope this helps others.
I have fixed this issue by following below reference link.
https://github.com/davidmoten/jax-maven-plugin
As per the above tutorial reference, I have modified my plugin as below and i am able to fix this.
<plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>VERSION_HERE</version>
<executions>
<execution>
<id>xjc-schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<target>2.2</target>
<schemaFiles>SubmitPaymentBatch/SubmitPaymentRequest.xsd</schemaFiles>
<packageName>app.test.services.submitpayment.request</packageName>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
</plugin>
I've just found a workaround for problems with using jaxb2-maven-plugin with Java 11. It consists of adding extra dependencies in pom.xml and adding an extra, dummy XSD file to the project, next to proper XSD files. I've put it altogether in my blog-post here:
https://artofcode.wordpress.com/2019/02/26/jaxb2-maven-plugin-2-4-and-java-11/
I was able to solve the issue for JDK11 by adding all dependencies which are listed here: https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/pom.xml#L251-L290 which the apache.cxf project uses in their example projects starting for JDK9

when deploying to heroku, it doesnt see my jar files or maven dependency in pom.xml

I am trying to deploy my app using heroku website, but it does not see any maven dependency like HttpServlet although I have it in my pom.xml AND it doesn't see Gson.jar although its in the lib directory. I have added webapp-runner plugin but nothing happened.
This is the error that I got. your help is appreciated. Thanks all.
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[6,21] package javax.servlet does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[7,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[8,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[9,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[11,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[13,40] cannot find symbol
symbol: class HttpServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,30] cannot find symbol
symbol: class HttpServletRequest
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,54] cannot find symbol
symbol: class HttpServletResponse
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,87] cannot find symbol
symbol: class ServletException
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[24,64] cannot find symbol
symbol: class HttpServletRequest
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[14,23] package com.google.gson does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[15,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/Deals.java:[6,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[14,9] method does not override or implement a method from a supertype
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[26,38] cannot find symbol
symbol: class Gson
location: class hotels.HotelDeals
[INFO] 15 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.514 s
[INFO] Finished at: 2018-03-09T16:25:19+00:00
[INFO] Final Memory: 19M/177M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project hotels: Compilation failure: Compilation failure:
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[6,21] package javax.servlet does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[7,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[8,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[9,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[11,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[13,40] cannot find symbol
[ERROR] symbol: class HttpServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,30] cannot find symbol
[ERROR] symbol: class HttpServletRequest
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,54] cannot find symbol
[ERROR] symbol: class HttpServletResponse
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,87] cannot find symbol
[ERROR] symbol: class ServletException
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[24,64] cannot find symbol
[ERROR] symbol: class HttpServletRequest
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[14,23] package com.google.gson does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[15,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/Deals.java:[6,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[14,9] method does not override or implement a method from a supertype
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[26,38] cannot find symbol
[ERROR] symbol: class Gson
[ERROR] location: class hotels.HotelDeals
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
Adding POM posted in the answer section by OP
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.khalid.hotels</groupId>
<artifactId>hotels</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>embeddedTomcatSample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<tomcat.version>8.5.23</tomcat.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.30.2</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Please use the updated POM below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.khalid.hotels</groupId>
<artifactId>hotels</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>embeddedTomcatSample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<tomcat.version>8.5.23</tomcat.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.30.2</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
</project>

Categories