AppEngine Maven Plugin jarSplittingExcludes - google-app-engine

I'm trying to include the stanford-corenlp library into my AppEngine application, but am running into "JAR too big" errors when uploading:
com.google.appengine.tools.admin.LocalIOException: Jar.../stanford-corenlp-3.3.0-models.jar is too large. Consider using --enable_jar_splitting.
Unable to update app: Jar /tmp/appcfg4516706702870427847.tmp/WEB-INF/lib/stanford-corenlp-3.3.0-models.jar is too large. Consider using --enable_jar_splitting.
As suggested, I tried the enable_jar_splitting option, but some individuals files were too large and those can't be split. Looking through the plugin docs I found:
jarSplittingExcludes
User property: appengine.jarSplittingExcludes
When --enable-jar-splitting is set, files that match the list of comma
separated SUFFIXES will be excluded from all jars.
So I tried to exclude some of the large files that I'm not using with this pom.xml:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
<configuration>
<enableJarSplitting>true</enableJarSplitting>
<jarSplittingExcludes>englishRNN.ser.gz</jarSplittingExcludes>
</configuration>
</plugin>
However, now when I run
mvn appengine:update
I get:
[INFO] Updating Google App Engine Application
Bad argument: Unknown option: --jar_splitting_excludes
usage: AppCfg [options] <action> [<app-dir>] [<argument>]
...
options:
....
--enable_jar_splitting
Split large jar files (> 10M) into smaller fragments.
--jar_splitting_excludes=SUFFIXES
When --enable-jar-splitting is set, files that match
the list of comma separated SUFFIXES will be excluded
from all jars.
Any ideas on what I'm doing wrong?

Turns out it was a bug. Should be fixed in 1.9.7. You can clone the development branch for earlier access:
$ git clone https://code.google.com/p/appengine-maven-plugin/
$ cd appengine-maven-plugin
$ mvn install
and change in you pom the plugin version to 1.9.7-SNAPSHOT (keep the other artifacts the same, change only for the plugin)

Related

How to install Apache Camel?

How do you install Apache-Camel?
I've just started reading 'Camel in Action' 2nd ed.
In section 1.2.1, is suggests downloading the binary distribution.
I found this link to from the releases page:
Release 2.24.1
But I can only see a source-code download.
I've tried to compile from the source, but that always encounters an error.
How do you just install the binary on either Ubuntu/Redhat/Fedora?
Or have I misunderstood Apache-Camel as being a library that you can just install?
Must it always be compiled with maven?
Camel, Java-projects and build-tools
Apache Camel works like any other Java library or framework, meaning that in order to use the framework you'll have to include its java binaries (i.e .jar files) to your project as dependencies. Now to make things simpler most developers use either Maven or Gradle to create, manage and build their java projects.
From these two I would recommend Maven as it seems to be the preferred option for Camel developers with most examples (including ones in official camel site) using it. To install maven follow the official how to install maven guide.
Maven archetypes
To create example camel project you can use maven archetypes which are basically project templates that can be used to create various types of new projects. If you're reading Camel in Action you might be better off using Camel version 2.x.x in your projects with Java Development Kit version 8. Camel 3.x.x is pretty similar so it should be fairly easy to learn that after learning the basics with 2.x.x.
After installing maven you can use your Java IDE (i.e IntelliJ, VSCode, Eclipse or Netbeans) to create project from maven archetype with groupId: org.apache.camel.archetypes artifactId: camel-archetype-java and version: 2.25.4
Or use maven command line command:
# Create new camel java project for Camel version 2.25.4
mvn archetype:generate -DarchetypeGroupId="org.apache.camel.archetypes" -DarchetypeArtifactId=camel-archetype-java -DarchetypeVersion="2.25.4"
Camel project
The new project should contain project file pom.xml where you can specify all the dependencies for your project. The the camel-archetype-java should have the following dependencies listed in the dependencies section of pom.xml.
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>runtime</scope>
</dependency>
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
The example route in camel-archetype-java archetypes Myroutebuilder.java is pretty complex for beginners. Hello world on a timer is generally a more simpler test on to see if things work.
package com.example;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
// from("file:src/data?noop=true")
// .choice()
// .when(xpath("/person/city = 'London'"))
// .log("UK message")
// .to("file:target/messages/uk")
// .otherwise()
// .log("Other message")
// .to("file:target/messages/others");
from("timer:timerName?period=3000")
.routeId("helloWorldTimer")
.log(LoggingLevel.INFO, "Hello world");
}
}
The project generated from archetype comes with exec-maven-plugin which allows you to run the project with mvn exec:java
Java development kit - JDK
If you're using JDK 11 instead of JDK 8 you'll have to modify maven-compiler-plugin configuration a bit.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<!--
<source>1.8</source>
<target>1.8</target>
-->
<source>11</source>
<target>11</target>
</configuration>
</plugin>
If you've multiple versions of JDK installed you'll have to configure your IDE to use the correct one for the project. With IntelliJ you can configure JDK used by the project from project structure settings.
With VSCode you'll need both JDK 11 and JDK 8 as VSCode Java extensions require JDK 11 to run.
Example settings.json entries for OpenJDK:
"java.configuration.runtimes": [
{
"name": "JavaSE-11",
"path": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.x.x.xxx-hotspot",
"default": true
},
{
"name": "JavaSE-1.8",
"path": "C:\\Program Files\\RedHat\\java-1.8.0-openjdk-1.8.0.xxx-x",
}
],
"java.home": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.x.x.xxx-hotspot"
You might also want to setup your path variable so that java -version returns correct version from the command-line.
What you really need is download the binaries for Apache Camel. The best way to get them is make use of maven (https://maven.apache.org/install.html), and existing project from GitHub and get started.
You can go to the following link: https://github.com/dilipsundarraj1/TeachApacheCamel. You can either download the project as zip file or clone the project (you need to have git installed on your machine).
After you downloaded / cloned the project use go to one of the projects: learncamel-simple-file and open the folder in command prompt.
In the command prompt run the command mvn dependency:resolve. (I am assuming you have maven and java installed on your machine). This command will download all the required binaries in the folder: c:\user\<userid>\.m2\repository, where userid is specific to you machine.
Hope it helps.

upgraded flink from 1.10 to 1.11, met error 'No ExecutorFactory found to execute the application'

java.lang.IllegalStateException: No ExecutorFactory found to execute the application.
at org.apache.flink.core.execution.DefaultExecutorServiceLoader.getExecutorFactory(DefaultExecutorServiceLoader.java:84)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:1803)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1713)
at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.execute(LocalStreamEnvironment.java:74)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1699)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1681)
at com.cep.StaticAlarmGenerationEntryTest.main(StaticAlarmGenerationEntryTest.java:149)
The error I met after I upgraded FLink from 1.10 to 1.11, and my IDE is eclipse.
and I tried to add artifactId:flink-clients_${scala.binary.version}, but still failed. Anybody already met and solved this issue, pls tell me. thanks a lot.
See the 1.11 release note, where you now have to add an explicit dependency on flink-clients.
I have solved my problem this way :
1.Use Java 8, apparently Flink has some sort of problem with Java 11 or 15
2.Change all the Scopes to "compile"
you can change scopes in this path : Project Structure → Modules → Dependencies → There is a table that one of its column's name is Scope
I found the reason why the error happened event I add dependency flink-clients. I upgraded Flink from 1.10 to 1.11, just edited the version of Flink, but not changed Scala version. Here also should change Scala version to 2.12. And the project is generated base on 1.10 archetype and Scala version is 2.11. Every time I build the project, it use the 2.11 environments.
So the fast way to solve this issue is :
use mvn archetype:generate -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-java -DarchetypeVersion=1.11.0 this command to generate new project.
copy all your old code to this new project. You will find that the flink-clinets already added in the pom.xml.
I had this problem when I was packaging up the flink job in a shaded jar. When shading, if there are files with the same name in multiple jars it will overwrite the file as it unzips each jar into the new shaded jar.
Flink uses the file META-INF/services/org.apache.flink.core.execution.PipelineExecutorFactory to discover different executor factories and this file is present in multiple jars, each with different contents.
To fix this, I had to tell the maven-shade plugin to combine these files together as it came across them, and this solved the problem for me.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>job</shadedClassifierName>
<transformers>
<!-- add this to combine the PipelineExecutorFactory files into one -->
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/org.apache.flink.core.execution.PipelineExecutorFactory</resource>
</transformer>
</transformers>
...

"mvn allure:serve" generates report to an temp folder

I was going through the io.qameta.allure documentation and saw this option to generate allure report using "mvn allure:serve"
mvn allure:serve
The report will be generated into a temp folder. The web server with results will start. You can additionally configure the server timeout
regarding the below lines, can we modify in the configuration to generate reports under the particulate folder instead of the temp folder?
do anyone have information about it using this command only?
You can do it by defining a configuration > reportDirectory for allure-maven in your pom.xml file.
Example: in a java/selenium/testng project, here is the reporting section of pom.xml file:
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.10.0</version>
<configuration>
<reportVersion>${allure.version}</reportVersion>
<reportDirectory>allure-report/</reportDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
In order to generate allure reports you need to use: mvn allure:report.
To specify the path of the report generated use the allure maven plugin and in the pom.xml file use this:
<configuration>
<reportVersion>2.14.0</reportVersion>
<resultsDirectory>*allure result path*</resultsDirectory>
<reportDirectory>*allure report path*</reportDirectory>
</configuration>
The following command: mvn allure:serve always uses a temp folder on your device and I haven't seen anywhere in their documentation the ability of defining the path when using the serve command.

Error resolving version for plugin 'org.apache.maven.plugins:maven-jar-plugin' from the repositories ,Plugin not found in any plugin repository

I am trying to Maven build my Java project but it is getting failed and i am getting below error:
Error resolving version for plugin 'org.apache.maven.plugins:maven-jar-plugin' from the repositories [local (C:\Users\Vinita.Gupta.m2\repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
I am trying to build the project in Eclipse Neon and have installed and setup Maven path,m2connector for Eclipse.
Note: I am not connected to network using any proxy
Most of the solutions which i have found online were having issues due to proxy settings but i am directly connected to network and able to browse below directory via browser but couldn't connect through Maven:
https://repo.maven.apache.org/maven2
Please help !!
I had the same error, but for the maven-failsafe-plugin.
With the help of a colleague, we got rid of the problem adding the version line to the plugin declaration in the project pom.xml. We added the <version>2.20.1</version> line resulting in the following plugin declaration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<skipTests>false</skipTests>
<argLine>-Djava.library.path=${project.parent.basedir}/lib/${arquitecturaMaquina}</argLine>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
It is a long working project (over a year) and never had this error. I do not know what triggered it, but all the other answers about resetting the local repository, checking the proxy, etc did not work.
Then we added that version line to the pom.xml and the project built correctly again. Now I removed the line and it is still working. My guess is that it indeed had something to do with some messed up cache of some kind, and that requiring the specific version got rid of the mess and now it is working as before the problem appeared.
Add this to your pom.xml and it should work
<pluginRepositories>
<pluginRepository>
<id>maven2</id>
<url>https://repo.maven.apache.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
I had a weird solution. I got the same error when i was connected in Office LAN. Once I switched to common wifi, the error was not thrown. So i believe this is more to do with the network restriction.
Spent a day working on it, finally, the solution was to change the URL in settings.xml of a .m2 directory
old line was:
<url>http://blah:8081/bla/blabla/</url>
However, for a reason unknown to me, and from my machine only, the URL was getting rejected. As a result, I was getting the error mentioned in a title... Therefore, the solution was to put the full URL such as:
<url>http://blah.org.blah:8081/bla/blabla/</url>
-Then, simply re-open IDE (if using it), update the project (build, clean or whatever else is necessary to refresh).
You may also need to specify <port> or to add the proxy settings, but none of that was required in my case. Therefore, the solution is about adjusting the settings.xml. I have tried adding the version numbers as suggested and it was a partial solution. Cleaning and updating the project (without the settings.xml change) did nothing. Removing *.lastUpdated from .m2 was not a solution either.
What worked for me was to add a Proxy Bypass for repo.maven.apache.org under ‘Window’ > ‘Preferences’ > ‘General’ > ‘Network connections’.
After that I ran into compilation errors related to certain classes not being resolved. Just did a clean and build, viola Build Successful!
Check settings.xml file is available in C:\Users\username.m2\settings.xml and change below
C:/Users/username/.m2/repository
Its worked for me.
Added this to pom.xml and update project.
Worked for me.
<build>
<finalName>spring-security-demo</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>

Maven surefire report's filename has redundant spaces when the tests are written using cucumber

I am using maven-surefire-plugin version 2.16 along with tests written using cucumber. The .xml and .txt reports do come up fine in the sure-fire reports folder. The text within the the .xml and .txt file along with the names has a lot of extra spaces that is proportional to the number of step definitions executed cumulatively. Also the filename has a number of spaces proportional to number of steps executed. In case I run a lot of tests then the file simply does not save with the following exception
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project **:
Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test failed: org.apache.maven.surefire.util.NestedRuntimeException: null;
nested exception is org.apache.maven.surefire.report.ReporterException:
Unable to create file for report: /Users/kgupta2/git/$$$$$$$$/target/surefire-reports/Scenario: Using $$$$$ .txt (File name too long);
nested exception is java.io.FileNotFoundException: /Users/kgupta2/git/$$$$$$$$/target/surefire-reports/Scenario: Using $$$$$$$$ .txt (File name too long)
-> [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/PluginExecutionException
Clearly the filename becomes long and I have verified that it is proportional to the number of steps executed. I am running cucumber using JUnit.
Here is my configuration for maven-surefire-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<includes>
<include>**/CucumberJunitRun.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
</dependency>
</dependencies>
</plugin>
I am unable to understand why these additional spaces pop up.
I got this to work. It was an issue with incorrect configuration of plugins. Since I was using JUnit to run my cucumber tests, I went ahead and removed all references of TestNG from my pom and that got it to work magically. Some references of TestNG were coming from my parent pom. Just checked that my effective pom had some dependency of testNG. Really do not have a great clue as to why this was happening. But the correct configuration fixed a bunch of other errors that were creeping in

Resources