Maven plugin with protobuf RestClientException: Unexpected character ('<' (code 60)): - java

i have a problem to get the maven plugin running in version 7.2.1. Versions of the server are also all 7.2.1. I have a simple development setup with kafka, zookeeper, schema registry and kqsldb. I configured the plugin according to the documentation and i always get the following error when I run the mojo register.
mvn -X -P Schema-registration kafka-schema-registry-maven-plugin:7.2.1:register
[DEBUG] Processing schema for subject(law-download-events-value).
[DEBUG] Calling register('law-download-events-value', 'syntax = "proto3";
package datamanager.entities;
option java_multiple_files = true;
option java_package = "org.mjm.DataManager.DMEntities.entities.protos";
option java_outer_classname = "LawDownloadEventProtos";
option optimize_for = SPEED;
message LawDownloadEvent {
LawDownloadEventType type = 1;
enum LawDownloadEventType {
CHECK_DECISIONS = 0;
CHECK_LAWS = 1;
}
}
')
[DEBUG] Sending POST with input {"schemaType":"PROTOBUF","schema":"syntax = \"proto3\";\npackage datamanager.entities;\n\noption java_multiple_files = true;\noption java_package = \"org.mjm.DataManager.DMEntities.entities.protos\";\noption java_outer_classname = \"LawDownloadEventProtos\";\noption optimize_for = SPEED;\n\nmessage LawDownloadEvent {\n LawDownloadEventType type = 1;\n\n enum LawDownloadEventType {\n CHECK_DECISIONS = 0;\n CHECK_LAWS = 1;\n }\n}\n"} to http://127.0.0.1:8098/subjects/law-download-events-value/versions?normalize=false
[ERROR] Exception thrown while processing law-download-events-value
io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number (or 'NaN'/'INF'/'+INF'), Array, Object or token 'null', 'true' or 'false')
at [Source: (sun.net.www.protocol.http.HttpURLConnection$HttpInputStream); line: 1, column: 2]; error code: 50005
at io.confluent.kafka.schemaregistry.client.rest.RestService.sendHttpRequest (RestService.java:301)
at io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest (RestService.java:371)
at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema (RestService.java:548)
at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema (RestService.java:536)
at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema (RestService.java:494)
at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.registerAndGetId (CachedSchemaRegistryClient.java:274)
at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register (CachedSchemaRegistryClient.java:381)
at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register (CachedSchemaRegistryClient.java:354)
at io.confluent.kafka.schemaregistry.maven.RegisterSchemaRegistryMojo.processSchema (RegisterSchemaRegistryMojo.java:48)
at io.confluent.kafka.schemaregistry.maven.UploadSchemaRegistryMojo.processSubject (UploadSchemaRegistryMojo.java:121)
at io.confluent.kafka.schemaregistry.maven.UploadSchemaRegistryMojo.execute (UploadSchemaRegistryMojo.java:85)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:577)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.474 s
[INFO] Finished at: 2022-08-28T12:15:08+02:00
[INFO] ------------------------------------------------------------------------
If I copy the schema from the post output and run it with curl (or Insomnia Rest Client) directly on the given url, it works normally.
I can not find any solution to that problem. I checked all the files and the server logs and they are all fine (from my point of view).
Here is the config of the plugin:
<plugin>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry-maven-plugin</artifactId>
<version>7.2.1</version>
<configuration>
<schemaRegistryUrls>
<param>http://127.0.0.1:8098</param>
</schemaRegistryUrls>
<outputDirectory>src/main/proto/downloaded</outputDirectory>
<subjects>
<law-download-events-value>src/main/proto/law_download_event_proto.proto</law-download-events-value>
</subjects>
<schemaTypes>
<law-download-events-value>PROTOBUF</law-download-events-value>
</schemaTypes>
<compatibilityLevels/>
<previousSchemaPaths/>
<schemas/>
</configuration>
</plugin>
Here is the example protobuf file:
syntax = "proto3";
package datamanager.entities;
option java_multiple_files = true;
option java_package = "org.mjm.DataManager.DMEntities.entities.protos";
option java_outer_classname = "LawDownloadEventProtos";
option optimize_for = SPEED;
message LawDownloadEvent {
LawDownloadEventType type = 1;
enum LawDownloadEventType {
CHECK_DECISIONS = 0;
CHECK_LAWS = 1;
}
}
I don't know where to look anymore. Any help is more than welcome. Thanks in advance ...
Best Martin

I answer my own question and hope it helps someone. If you have this error, check the connection to the schema server. A bit embarrassing that I totally oversaw the typo in the port, but sometimes it happens that you do not see your obvious mistakes.
Thanks to #OneCricketeer pointed me in that direction, so that i checked this setting again.

Related

Facing issue while running maven clean install command for my project

I'm new to Java & in a project trying to run
mvn clean install
command to build the project but facing some issue. Saw some previous solutions but didn't work for me. I've checked for Java version & maven version. They look same to me. Any idea what could be the issue?
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
/bin/sh: /bin/javac: No such file or directory
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.136 s
[INFO] Finished at: 2021-12-03T00:43:04+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project My_Project: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] /bin/sh: /bin/javac: No such file or directory
[ERROR]
[ERROR]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project My_Project: Compilation failure
Failure executing javac, but could not parse the error:
/bin/sh: /bin/javac: No such file or directory
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
Failure executing javac, but could not parse the error:
/bin/sh: /bin/javac: No such file or directory
at org.apache.maven.plugin.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:656)
at org.apache.maven.plugin.CompilerMojo.execute (CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Following are the results for java -version & mvn -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T20:36:16+05:30)
Maven home: /Users/saswal/.asdf/installs/maven/3.6.2
Java version: 11.0.6, vendor: AdoptOpenJDK, runtime: /Users/saswal/.asdf/installs/java/adoptopenjdk-11.0.6+10.1
Default locale: en_IN, platform encoding: US-ASCII
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
pom.xml looks like this
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<service-framework-java.version>1.82</service-framework-java.version>
<elasticsearch-version>7.4.2</elasticsearch-version>
<elasticsearch-common.version>8.1.1</elasticsearch-common.version>
<elasticsearch-event-common.version>3.1.9</elasticsearch-event-common.version>
<proposal-search-consumer-shared.version>2.2.36-java8-1</proposal-search-consumer-shared.version>
<logic-domain-entities.version>4.1.14.1</logic-domain-entities.version>
<common-dropwizard.version>13.0.6</common-dropwizard.version>
</properties>
<dependencies>
Thanks in advance.
please check and follow the steps in Eclipse/STS
:- Window --> Preference --> Installed JREs -->Change path of JRE to JDK(add).
then mvn clean install
change java.version>1.82 to respective version as well

NetBeans on windows works fine but on ubnutu 20.04.2 LTE it shows me that:

When I run my code with NetBans on Windows it works fine but on ubnutu 20.04.2 LTE it shows me that:
cd /home/sulayman/NetBeansProjects/Clases; JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 /snap/netbeans/41/netbeans/java/maven/bin/mvn "-Dexec.args=-classpath %classpath clases.Clases" -Dexec.executable=/usr/lib/jvm/java-11-openjdk-amd64/bin/java org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...
------------------------< com.mycompany:Clases >------------------------
Building Clases 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------
--- exec-maven-plugin:3.0.0:exec (default-cli) # Clases ---
Error: Se ha producido un error de enlace al cargar la clase principal clases.Clases
java.lang.UnsupportedClassVersionError: clases/Clases has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.707 s
Finished at: 2021-02-28T14:01:07+01:00
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project Clases: Command execution failed.: Process exited with an error: 1 (Exit value: 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/MojoExecutionException
This
java.lang.UnsupportedClassVersionError: clases/Clases has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
is the reason.
You are trying to run classes that have been compiled for Java 15, but you are trying to use/compile them with Java 11
You either need to recompile those classes with Java 11, or use Java 15 on your Ubuntu computer

Surefire maven plugin does not execute one of the tests

I have a project with four packages. With three of them everything is fine. I have generated JUnit tests and they are executed during the build or while I am running mvn test command.
But my fourth package, containing just one class. I have created a JUnit test for it, but when I am running the build, Surefire does not see this test class. All other eight test classes are executed, but this one is ignored.
When I am trying to execute just this one test class explicitly using
mvn -Dtest=com.company.dpt.prj.pkg.MySpecificClassTest test
I am getting these messages
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.058 s
[INFO] Finished at: 2020-12-19T23:58:01-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project my-project-name: No tests were executed! (Set -DfailIfNoTests=false to ignore this 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
I went through the test code line by line and couldn't find any reasons for such behavior.
I even deleted the test file and regenerated a very basic one. It is still not executed.
Has anyone encountered something similar? Any hint will be greatly appreciated, as I couldn't find any clues.
I am using JUnit 4.11
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.11</version>
</dependency>
All tests were originally generated using Netbeans v.12 "Tools->Create/Update Test" and than edited to reflect methods functionality.
However, all test but this one are working fine both in Netbeans GUI and CLI "mvn test". This one is ignored. The purpose of method I want to test is to build HttpEntity for the REST API client. Here is the code of the test:
/**
* Test of prepareRequest method, of class BatchServiceClient.
* #throws java.net.URISyntaxException
*/
#Test
public void testPrepareRequest() throws URISyntaxException {
System.out.println("prepareRequest");
ObjectMapper mapper = Json.mapper();
URL configFileUrl = this.getClass().getClassLoader().getResource("config_f.json");
if (configFileUrl == null) {
fail("Missing configuration file");
} else {
File configFile = new File(configFileUrl.toURI());
BatchConfig config = BatchConfigLoader.loadConfig(configFile);
assertNotNull(config);
boolean validated = config.validate();
assertTrue(validated);
BatchServiceClient client = new BatchServiceClient(config, null, null, null, null, null, null);
List<Object> requestData = Arrays.asList("16759408", "", "", "", "The Home Depot", "",
"Baltimore", "MD", "", "840", "", "", "", "", "", "", "", "", "", "", 10, "",
true, true, "merchantName", "merchantName", "merchantName");
HttpEntity<String> request = client.prepareRequest(requestData);
assertNotNull(request);
}
}
My problem is that it is not failing within the test code. I will be happy if it would, because I will be able to debug it than. It is just not executing.
I tried to upgrade JUnit to v.4.13.1 and surefire maven plugin to v.3.0.0-M5 but it did not have any affect.
I tried to run mvn with -e option and got the following stack trace, but it still did not give me any clues on why it is happening.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution (SurefireHelper.java:149)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary (SurefirePlugin.java:364)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:1041)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:857)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
You cannot use this patter:
-Dtest=com.company.dpt.prj.pkg.MySpecificClassTest
because the Surefire and Failsafe plugin does not support fully qualified class name. It makes a lookup on the file system and therefore I showed you on how to use the slashes in the configuration. The documentation is specifying this option, read it again here:
NOTE: Use syntax e.g. "foo/MyTest.java", "/MyTest.java", "MyTest" for "test" parameter (see includes/excludes).**
Gary, your problem is that you are talking about the JUnit but which one? There are two versions 4 anf 5, and even more specifically you can post a source code to our Apache JIRA (or to Stackoverflow) and then me as a committer can have a look into your code. Really it cannot be reproduced without it because only a pure text in the stackoverflow cannot make your problem reproducible on my side. So please attach always a link the next time and we will have a look. One guy did it last week and it was very helpful.
Regarding the import of the Test annotation, it was not Surefire plugin that did not recognize the #Test import. :-) Really, it was your fault you did not write proper source code including the POM and the compiler has compiled the code as it was even if you combine JUnit4 and JUnit5 in the POM. Then the Surefire triggered the JUnit libraries which are then responsible for recognizing the annotations - not the Surefire. The Surefire algorithm would prefer using JUnit5 if you combine JUnit4 and JUnit5-Jupiter and that's the reason why the annotation org.junit.Test was ignored because the Jupiter does not find it and Jupiter's annotation.
I did find the cause of the problem.
Somehow, when IDE generated (and regenerated) that test file it placed the wrong import for the #Test annotation. Instead of
import org.junit.jupiter.api.Test;
it placed
import org.junit.Test;
Therefore, jupiter engine, ran by surefire did not recognized #Test annotation.
After I corrected import test was executed.
I had this issue in a Spring Boot Project together with the Maven Surefire plugin 3.0.0-M5. Spring Boot is providing dependencies for junit4 and junit5. Maven Surefire has a precedence when selecting a provider and is choosing junit5 first if available:
if the JUnit 5 Platform Engine is present in the project
use junit-platform
if the JUnit version in the project >= 4.7 and the <<>> configuration parameter has ANY value
use junit47 provider
if JUnit >= 4.0 is present
use junit4 provider
else
use junit3.8.1
All my test were junit4 test and hence no test were found to be executed. I have migrated all tests, look out in the documentation to find an option to set the provider, maybe there is any.
Please see the documentation.
In your case the command should become:
mvn -Dtest=com/company/dpt/prj/pkg/MySpecificClassTest.java test

How to fix "Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java" error running a Dataflow template from a VM instance in GCP?

I'm trying to execute the Dataflow template named PubSubToBigQuery.java at a VM instance (OS: "linux", version: "4.9.0-11-amd64", Distributor: Debian GNU/Linux 9.11 (stretch)) to take input messages from a Pub/Sub subscription and write them in a BigQuery table (without modifying the template for the moment). In order to do this I cloned the GitHub DataflowTemplates repo into my Cloud Shell in the $HOME/opt/ directory. Following the README document I've installed Java 8 and Maven 3:
Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00) Maven home: /opt/maven
Java version: 1.8.0_232, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.9.0-11-amd64", arch: "amd64", family: "unix"
After building the entire project, this is what I'm trying to execute from the comand line to compile the code:
sudo mvn -X compile exec:java -Dexec.mainClass=com.google.cloud.teleport.templates.PubSubToBigQuery -
Dexec.cleanupDaemonThreads=false -Dexec.args=" --project=real-demand --
stagingLocation=gs://rd_pubsub/staging --streaming=true"
And this is the error I'm getting:
[WARNING]
java.lang.ClassNotFoundException: com.google.cloud.teleport.templates.PubSubToBigQuery.java
at java.net.URLClassLoader.findClass (URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:270)
at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:21 min
[INFO] Finished at: 2019-11-26T10:47:57Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project google-cloud-teleport-java: An exception occured while executing the Java class. com.google.cloud.teleport.templates.PubSubToBigQuery.java -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project google-cloud-teleport-java: An exception occured while executing the Java class. com.google.cloud.teleport.templates.PubSubToBigQuery.java
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. com.google.cloud.teleport.templates.PubSubToBigQuery.java
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:339)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.ClassNotFoundException: com.google.cloud.teleport.templates.PubSubToBigQuery.java
at java.net.URLClassLoader.findClass (URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:270)
at java.lang.Thread.run (Thread.java:748)
[ERROR]
[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
Following this post or this discussion discussion I've also added this piece of XML in pom.xml:
<properties>
<testNgMainClass>defaultMainClass</testNgMainClass>
<args>defaultArgs</args>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>${testNgMainClass}</mainClass>
<arguments>${args}</arguments>
</configuration>
<executions>
<execution>
<id>run-selenium</id>
<phase>integration-test</phase>
<goals><goal>java</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
But it's still not working.
I can see that you are not specifying all the parameters needed to execute the template and as you mentioned, you are not modifying the file.
inputTopic=projects/${PROJECT_ID}/topics/input-topic-name
outputTableSpec=${PROJECT_ID}:dataset-id.output-table
outputDeadletterTable=${PROJECT_ID}:dataset-id.deadletter-table
The command should look like this:
mvn compile exec:java -Dexec.mainClass=com.google.cloud.teleport.templates.PubSubToBigQuery -Dexec.cleanupDaemonThreads=false \
-Dexec.args=" --project=PROJECT_ID \
--stagingLocation=gs://bucket-name/dataflow \
--streaming=true \
--inputTopic=projects/PROJECT_ID/topics/input-topic-name \
--outputTableSpec=PROJECT_ID:dataset-id.deadletter-table \
--outputDeadletterTable=PROJECT_ID:dataset-id.deadletter-table"
On the other hand, I recommend to deploy the template into GCP and execute using the gcloud command, follow the instructions given within the PubSubToBigQuery.java file
To clone, compile and run a Dataflow Template is necessary enable all the necessary APIs in your GCP project:
Dataflow
Compute Engine
Stackdriver Logging
Cloud Storage
Cloud Storage JSON
BigQuery
PubSub
In order to do that you can click in this helper link:
https://console.cloud.google.com/flows/enableapi?apiid=dataflow,compute_component,logging,storage_component,storage_api,bigquery,pubsub

Maven plugin failed to execute

Maven configuration failed this line just ruined my Friday night and still i am unable to solve it.
Well,I am a big fan of visual studio code so i just decided to switch on vscode to eclipse for java development. but this is not the problem,Problem raise when i just try to add an external java library.I am unable to use it and i just get an error something like Class-not-Found or so on.
Well,this is my project structure in vscode
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project in.blackpaper.topdf: Compilation failure
This is error message which i get while install mvn plugin.
mvn clean install
[DEBUG] incrementalBuildHelper#beforeRebuildExecution
[INFO] Compiling 1 source file to E:\Documents\Java\in.blackpaper.topdf\target\classes
[DEBUG] incrementalBuildHelper#afterRebuildExecution
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.086 s
[INFO] Finished at: 2018-04-17T11:23:29+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project in.blackpaper.topdf: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project in.blackpaper.topdf: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1161)
at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:168)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[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
Well,i also try to solve my problem with vscode developers but still i can't solve it.
This is the issue i raised in vscode-github
vscode-java/issue#509
Well,my problem is different from all the previously asked questions about maven-plugins and I tried all available solution but unable to get the point.
Thanks in advance.
The Java installation you're using is not a Java Development Kit (you can understand the difference by looking at this question).
To solve your problem, download and install the JDK (such as from here, or from here, depending on the version you prefer), if you haven't installed it already. After installing and/or extracting (if you're on linix, better done in an init script):
export JAVA_HOME=<path_to_the_extracted_jdk_directory>
On Windows, create an environment variable named JAVA_HOME, with a value set to the full path to the installation directory.
To verify that Maven picks up the correct Java installation, you can try
mvn -version
The output includes a line for the Java installation Maven is seeing, such as:
...Maven home: [path to maven]
Java version: 1.8.0_152, vendor: Oracle Corporation
Java home: /home/user/jdk/jdk1.8.0_152/jre
...
Please check the terminal, the process holds the lock. So the application files are still used by somewhere. So first we need to stop the process, then start your task it will work.

Categories

Resources