I have configured my REST/Spring/Jersey project to generate documentation for APIs using enunciate.
The relevant changes in my pom.xml are
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-spring-plugin</artifactId>
<version>1.28</version>
<configuration>
<generateDir>${project.build.directory}/enunciate-generate</generateDir>
<configFile>enunciate.xml</configFile>
<exports>
<jaxws.client.library.binaries>client.jar</jaxws.client.library.binaries>
</exports>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
.....
<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-spring-plugin</artifactId>
<version>1.28</version>
</dependency>
My enunciate.xml is as follows
<?xml version="1.0"?>
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd">
<api-classes>
<include pattern="com.xxx.rest.*"/>
</api-classes>
<modules>
<docs docsDir="api" title="REST WebServices API"/>
<spring-app>
<war mergeWebXML="war/WEB-INF/web.xml"/>
<springImport file="war/WEB-INF/applicationContext-jdbc.xml"/>
</spring-app>
</modules>
</enunciate>
When I run my maven project I get the following error initializing enunciate. As you can see the error is not very helpful. Any hints what could be wrong in my configuration.
--- maven-enunciate-spring-plugin:1.28:assemble (default) # xxx ---
initializing enunciate.
[csharp] C# compilation is disabled, but the source code will still be generated.
invoking enunciate:generate step...
BUILD FAILURE
Total time: 3.324s
Failed to execute goal org.codehaus.enunciate:maven-enunciate-spring-plugin:1.28:assemble (default) on project xxx: Problem assembling the enunciate app. String index out of range: 0 -> [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
That StringIndexOutOfBoundsException was reported and fixed here.
The "invocation of API has failed" is almost always caused by some compile failure. Maybe when you messed with your dependencies to get around the first problem, you introduced a compile failure in your code base?
Related
I'm getting the following exception when updating the cucumber-groovy version in my POM file from 4.2.0 to 4.7.0
java.lang.IllegalArgumentException: The glue path contained invalid identifiers target/test-classes
at io.cucumber.core.model.GluePath.parseAssumeClasspathScheme (GluePath.java:84)
at io.cucumber.core.model.GluePath.parse (GluePath.java:53)
at io.cucumber.core.options.RuntimeOptionsParser.parse (RuntimeOptionsParser.java:85)
at io.cucumber.core.options.CommandlineOptionsParser.parse (CommandlineOptionsParser.java:25)
at io.cucumber.core.options.CommandlineOptionsParser.parse (CommandlineOptionsParser.java:29)
at io.cucumber.core.cli.Main.run (Main.java:29)
at io.cucumber.core.cli.Main.main (Main.java:14)
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.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.329 s
[INFO] Finished at: 2019-10-28T19:17:41+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default) on project sample-test: An exception occured while executing the Java class. The glue path contained invalid identifiers target/test-classes -> [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
This is the section of POM file where the error is being generated from (I believe)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>io.cucumber.core.cli.Main</mainClass> <!-- NEEDED FOR cucumber-groovy version 4.7.1 -->
<!--<mainClass>cucumber.api.cli.Main</mainClass>--> <!-- NEEDED FOR cucumber-groovy version 4.2.0 -->
<arguments>
<argument>--plugin</argument>
<argument>json:reports/junit.json</argument>
<argument>--strict</argument>
<argument>--glue</argument>
<argument>target/test-classes</argument>
<argument>target/test-classes/.</argument>
<argument>--tags</argument>
<argument>${tagArg}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
And here is the properties section of the POM file
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cluecumber-report-plugin.version>2.3.1</cluecumber-report-plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<ocular.version>1.0.0.Alpha</ocular.version>
<groovycsv.version>1.3</groovycsv.version>
<ashot.version>1.5.4</ashot.version>
<webdrivermanager.version>3.7.1</webdrivermanager.version>
<com4j.version>2.1</com4j.version>
<geb-core.version>3.2</geb-core.version>
<http-builder.version>0.7.1</http-builder.version>
<commons-io.version>2.6</commons-io.version>
<selenium-api.version>3.141.59</selenium-api.version>
<selenium-java.version>3.141.59</selenium-java.version>
<slf4j-simple.version>1.7.28</slf4j-simple.version>
<cucumber-jvm.version>4.8.0</cucumber-jvm.version>
<cucumber-groovy.version>4.7.0</cucumber-groovy.version>
<groovy-all.version>2.5.8</groovy-all.version>
</properties>
Same POM file works fine when using the cucumber-groovy version 4.2.0, is there a different way to specify the glue code for newer version of cucumber-groovy?
I have tried using the following but none of them worked.
target.test-classes
target
test-classes
My folder structure is
src\test\resources\features
src\test\resources\step_definitions
Any help is highly appreciated.
Thanks!
You currently pass your glue as --glue target/test-classes target/test-classes/. However your glue should be either a package name or class path uri. To access resources in the nameless package you can use --glue classpath: instead.
update POM file and replace
--glue target/test-classes target/test-classes/.
with
--glue classpath: classpath:/.
Context: My team is working on making our suite of Java services containerized and dynamically scalable. To accomplish this, our plan is to use Envoy backed by etcd, with a custom-build Endpoint Discovery Service as described in the Envoy documentation, using the v2 gRPC-based API. We'll then generate Docker images for each service and deploy/manage them with Kubernetes.
We use Maven as a build system. I'm pretty well versed in Maven, but this is my first time with gRPC or protocol buffers.
I've created a stub for my service using Spring Boot, with Jetty offering some REST and JMX endpoints for management. Before introducing the protobuf stuff, the stub built and ran just fine.
I've downloaded the Envoy data-plane-api and checked the API definition files (**/*.proto) into my project under src/main/proto, keeping the directory structure from the download (e.g. src/main/proto/envoy/api/v2/eds.proto). (Side question: do I need the BUILD files?)
In the end, I'd like a standalone Maven build that can read these files and generate Java classes. The build needs to work on Windows and OS X boxes so that it works for developers, and on Linux boxes so that it works in our CI (Bamboo). It should require nothing more than a JDK, a Maven install, and a Maven repo. (We have an Artifactory instance where I can upload artifacts not otherwise available online, if necessary.)
What I have so far seems like it will accomplish my portability goals:
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>discovery-service</artifactId>
<packaging>jar</packaging>
<name>Discovery Service</name>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}</protocArtifact>
<checkStaleness>true</checkStaleness>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<extensions>
<!-- provides os.detected.classifier (i.e. linux-x86_64, osx-x86_64) property -->
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.1.Final</version>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>io.hydrosphere</groupId>
<artifactId>envoy-data-plane-api_2.11</artifactId>
<version>v1.5.0_1</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.9.1</version>
</dependency>
<!--Unrelated deps (Spring Boot, Jetty, logging, etc) omitted for brevity -->
</dependencies>
</project>
When I build this project using mvn compile, Maven correctly downloads protoc and invokes it, but protoc errors because it can't find some external dependencies:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: osx-x86_64
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Discovery Service 1.0.0
[INFO] ------------------------------------------------------------------------
Downloading: http://devutl1.sircon.com:8081/artifactory/libs-snapshot/org/glassfish/javax.el/maven-metadata.xml
Downloading: http://devutl1.sircon.com:8081/artifactory/libs-release/org/glassfish/javax.el/maven-metadata.xml
Downloaded: http://devutl1.sircon.com:8081/artifactory/libs-release/org/glassfish/javax.el/maven-metadata.xml (882 B at 547 B/s)
Downloaded: http://devutl1.sircon.com:8081/artifactory/libs-snapshot/org/glassfish/javax.el/maven-metadata.xml (882 B at 547 B/s)
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (default-cli) # discovery-service ---
[INFO]
[INFO] --- protobuf-maven-plugin:0.5.1:compile (default) # discovery-service ---
[INFO] Compiling 56 proto file(s) to /Users/jrobb/Projects/vertabrae/trunk/scaling/discovery-service/target/generated-sources/protobuf/java
[ERROR] PROTOC FAILED: validate/validate.proto: File not found.
gogoproto/gogo.proto: File not found.
envoy/api/v2/core/address.proto: Import "validate/validate.proto" was not found or had errors.
envoy/api/v2/core/address.proto: Import "gogoproto/gogo.proto" was not found or had errors.
envoy/config/metrics/v2/stats.proto: Import "envoy/api/v2/core/address.proto" was not found or had errors.
envoy/config/metrics/v2/stats.proto: Import "validate/validate.proto" was not found or had errors.
envoy/config/metrics/v2/stats.proto:148:5: "envoy.api.v2.core.Address" is not defined.
envoy/config/metrics/v2/stats.proto:167:5: "envoy.api.v2.core.Address" is not defined.
The output continues, with the same set of errors for each .proto file.
It seems that the crux of the issue is that I don't have validate/validate.proto or gogoproto/gogo.proto, which are imported at the top of (nearly?) every .proto file:
import "google/protobuf/wrappers.proto";
import "validate/validate.proto";
import "gogoproto/gogo.proto";
It seems to be finding wrappers.proto, which I think is coming from my compile-time Maven dependency on protobuf-java.
I think gogoproto/gogo.proto might be looking for this: https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto
I'm totally stumped about where validate/validate.proto is supposed to come from. I've seen some evidence that it's specific to Envoy, but I can't find it.
I've spent the last few hours searching, and I'm coming up empty on anyone who's done this before. Where do I get those files? If I can't get them from Maven Central, I'll build them myself and upload to Artifactory.
My eyes are glazing over looking at documentation intended for people using other tech stacks, and I'm having trouble translating for my needs. Any and all help will be much appreciated, and I apologize if this is a hugely n00bish question. :)
Once again, the mere act of asking on SO has led me to the answer; found while adding context and detail to my question. There's a brand-new Java port of the Go-based Envoy control-plane: java-control-plane!
Somebody who, like me, would prefer to just depend on something from Maven Central, and already knew what they were looking for reported this issue, and while I was writing up this question, the maintainer answered: exactly that is coming soon!
I'm pleased to find that api/pom.xml in java-control-plane looks very similar to what I posted in my question. :)
So, if you find yourself in my situation, wanting to implement a Discovery Service for Envoy on a Java tech stack, java-control-plane is already there -- you just have to extend it with whatever backing store you want to use. I assume that, over time, implementations for that will pop up in the community as well. I'll be writing one for etcd and might end up contributing it back to the community.
Answering the finer details of my question:
Where do I get the two .proto file dependencies not included in data-plane-api?
They are in the java-control-plane source: they're checked in as part of the api module's source code, and therefore presumably not available as a separate dependency. I'm reasonably confident that the gogo.proto I found was the right one, but I'm still unclear on where I could have found validate.proto.
Do I need to include the BUILD files from data-plane-api in order to compile the *.proto files with protoc?
Nope! The api module in java-control-plane doesn't include them.
I want to create an EAR using Maven, but since I'm in a pure Tycho world, I can't use the maven-ear-plugin, just the maven-assembly-plugin (which is fine).
There are multiple questions even on this very site that indicate that the maven-assembly-plugin can build EARs, even though the documentation says no.
However, when I use define the EAR format like this:
<formats>
<format>ear</format>
</formats>
I get the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.0:single (make-assembly) on project org.acme.application: Failed to create assembly: Error creating assembly archive default: appxml attribute is required -> [Help 1]
(I tried a couple of versions for the maven-assembly-plugin, so it's not that.)
Since a EAR is just a renamed JAR, I'm now using the JAR format and this other Maven plug-in:
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>rename-ear</id>
<phase>verify</phase>
<goals>
<goal>rename</goal>
</goals>
<configuration>
<sourceFile>${basedir}/target/${earName}.jar</sourceFile>
<destinationFile>${basedir}/target/${earName}.ear</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
Which works nicely in creating an EAR, however with mvn install it brings the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-install) on project org.acme.application: Failed to install artifact group:org.acme.application:jar:1.9.126-SNAPSHOT: C:\workspace\Application\target\Application.jar (Das System kann die angegebene Datei nicht finden) -> [Help 1]
(It's German for "Cannot find file", one day I'll get him to print out readable error messages.)
Of course, now I could copy the JAR to an EAR instead of just renaming it, but I thought I get a 2nd oppinion first: Is it possible to create an EAR with the maven-assembly-plugin? If so, how?
I'm managing the builds for a web service with Jenkins, and I've run into a problem with Tomcat. I'm getting the following error and stack trace:
mavenExecutionResult exceptions not empty
message : Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy(default-cli) on project rnr: Cannot invoke Tomcat manager
cause : Cannot invoke Tomcat manager
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project rnr: Cannot invoke Tomcat manager
Here's my pom configuration for the Tomcat maven plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<path>/</path>
</configuration>
</plugin>
EDIT: I'm using Tomcat 7.0.42.
I'm not sure exactly what the problem is or if I've provided enough information, so let me know if more is needed. This is the first time I've run into this problem, and to my knowledge nothing in the pom or jenkins setup has changed, so I don't know where this error is coming from.
Thank you!!
We're using Maven 3.0.3 and are using JUnit 4.8.1 ...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
We have this test file ...
./src/test/java/com/myco/clearing/common/xml/TextNodeTest.java
How can I run this individual test? When I try
mvn -Dtest=TextNodeTest test
I get an error saying no tests were run. I get the same error if I specify the entire package name to my test. ...
mvn clean -Dtest=com.myco.clearing.common.xml.TextNodeTest test
which produces the error message ...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project myco-productplus-web: 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
Here is the surefire configuration I'm using
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skip>false</skip>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
<additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
</additionalClasspathElements>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
<systemProperties>
<property>
<name>gwt.args</name>
<value>-out "${webappDirectory}"</value>
</property>
</systemProperties>
<systemPropertyVariables>
<tomcat.port>${tomcat.servlet.port}</tomcat.port>
<project.artifactId>${project.artifactId}</project.artifactId>
</systemPropertyVariables>
</configuration>
</plugin>
The way to run a single test (method) in surefire is to do:
mvn test -Dtest=uk.co.farwell.AppTest#testSlow
Note the # instead of the space between the class name and the method name.
However, as #Andrew says, there is a bug in 2.12 (SUREFIRE-827: Surefire 2.12 cannot run a single test, regression from 2.11), but it works in 2.11.
The above bug is still open (as of 24.02.2012), but actually works for me using 2.13-SNAPSHOT.
EDIT: This is now marked as fixed in 2.12.1.
Looks like it's a bug in 2.12 version - SUREFIRE-827. Try downgrading to 2.11.
Like the others say, it's a bug in Surefire and it's fixed since version 2.11.1.