Build fail Heroku java - java

I have issue deploy project java. i configed pom.xml version jar 11 and mvn 3.8.1. I build success project in local so when i deployed in heroku. What I need to do?
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar (21 kB at 211 kB/s)
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 149 source files to /tmp/build_740f92f8/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.581 s
[INFO] Finished at: 2022-10-14T02:29:49Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project NCKHSV: Fatal error compiling: invalid flag: --release -> [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/MojoExecutionException
! 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

The problem is heroku currently using Java 8: Heroku Java versions
The indicator is this line:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project NCKHSV: Fatal error compiling: invalid flag: --release -> [Help 1]
I've encountered this problem when building maven application with target is Java 11 but running JDK is Java 8. I can't help with heroku since I haven't used it yet

At heroku you could really use the configurations in your pom.xml below,
please look carefully. :)
please check maven-plugin mentioned in pom.xml under <project>
I have something like this below.
...
<packaging>maven-plugin</packaging>
</project>
Futher more please check this plugin you could replace the below plugin code and modify as per your need. It can be added under build->plugins->THIS_PLUGIN
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.4</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
</execution>
<execution>
<id>help-descriptor</id>
<phase>process-classes</phase>
</execution>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
Also please add the below dependency in your pom.xml, under ```dependencies-> THIS DEPENDENCY
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.7.4</version>
</dependency>
I hope, it helps!

Related

com.sun.tools.xjc.maven2 giving No XSD files found even though xsd exist (java 11)

I am upgrading from java 8 to java 11. I'm attempting to use jaxb2-maven plugin to convert XSD files into java classes. when i run "mvn clean install" i get the below compile error
[INFO] Ignored given or default sources [xsd/dummy.xsd], since it is not an existent file or directory.
[INFO] Ignored given or default sources [xsd/MessageProcessingAck.xsd], since it is not an existent file or directory.
[WARNING] No XSD files found. Please check your plugin configuration.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.216 s
[INFO] Finished at: 2022-11-10T19:13:17-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.4:xjc (Acknowledgement notification XML/WSDL binding) on project dsched-integration-ackn: : MojoExecutionException: NoSchemasException -> [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/MojoExecutionException
my pom.xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>Acknowledgement notification XML/WSDL binding</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/</schemaDirectory>
<outputDirectory>${basedir}/target/generated/</outputDirectory>
<packageName>com.dgp.ds.ackn.ws.send.acknowledgement</packageName>
<sources>
<source>xsd/MessageProcessingAck.xsd</source>
</sources>
<args>-wsdl -b ${basedir}/src/main/resources/xsd/</args>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I have tried following the directions from these posts. I still got the same error
Maven jaxb2:xjc failing to generate code
the above post is mostly dealing with a lower version that is not compatible with most of my dependencies
https://artofcode.wordpress.com/2019/02/26/jaxb2-maven-plugin-2-4-and-java-11/
This post did not have any effect, both XSD were still not found
I was able to resolve this issue by using the below plugins
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.15.1</version>
....
</build>

Changing a 1.8 Maven Project to compile to 1.16 produces "invalid target release 1.16"

I've been searching a solution for hours, couldn't even find 1 post about maven compilation to 1.16
I recently decided to one of my projects from java 8 to 16, so I installed 16 JDK and changed my build section(in pom.xml) accordingly:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.16</source> //used to be 1.8
<target>1.16</target> //used to be 1.8
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
But I get the following error when I try to install:
[INFO] Total time: 0.628 s
[INFO] Finished at: 2021-08-03T22:40:27+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project employeme: Fatal error compiling: error: invalid target release: 1.16 -> [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/MojoExecutionException
It's not 1.16, it's 16.
You don't have to configure the maven-compiler-plugin.
You can use the new release option.
<properties>
<maven.compiler.release>16</maven.compiler.release>
</properties>
I ran into a similar issue despite the fact that my settings were
<source>16</source> //used to be 8
<target>16</target> //used to be 8
The real insight came up when I ran
mvn --version
as this one pointed out I was running a current maven with JDK 11.
The solution was to change JAVA_HOME to point to my JDK 16 installation before running maven.

How to fix PluginincompatibleException?

I am trying to build a project in Netbeans from Maven Central. When I first tried to build the project there were a number of error messages because plugins didn't have versions specified in the POM. I fixed those problems.
I am running the latest version of Maven 3.5.0. I specified in the POM the latest version of the plugin. Here is the related section of the POM complete with the version number I added.
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.2</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
<execution>
<id>validate-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<excludeProperties>
<excludeProperty>git.build.*</excludeProperty>
<excludeProperty>git.commit.user.email</excludeProperty>
<excludeProperty>git.commit.message.*</excludeProperty>
<excludeProperty>git.commit.id.describe</excludeProperty>
<excludeProperty>git.commit.user.name</excludeProperty>
<excludeProperty>git.remote.origin.url</excludeProperty>
<excludeProperty>git.commit.id.abbrev</excludeProperty>
<excludeProperty>git.closest.tag.name</excludeProperty>
<excludeProperty>git.closest.tag.commit.count</excludeProperty>
<excludeProperty>git.remote.origin.url</excludeProperty>
</excludeProperties>
</configuration>
</plugin>
I now get the follow fatal error:
cd D:\darren\My Documents\NetBeansProjects\XBee-API; "JAVA_HOME=D:\\Program Files\\Java\\jdk1.8.0_121" cmd /c "\"\"D:\\Program Files\\Java\\NetBeans 8.2\\java\\maven\\bin\\mvn.bat\" -Dmaven.ext.class.path=\"D:\\Program Files\\Java\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 install\""
Scanning for projects...
Inspecting build with total of 1 modules...
Installing Nexus Staging features:
... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
------------------------------------------------------------------------
Building com.rapplogic:xbee-api 0.9.2
------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/pl/project13/maven/git-commit-id-plugin/2.2.2/git-commit-id-plugin-2.2.2.pom
log4j:WARN No appenders could be found for logger (org.apache.maven.wagon.providers.http.httpclient.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
Downloaded: http://repo.maven.apache.org/maven2/pl/project13/maven/git-commit-id-plugin/2.2.2/git-commit-id-plugin-2.2.2.pom (13 KB at 25.6 KB/sec)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.729s
Finished at: Tue Jul 04 22:15:49 NZST 2017
Final Memory: 14M/245M
------------------------------------------------------------------------
Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.2.2:revision (get-the-git-infos) on project xbee-api: The plugin pl.project13.maven:git-commit-id-plugin:2.2.2 requires Maven version [3.1.1,) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginIncompatibleException
The Wiki help page is no help. There is no obvious way to resolve this problem and clear the error.

Maven enforcer plugin and missing dependencies

Here is a minimal project:
<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.test</groupId>
<artifactId>enforcer</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-env</id>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<rules>
<requireProperty>
<property>custom</property>
<message>You must set custom property.</message>
</requireProperty>
</rules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>enforcer-dep</artifactId>
<version>1.0.0</version>
<classifier>${custom}</classifier>
</dependency>
</dependencies>
</project>
When running:
mvn -Dcustom=some-value validate
Validation goes OK.
When running:
mvn enforcer:enforce
or any phase from validate to process-resources
mvn validate
mvn initialize
mvn generate-sources
mvn process-sources
mvn generate-resources
mvn process-resources
I get expected fail with message:
[...]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-env) # enforcer ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must set custom property.
[...]
But when I run any other (later) phase from compile up to deploy e.g.:
mvn install
I get the error about missing dependency but there is no fail caused by enforcer plugin:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building enforcer 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.test:enforcer-dep:jar:${custom}:1.0.0 is missing, no dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer-dep-1.0.0-${custom}.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.983s
[INFO] Finished at: Fri Nov 22 09:22:24 CET 2013
[INFO] Final Memory: 7M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project enforcer: Could not resolve dependencies for project com.test:enforcer:jar:1.0
.0: Could not transfer artifact com.test:enforcer-dep:jar:${custom}:1.0.0 from/to central (http://repo.maven.apache.org/
maven2): Illegal character in path at index 84: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer
-dep-1.0.0-${custom}.jar -> [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/DependencyResolutionException
It looks for me like enforcer plugin is not executed at all, or dependencies are checked first before project can be build when running compile and later phases.
But why dependencies are not checked when running up to process-resources?
Obviously you seemed to have changed the settings of the maven installation which went wrong based on the error message:
[WARNING] Some problems were encountered while building the effective settings
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ever maven must make a connection to a remote s
erver.\n |-->\n <s... #111:5) # C:\programs\Maven\3\bin\..\conf\settings.xml
This means first clean up the conf/settings.xml file. Best is to use the default file which came via the installation. If you need to make modification do this in the users settings.xml $HOME/.m2/settings.xml or on Windows C:/Users/UserName/.m2/settings.xml
Apart from that i don't know what you like to achieve by using something like this:
[WARNING] The POM for com.test:enforcer-dep:jar:${custom}:1.0.0 is missing, no dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer-dep-1.0.0-${custom}.jar

The import javax.annotation cannot be resolved during Maven build

I am getting the following error while building a .war using mcn clean package with Apache Maven. Can some one give me a way to resolve it? Thanks.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.593s
[INFO] Finished at: Thu Sep 05 22:35:10 GMT+05:30 2013
[INFO] Final Memory: 13M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.0:compile (default) on project application: Compiler errors :
[ERROR] error at import javax.annotation.PreDestroy;
[ERROR] ^^^^^^^^^^^^^^^
[ERROR] C:\Documents and Settings\User\My Documents\application\application\src\main\java\com\Service\MyService.java:13:0::0 The import javax.annotation cannot be resolved
[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/MojoExecutionException
Does your pom.xml set the Java Compiler version?
Some (all?) versions of maven-compiler assume the Java 1.4 compiler... which of course causes issues since Annotations were new in Java 1.5.
You can force it to Java 7 by including a plugin block for maven-compiler-version in your project's pom.xml and set its source and target properties... something like this:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Download JSR305 from here to fix the problem.

Categories

Resources