java.lang.NoSuchMethodError: org.glassfish.jersey.server.ApplicationHandler.<init> - java

I've been trying to debug this issue for a bit now, and searching SO and other websites I haven't been able to find a solution. I've checked all versions of the dependencies in my pom.xml and made sure they are compatible with grizzly2, and I've also verified that it is being imported. However, Java is still printing out this error upon run:
Exception in thread "main" java.lang.NoSuchMethodError: org.glassfish.jersey.server.ApplicationHandler.<init>(Ljavax/ws/rs/core/Application;Lorg/glassfish/hk2/utilities/Binder;)V
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.<init>(GrizzlyHttpContainer.java:334)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:122)
at com.kyrahosting.daemon.Main.startServer(Main.java:30)
at com.kyrahosting.daemon.Main.main(Main.java:34)
Here is my pom.xml:
4.0.0
<groupId>com.kyrapanel.daemon</groupId>
<packaging>jar</packaging>
<name>KyraPanel Daemon</name>
<artifactId>KyraDaemon</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-all</artifactId>
<version>2.3.30</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- any other plugins -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.kyrahosting.daemon.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jersey.version>2.17</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Any help will be appreciated!

Don't mix your Jersey versions
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.25.1</version>
</dependency>
Which one is different? Fix it.
And get rid of this
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-all</artifactId>
<version>2.3.30</version>
</dependency>
jersey-container-grizzly2-http already pulls in everything you need for Grizzly.
As an aside, the error says nothing about "GrizzlyHttpServerFactory doens't exist". It's saying that there is no such method (in this case constructor)
public ApplicationHandler(Application application, Binder binder) {}
That's how you read this
java.lang.NoSuchMethodError: org.glassfish.jersey.server.ApplicationHandler.<init>(Ljavax/ws/rs/core/Application;Lorg/glassfish/hk2/utilities/Binder;)V
The reason you would get this error when mixing versions is because say some class in Jersey 2.25.1 is trying to call the constructor mentioned above. But in version 2.9.1 this constructor doesn't exist. Say it wasn't added til a later version. But when loading classes, the ApplicationHandler from 2.9.1 is loaded, instead of the one from 2.25.1. So now you have the wrong ApplicationHandler version loaded. Hence the error; there's no such constructor.

I was facing an issue similar to the one asked here with my Spring Boot Application. My application was unable to find LocalizationMessages class under org.glassfish.jersey.internal in place of org.glassfish.jersey.server.ApplicationHandler. with the same error java.lang.NoSuchMethodError .
java.lang.NoSuchMethodError: org.glassfish.jersey.internal.LocalizationMessages.WARNING_PROPERTIES()Ljava/lang/String
2021-09-20 15:27:47.927 INFO 11 --- [http-nio-9070-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.glassfish.jersey.internal.LocalizationMessages.WARNING_PROPERTIES()Ljava/lang/String;] with root cause
The irony is that the same set of dependencies worked fine on a java maven project. On getting the dependency tree mvn dependency:tree for java project I was able to get class org.glassfish.jersey.internal.LocalizationMessages but it was missing on the dependency tree for Spring Boot Project.
Following Issues observed:
The Jar created by Spring Boot was not containing the dependency when I was using spring-boot-maven-plugin with version 2.4.3
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.3</version>
</plugin>
When I was trying to create a shaded jar with the above version then I was getting error for all the Transformer implementation I was using. Error ex: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ServicesResourceTransformer
I changed the version to 1.5.8.RELEASE and then the shaded jar compilation went through.
I replaced the default Spring Boot Application Plugin with the shaded jar Plugin.
Default Spring Boot Application Plugin
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
<configuration>
<mainClass>com.rohit.agrawal.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Shaded Jar Plugin I used to resolve error
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
</dependency>
</dependencies>
<configuration>
<keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
<resource>META-INF/spring.factories</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.rohit.agrawal.Application</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
</plugin>
</plugins>
</build>
Please see that here spring-boot-version is 1.5.8.RELEASE
Now the Jar has the required class:
rohiagra-mac:faw-qa-api rohiagra$ jar -tvf target/faw-qa-api-1.0-SNAPSHOT.jar | grep "org.glassfish.jersey.internal.LocalizationMessages"
42097 Tue Sep 21 18:01:54 IST 2021 BOOT-INF/classes/org/glassfish/jersey/internal/LocalizationMessages.class
268 Tue Sep 21 18:01:56 IST 2021 BOOT-INF/classes/org/glassfish/jersey/internal/LocalizationMessages$1.class
1272 Tue Sep 21 18:01:56 IST 2021 BOOT-INF/classes/org/glassfish/jersey/internal/LocalizationMessages$BundleSupplier.class

In Dec.2017, this set of Maven dependencies worked fine for me to start Jetty with RS.
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles.repackaged</groupId>
<artifactId>jersey-guava</artifactId>
<version>2.26-b03</version>
</dependency>

Related

java.lang.NoClassDefFoundError: jakarta/ws/rs/core/MultivaluedMap

I updated my project to Java 17/Wildfly 27/Keycloak 19 and I get the error:
java.lang.NoClassDefFoundError: jakarta/ws/rs/core/MultivaluedMap
The library Maven: jakarta.ws.rs-api is added in the library of the project via Maven: jakarta.ws.rs:jakarta.ws.rs-api:3.1.0
Does somebody know why this happens?
My pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mainProject</artifactId>
<groupId>ch.company.mainProject</groupId>
<version>4.5.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>auth-post</artifactId>
<name>Project Auth Post (Keycloak Setup)</name>
<description>This project is responsible to setup Keycloak.</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>ch.company.project.AuthPostMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>ch.company.project.AuthPostMain</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>ch.company.project</groupId>
<artifactId>common</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client-jakarta</artifactId>
<version>19.0.0</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
</dependencies>
</project>
Stacktrace:
"C:\Program Files\ojdkbuild\jdk-17.0.2\bin\java.exe" -
Dtenant.config=../e2e-test/src/main/resources/e2e-config "-
javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\lib\idea_rt.jar=55918:C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\bin" -Dfile.encoding=UTF-8 -classpath C:\work\project\auth-post\target\classes;C:\work\project\common\target\classes;C:\Users\maku\.m2\repository\org\keycloak\keycloak-admin-client-jakarta\19.0.0\keycloak-admin-client-jakarta-19.0.0.jar;C:\Users\maku\.m2\repository\org\keycloak\keycloak-core\19.0.0\keycloak-core-19.0.0.jar;C:\Users\maku\.m2\repository\org\keycloak\keycloak-common\19.0.0\keycloak-common-19.0.0.jar;C:\Users\maku\.m2\repository\org\jboss\resteasy\resteasy-client\6.2.2.Final\resteasy-client-6.2.2.Final.jar;C:\Users\maku\.m2\repository\org\jboss\resteasy\resteasy-client-api\6.2.2.Final\resteasy-client-api-6.2.2.Final.jar;C:\Users\maku\.m2\repository\org\jboss\resteasy\resteasy-core-spi\6.2.2.Final\resteasy-core-spi-6.2.2.Final.jar;C:\Users\maku\.m2\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;C:\Users\maku\.m2\repository\org\jboss\resteasy\resteasy-core\6.2.2.Final\resteasy-core-6.2.2.Final.jar;C:\Users\maku\.m2\repository\org\jboss\jandex\2.4.3.Final\jandex-2.4.3.Final.jar;C:\Users\maku\.m2\repository\jakarta\activation\jakarta.activation-api\2.1.0\jakarta.activation-api-2.1.0.jar;C:\Users\maku\.m2\repository\org\eclipse\angus\angus-activation\1.0.0\angus-activation-1.0.0.jar;C:\Users\maku\.m2\repository\com\ibm\async\asyncutil\0.1.0\asyncutil-0.1.0.jar;C:\Users\maku\.m2\repository\org\jboss\logging\jboss-logging\3.5.0.Final\jboss-logging-3.5.0.Final.jar;C:\Users\maku\.m2\repository\org\apache\httpcomponents\httpclient\4.5.14\httpclient-4.5.14.jar;C:\Users\maku\.m2\repository\org\apache\httpcomponents\httpcore\4.4.16\httpcore-4.4.16.jar;C:\Users\maku\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\maku\.m2\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\maku\.m2\repository\org\reactivestreams\reactive-streams\1.0.4\reactive-streams-1.0.4.jar;C:\Users\maku\.m2\repository\org\jboss\resteasy\resteasy-jaxrs\3.15.3.Final\resteasy-jaxrs-3.15.3.Final.jar;C:\Users\maku\.m2\repository\org\jboss\spec\javax\ws\rs\jboss-jaxrs-api_2.1_spec\2.0.1.Final\jboss-jaxrs-api_2.1_spec-2.0.1.Final.jar;C:\Users\maku\.m2\repository\org\jboss\spec\javax\xml\bind\jboss-jaxb-api_2.3_spec\2.0.1.Final\jboss-jaxb-api_2.3_spec-2.0.1.Final.jar;C:\Users\maku\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\Users\maku\.m2\repository\org\jboss\spec\javax\annotation\jboss-annotations-api_1.3_spec\2.0.1.Final\jboss-annotations-api_1.3_spec-2.0.1.Final.jar;C:\Users\maku\.m2\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;C:\Users\maku\.m2\repository\commons-io\commons-io\2.6\commons-io-2.6.jar;C:\Users\maku\.m2\repository\com\github\stephenc\jcip\jcip-annotations\1.0-1\jcip-annotations-1.0-1.jar;C:\Users\maku\.m2\repository\org\jboss\resteasy\resteasy-jaxb-provider\6.2.2.Final\resteasy-jaxb-provider-6.2.2.Final.jar;C:\Users\maku\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\4.0.0\jakarta.xml.bind-api-4.0.0.jar;C:\Users\maku\.m2\repository\org\glassfish\jaxb\codemodel\4.0.1\codemodel-4.0.1.jar;C:\Users\maku\.m2\repository\org\glassfish\jaxb\jaxb-core\4.0.1\jaxb-core-4.0.1.jar;C:\Users\maku\.m2\repository\org\glassfish\jaxb\jaxb-jxc\4.0.1\jaxb-jxc-4.0.1.jar;C:\Users\maku\.m2\repository\org\glassfish\jaxb\jaxb-runtime\4.0.1\jaxb-runtime-4.0.1.jar;C:\Users\maku\.m2\repository\org\glassfish\jaxb\txw2\4.0.1\txw2-4.0.1.jar;C:\Users\maku\.m2\repository\org\glassfish\jaxb\jaxb-xjc\4.0.1\jaxb-xjc-4.0.1.jar;C:\Users\maku\.m2\repository\org\glassfish\jaxb\xsom\4.0.1\xsom-4.0.1.jar;C:\Users\maku\.m2\repository\com\sun\istack\istack-commons-runtime\4.1.1\istack-commons-runtime-4.1.1.jar;C:\Users\maku\.m2\repository\com\sun\istack\istack-commons-tools\4.1.1\istack-commons-tools-4.1.1.jar;C:\Users\maku\.m2\repository\com\sun\xml\bind\external\relaxng-datatype\4.0.1\relaxng-datatype-4.0.1.jar;C:\Users\maku\.m2\repository\com\sun\xml\bind\external\rngom\4.0.1\rngom-4.0.1.jar;C:\Users\maku\.m2\repository\org\jboss\resteasy\resteasy-jackson2-provider\6.2.2.Final\resteasy-jackson2-provider-6.2.2.Final.jar;C:\Users\maku\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.14.1\jackson-core-2.14.1.jar;C:\Users\maku\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.4.2\jackson-databind-2.13.4.2.jar;C:\Users\maku\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.4\jackson-annotations-2.13.4.jar;C:\Users\maku\.m2\repository\com\fasterxml\jackson\jakarta\rs\jackson-jakarta-rs-base\2.13.4\jackson-jakarta-rs-base-2.13.4.jar;C:\Users\maku\.m2\repository\com\fasterxml\jackson\jakarta\rs\jackson-jakarta-rs-json-provider\2.13.4\jackson-jakarta-rs-json-provider-2.13.4.jar;C:\Users\maku\.m2\repository\com\fasterxml\jackson\module\jackson-module-jakarta-xmlbind-annotations\2.13.4\jackson-module-jakarta-xmlbind-annotations-2.13.4.jar;C:\Users\maku\.m2\repository\com\github\java-json-tools\json-patch\1.13\json-patch-1.13.jar;C:\Users\maku\.m2\repository\com\github\java-json-tools\msg-simple\1.2\msg-simple-1.2.jar;C:\Users\maku\.m2\repository\com\github\java-json-tools\btf\1.3\btf-1.3.jar;C:\Users\maku\.m2\repository\com\github\java-json-tools\jackson-coreutils\2.0\jackson-coreutils-2.0.jar ch.company.project.AuthPostMain
Fehler: Hauptklasse ch.company.project.AuthPostMain kann nicht initialisiert werden
Ursache: java.lang.NoClassDefFoundError: jakarta/ws/rs/core/MultivaluedMap
WildFly (and other JEE / Jakarta EE containers) provide their own Java EE / Jakarta EE classes (servlet API, JAX-RS, JPA, etc.). If you bundle them in your application, these classes will be not be used by WildFly. Even if the class files are identical, the classes in your application are not the same as the provided classes - they have different class loaders. Class equality does not just use the fully qualified class name, it also uses the class loader. As a result, you will most likely get a class mismatch. You didn't show the full stack trace, but this is a likely cause of it.
Mark these dependencies as provided, that should usually solve the issue. You will also have to do something in your shade plugin if they still get included.
The same goes for the RESTEasy dependencies, although that's specific to WildFly / JBoss.
Deleted .idea and reimported everything and now it works

Incompatible class versions when submitting Flink a job

I'm trying to submit a streaming job using Beam 2.27/Flink 1.12, using the following Maven command-line:
mvn exec:java -Dexec.mainClass=org.example.MyPipelineClass -Pflink-runner -Dexec.args="--runner=FlinkRunner --flinkMaster=flink-host:8081 --filesToStage=target/pipelines-bundled-1.0.0.jar"
Things were working smoothly for a bit, but I recently made some edits and wanted to run a new version of the pipeline and am now getting the following error:
Caused by: java.io.InvalidClassException: org.apache.flink.streaming.api.graph.StreamConfig$NetworkInputConfig; local class incompatible: stream classdesc serialVersionUID = -3137689219135046939, local class serialVersionUID = 3698633776553163849
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:699)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2003)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1850)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2160)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1667)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:2093)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1655)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:503)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:461)
at org.apache.flink.util.InstantiationUtil.deserializeObject(InstantiationUtil.java:615)
at org.apache.flink.util.InstantiationUtil.deserializeObject(InstantiationUtil.java:600)
at org.apache.flink.util.InstantiationUtil.deserializeObject(InstantiationUtil.java:587)
at org.apache.flink.util.InstantiationUtil.readObjectFromConfig(InstantiationUtil.java:541)
at org.apache.flink.streaming.api.graph.StreamConfig.getInputs(StreamConfig.java:263)
... 21 more
My pom.xml looks something like this:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>pipelines</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<beam.version>2.27.0</beam.version>
<flink.version>1.12</flink.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-exec-plugin.version>1.6.0</maven-exec-plugin.version>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<maven-shade-plugin.version>3.1.0</maven-shade-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-bundled-${project.version}</finalName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/LICENSE</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${maven-exec-plugin.version}</version>
<configuration>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>flink-runner</id>
<dependencies>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-flink-${flink.version}</artifactId>
<version>${beam.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-core</artifactId>
<version>${beam.version}</version>
</dependency>
<!-- note that the pipeline runs on GCP -->
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
<version>${beam.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-client-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- main output is JDBC/Postgres -->
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-io-jdbc</artifactId>
<version>${beam.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.4</version>
</dependency>
</dependencies>
</project>
Of course, before submitting the job I built the JAR using mvn clean package -Pflink-runner.
Flink is self-hosted on a GKE instance, and is deployed using the flink:1.12.4-java8 image.
I found this issue which seems to have the same error message, but no clear offender.
Any help or ideas to explore would be greatly appreciated, I have no idea what to investigate.
I found the issue own my own. In the pom.xml above, I specified that the Beam runner was beam-runners-flink-1.12, and the cluster was running Flink 1.12.4
Beam's Flink runner does not specify a patch, and uses Flink 1.12.0
Downgrading the cluster fixed my issue.

Errors with deeplearning4j and Maven

Here is the tutorial I'm following.
The pom.xml file is the default one that comes with the dl4j examples folder so there shouldn't be issues there but it still has errors.
Here's the code:
package org.deeplearning4j.self;
import org.deeplearning4j.datasets.iterator.impl.EmnistDataSetIterator;
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.layers.DenseLayer;
import org.deeplearning4j.nn.conf.layers.OutputLayer;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.nn.weights.WeightInit;
import org.nd4j.linalg.activations.Activation;
import org.nd4j.linalg.learning.config.Adam;
import org.nd4j.linalg.lossfunctions.LossFunctions;
import java.io.IOException;
public class first {
int batchSize = 128; // how many examples to simultaneously train in the network
EmnistDataSetIterator.Set emnistSet = EmnistDataSetIterator.Set.BALANCED;
EmnistDataSetIterator emnistTrain;
{ try { emnistTrain = new EmnistDataSetIterator(emnistSet, batchSize, true); } catch (IOException e) { e.printStackTrace(); } }
EmnistDataSetIterator emnistTest;
{ try { emnistTest = new EmnistDataSetIterator(emnistSet, batchSize, false); } catch (IOException e) { e.printStackTrace(); } }
int outputNum = EmnistDataSetIterator.numLabels(emnistSet);// total output classes
int rngSeed = 123; // integer for reproducability of a random number generator
int numRows = 28; // number of "pixel rows" in an mnist digit
int numColumns = 28;
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.seed(rngSeed)
.updater(new Adam())
.l2(1e-4)
.list()
.layer(new DenseLayer.Builder()
.nIn(numRows * numColumns) // Number of input datapoints.
.nOut(1000) // Number of output datapoints.
.activation(Activation.RELU) // Activation function.
.weightInit(WeightInit.XAVIER) // Weight initialization.
.build())
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
.nIn(1000)
.nOut(outputNum)
.activation(Activation.SOFTMAX)
.weightInit(WeightInit.XAVIER)
.build())
.build();
MultiLayerNetwork network = new MultiLayerNetwork(conf);
network.init();
// pass a training listener that reports score every 10 iterations
int eachIterations = 10;
network.addListeners(new ScoreIterationListener(eachIterations));
}
I'm using IntelliJ.
The errors I'm getting in the class is:
Both methods called on "network" aren't recognized, both "init()" and "addListeners()" have "Cannot resolve symbol" on them. It also says on "network" that the "Field network is never used".
Additionally the int "eachIterations" has an "Unknown class" error inside of the addListeners() method.
Here's the pom.xml file:
<?xml version="1.0" encoding="UTF-8"?> <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Copyright (c) 2020 Konduit K.K. ~ Copyright (c) 2015-2019 Skymind, Inc. ~ ~ This program and the accompanying materials are made available under the ~ terms of the Apache License, Version 2.0 which is available at ~ https://www.apache.org/licenses/LICENSE-2.0. ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the ~ License for the specific language governing permissions and limitations ~ under the License. ~ ~ SPDX-License-Identifier: Apache-2.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<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>org.deeplearning4j</groupId>
<artifactId>dl4j-examples</artifactId>
<version>1.0.0-beta7</version>
<name>Introduction to DL4J</name>
<description>A set of examples introducing the DL4J framework</description>
<properties>
<dl4j-master.version>1.0.0-beta7</dl4j-master.version>
<!-- Change the nd4j.backend property to nd4j-cuda-X-platform to use CUDA GPUs -->
<!-- <nd4j.backend>nd4j-cuda-10.2-platform</nd4j.backend> -->
<nd4j.backend>nd4j-native</nd4j.backend>
<java.version>1.8</java.version>
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
<maven.minimum.version>3.3.1</maven.minimum.version>
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<jcommon.version>1.0.23</jcommon.version>
<jfreechart.version>1.0.13</jfreechart.version>
<logback.version>1.1.7</logback.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.29</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>4.1.48.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>${nd4j.backend}</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.datavec</groupId>
<artifactId>datavec-api</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.datavec</groupId>
<artifactId>datavec-data-image</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.datavec</groupId>
<artifactId>datavec-local</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-datasets</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-ui</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-zoo</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<!-- ParallelWrapper & ParallelInference live here -->
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-parallel-wrapper</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<!-- Used in the feedforward/classification/MLP* and feedforward/regression/RegressionMathFunctions example -->
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>${jfreechart.version}</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>${jcommon.version}</version>
</dependency>
<!-- Used for downloading data in some of the examples -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.datavec</groupId>
<artifactId>datavec-data-codec</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
<!-- Maven Enforcer: Ensures user has an up to date version of Maven before building -->
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-default</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[${maven.minimum.version},)</version>
<message>********** Minimum Maven Version is ${maven.minimum.version}. Please upgrade Maven before continuing (run "mvn --version" to check). **********</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<version>0.0.11</version>
<configuration>
<failOnViolation>true</failOnViolation>
<onlyRunRules>
<rule>DuplicateDep</rule>
<rule>RedundantPluginVersion</rule>
<!-- Rules incompatible with Java 9
<rule>VersionProp</rule>
<rule>DotVersionProperty</rule> -->
</onlyRunRules>
</configuration>
<executions>
<execution>
<id>pom-lint</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>${shadedClassifier}</shadedClassifierName>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>org/datanucleus/**</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<versionRange>[0.0.11,)</versionRange>
<goals>
<goals><goal>check</goal></goals>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build> </project>
The error here is "${shadedClassifier}" shadedClassifier is red and the error is: "Cannot resolve symbol 'shadedClassifier'"
So I reinstalled maven with "mvn clean install" but it still doesn't work.
Maven has installed correctly with clean install but still I have these errors.
Please any help would be appriciated. I've been stuck on this for a week and I really want to learn machine learning.
I'm guessing maven isn't setup properly. I would ensure the IDE is up to date. Right clicking on the project in intellij and hitting reload is something I would consider doing. Same answer as here: Force Intellij IDEA to reread all maven dependencies

Exclude javax.servlet package from com.google.gwt dependency on pom.xml

I use Vaadin 7, and vaadin have a default package javax.servlet and I need com.google.gwt in my dependencies which contains another javax.servlet. When I run my application I got this error :
SEVERE: Allocate exception for servlet Vaadin Application Servlet
java.lang.ClassCastException: com.vaadin.server.VaadinServlet cannot be cast to javax.servlet.Servlet
Now I want to exclude javax.servlet from this dependency, and here is what I tried so far :
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.6.1</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
and this :
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<minimizeJar>true</minimizeJar>
<artifact>com.google.gwt:gwt-user</artifact>
<includes>
<include>com/google/**</include>
</includes>
<excludes>
<exclude>javax/servlet/**</exclude>
<exclude>javax/servlet/http/**</exclude>
<exclude>javax/servlet/resources/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
But both didn't work !. Help!
I think you actually want the gwt-servlet dependency rather than gwt-user.
That said, I don't know Vaadin; maybe there's a com.vaadin dependency that contains the GWT classes?
According to your 2nd try, exclude the required package in a way given below:
Example :
<configuration>
<packagingExcludes>
WEB-INF/lib/servlet-api*.jar,
WEB-INF/lib/jsp-api*.jar,
WEB-INF/lib/jstl-api*.jar,
</packagingExcludes>
</configuration>

Jasper Reports w/ Maven - How do I specify Java version to compile with?

Is there any way I can specify which version of Java to use when compiling my .jrxml files with Jasper Reports in Maven (using jasperreports-maven-plugin)? I saw this blog post saying claiming that Jasper uses the "default virtual machine set in your computer" and not "same version of the maven-compiler-plugin". If I cannot change or guarantee the JAVA_HOME environment variable, how can I get Jasper to compile with Java6?
Here is a snippet from my pom.xml:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<configuration>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.0.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
</plugins>
Looking on the Codehaus docs, there is a parameter you can use, but it doesn't say how to specify which Java version.
Thanks!
According to this issue the folllowing parameters can help you:
<configuration>
...
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
...
</configuration>
1.0-beta-2, however, does not have these properties, so the later version is necessary. You can either use a snapshot plugin version from here, of build a plugin from source code yourself. As far as I can see, plugin code from trunk supports these parameters.
I had to make some additional configurations:
set eclipse:jdtcore as exclusion in jasperresports;
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.6.0</version>
<exclusions>
<exclusion>
<groupId>eclipse</groupId>
<artifactId>jdtcore</artifactId>
</exclusion>
</exclusions>
</dependency>
set org.eclipse.jdt.core.compiler:ecj as plugin dependency;
jasperreports-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<version>1.0-beta-4-OPENNMS-20160912-1</version>
<configuration>
<outputDirectory>src/main/webapp/WEB-INF/reports</outputDirectory>
<maven.compiler.source>${compileSource}</maven.compiler.source>
<maven.compiler.target>${compileSource}</maven.compiler.target>
<compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
Note: the dependencies order of plugin jasperreports-maven-plugin was relevant for me (don't ask me why).

Categories

Resources