Issue when flink upload a job with stream sql query - sbt

I used the latest flink version(1.10.0) and sbt(1.3.7). I have this exception when upload a job with streaming sql query:
Caused by: java.lang.ClassCastException:
org.codehaus.janino.CompilerFactory cannot be cast to
org.codehaus.commons.compiler.ICompilerFactory
at org.codehaus.commons.compiler.CompilerFactoryFactory.getCompilerFactory(CompilerFactoryFactory.java:129)
at org.codehaus.commons.compiler.CompilerFactoryFactory.getDefaultCompilerFactory(CompilerFactoryFactory.java:79)
at org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.compile(JaninoRelMetadataProvider.java:432)
When I running main class with sbt run it works perfectly. I made jar with the sbt assembly command and I have conflicts between libraries. For this reason add this in the build.sbt:
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
I read a similar case with hive connector https://issues.apache.org/jira/browse/FLINK-14849 and this is the answer:
After https://issues.apache.org/jira/browse/FLINK-13749 , flink-client will use default child-first resolve-order.
If user jar has some conflict dependents, there will be some problem.
My question is: How to resolve these conflicts? Any assembly merge strategy suggest for this case?
Help would be appreciated.

I faced the same issue and the following solution helped me get through :
assembly / assemblyMergeStrategy := {
case PathList("org", "codehaus", "janino", "CompilerFactory.class") => MergeStrategy.discard // discard
case x => MergeStrategy.first // first
}
Also, took help from the this link.
The above addition needs to be done in sbt.build file and make sure you're building using assembly command.
In case one is building using package-bin in case of legacy applications, follow this link.
Another solution includes checking the scope of the flink libraries. If by any chance you have accidentally pushed libraries that were earlier set to 'provided' with something like 'compile', do revert the changes and test.
Hope this helps.

I have same problem.
Maybe you have package your code with flink-table-planner_${scala.binary.version}, so you need to change your maven config with those settings:
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>

I had the same issue. My problem was, that I added the dependency
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
without the provided scope. Therefore, maven packaged it in my jar, which lead to the ClassCastException when trying to submit the job to my local flink cluster.

Related

NoClassDefFoundError for a class due to the interrelative dependencies in karaf

Consider the below scenario where i am getting an unexpected error and unable to fix it.
In Opendaylight architype project, I just used a class(Say test.class from io-example dependency) when I just declared only one dependency (i.e io-example) in the pom.xml, there is no error.
But if i add one more dependency (io-example-api) in the pom.xml, I am getting java.lang.NoClassDefFoundError: io/example/test.class
at org.opendaylight.gnmi.impl.base.OpenconfigInter
..................................................
..................................................
Caused by: java.lang.ClassNotFoundException: io.example.Test cannot be found by org.opendaylight
I found that io.example-api has the io-example as the dependency.. Summarize the issue, If i have the io-example alone in the pom.xml, there is no issue. If I have both io-example and io-example-api in the pom.xml, I am getting the NoclassDef error.
Even I have tried the exclusion option in the dependency section, Nothing works.
Thanks in advance...
Edited:
classname : io.grpc.Context
Dependencies :
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-context</artifactId>
<version>1.38.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>1.38.0</version>
</dependency>
In karaf container, I ran the "package:exports" commands and the results are,
opendaylight-user#root>package:exports -p io.grpc
io.grpc 0.0.0 354 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-api_1.38.0_grpc-api-1.38.0.jar
io.grpc 0.0.0 355 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-context_1.38.0_grpc-context-1.38.0.ja
opendaylight-user#root>package:exports -d
io.grpc 0.0.0 354 355
You can see that, io.grpc package exported by two bundles (354 and
355)..
A common cause for ClassNotFoundException in OSGi and Karaf is that multiple bundles export the same package with the same version. This causes only one of them be imported which may or may not contain your Test class.
Check which packages export io.example with package:exports command:
packages:exports -p io.example
I am guessing that adding the dependency causes your bundle to import the package io.example from io-example-api instead of io-example.
Solution for this would be to make sure only one bundle exports io.example package.
[Edit] I am unfamiliar with grpc but there seems to be issue on github about this and some workarounds that you could look in to.
You could also try creating a bundle that embeds these problematic dependencies and exports the packages for other bundles to use.
Create a new bundle project using archetype karaf-bundle-archetype
Add grpc-context and grpc-api dependencies
Configure maven-bundle-plugin to emped the grpc dependencies and export io.grpc package along with its sub packages.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>com.example.Activator</Bundle-Activator>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Export-Package>
io.grpc*;-split-package:=merge-first
</Export-Package>
<Emped-Dependency>
grpc-context;scope=compile|runtime;inline=true,
grpc-api;scope=compile|runtime;inline=true
</Emped-Dependency>
</instructions>
</configuration>
</plugin>
Managed to install the bundle successfully to Karaf 4.2.11 and "use" the exported io.grpc.Context class in the bundle and in another bundle.
Simply called this from the Activator of two bundles
Context grpcContext = Context.current();
System.out.println(grpcContext.getClass().getName());

GlassFish 4, Grizzly Framework 2.3.23: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn

While starting GlassFish 4.1.1 server (Grizzly Framework 2.3.23), below warning message is displayed: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn
Do Grizzly Framework 2.3.23 to be separately installed on the computer? (As per details: "Class=interface org.glassfish.grizzly.http.server.AddOn" it seems like grizzly http server is part of glassfish) If grizzly http server seperately not needed to be installed, then which instance it is trying to be initialized and failing.
Do GlassFish Plugin for Eclipse is to be added in Spring Tool Suite IDE?
GlassFish 4 server stop and start using command prompt tested:
glassfish4\bin>asadmin stop-domain
Command stop-domain executed successfully.
glassfish4\bin>asadmin start-domain
Waiting for domain1 to start ;
Successfully started the domain : domain1;
domain Location: glassfish4\glassfish\domains\domain1;
Log File: glassfish4\glassfish\domains\domain1\logs\server.log;
Admin Port: 4848;
Command start-domain executed successfully.
Still the warning exist as given above.
If Grizzly Framework is inbuilt in GlassFish 4 then, does Grizzly dependency inclusion in the project pom.xml needed explicitly as given below? (code is from: Grizzly)
<dependencies>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-server</artifactId>
<version>2.3.22</version>
</dependency>
</dependencies>
I had the same problem, with Glassfish embedded 4.1.2. Please notice that you wrote only a part of the errore message, full error message is:
Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn
So, Glassfish is trying to instantiate a class in package http2, however this package is not included in embedded Glassfish! There is no such folder in glassfish-embedded-all-4.1.2.jar.
I don't know if this was fixed in 5.0.
My solution for 4.1.2 is to add dependencies that include this package (well, this is exactly the solution you propose):
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http2</artifactId>
<version>2.3.28</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-npn-bootstrap</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>

How to have access to ServletRequestAware on struts2-core 2.3.16.1?

I changed my struts2 version from 2.3.14 to 2.3.16.1, it seems that newest version does not support ServletRequestAware and ServletResponseAware anymore, what should I do? I could not find anything online.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.16.1</version>
<type>jar</type>
</dependency>
Code
import org.apache.struts2.interceptor.ServletRequestAware;
public class MyExample implements ServletRequestAware, ServletResponseAware {
Error
package org.apache.struts2.interceptor does not exist.
When I try to find a dependency for it Maven shows the latest version of Struts2 which is supporting it is 2.3.14!
You probably have some problem with the libraries included in your project;
Be sure to erase all the old JARs from the classpath (your WAR / EAR and shared libs on the AS;
run Clean Project in your IDE;
download Struts2.3.16.1 from Maven or manually from here;
check out the ServletRequestAware and ServletResponseAware Interfaces at
/struts-2.3.16.1/src/core/src/main/java/org/apache/struts2/interceptor/
, exactly where they were before ;)
E.g., output from 2.3.16.3 distribution:
$ jar tvf struts2-core-2.3.16.3.jar | grep ServletRequest
223 Fri May 02 17:23:44 EDT 2014 org/apache/struts2/interceptor/ServletRequestAware.class
It's also in the 2.3.16.1 jars.
At the Step 3 of Welcome to Struts2 add the following dependency to your pom.xml
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>X.X.X.X</version>
</dependency>
Check the file version X.X.X.X is available in the repository and downloaded to your hard drive.

Looking up a Remote Bean, getting a EjbNamingContext in JBoss 7.1

I have a Maven project, in which I want to try integration-testing an EAR sub-module.
In the integration-test submodule, I do the following:
Properties env;
Context ctx;
env = new Properties();
env.setProperty( "java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env.setProperty( "java.naming.provider.url", "remote://localhost:4447");
env.put(Context.SECURITY_PRINCIPAL, "jboss-user");
env.put(Context.SECURITY_CREDENTIALS, "*******");
ctx = new InitialContext( env );
IBMPFacadeRemote bmpFacade = ( IBMPFacadeRemote ) ctx.lookup( "ejb:DeDomain-ejb-1.0-SNAPSHOT/BMPFacade!de.domain.service.IBMPFacadeRemote");
bmpFacade.executeBMPProcess( model1, model2);//model1 & model2 are some entities
The problem: when calling mvn integration-test it ends up with the following Exception
java.lang.ClassCastException: org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to de.domain.service.IBMPFacadeRemote
Could someone help me to solve this problem? Are there any possibilities to integration-test this using a Local Bean (the maven project uses the failsafe-plugin)?
It is now hard to say what exactly solved the problem, but I will try to mention all made changes that solved the problem.
Added to the pom.xml the dependencies
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<version>7.1.1.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-jms-client-bom</artifactId>
<version>7.1.1.Final</version>
<type>pom</type>
</dependency>
Changed the JNDI lookup as follows (after changing the deployed name of the EAR&EJB projects)
IBMPFacadeRemote bmpFacade = ( IBMPFacadeRemote ) ctx.lookup( "ejb:DeDomain-ear/DeDomain-ejb//BMPFacadeBean!de.domain.service.IBMPFacadeRemote");
Got rid of the EJB maven plugin from the EJB Project & of some other resources, like jndi.properties
Probably it is worth mentioning, that the Properties instance remained the same as in the stated in the question.
The JNDI Properties are looking strange for me. I was always successfull with the following Properties for JBoss:
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
jnp.socket.Factory=org.jnp.interfaces.TimedSocketFactory
May be you should double check them.

bouncy castle: How to get bcpkix-jdk15on-1.47.jar with debug information

I am trying to debug an issue with bouncy castle 1.47. I can find a debug jar for 'bcprov' but not for {org.bouncycastle:bcpkix-jdk15on:1.47:jar}.
Is there any other place to download bcpkix-jdk15on-1.47.jar with debug information?
or
Is there a tool that can generate line numbers from a jar (containing .class files) without line numbers and also generated sources for the same generated jar?
or
I had been trying to build the jars from source 1 but the build cannot find the test jars I suppose from the errors.
[javadoc] /tickets/bouncycastle/src-cvs/java/crypto/build/artifacts/jdk1.5/bcprov-jdk15on-147/src/org/bouncycastle/jce/provider/test/AllTests.java:5: package junit.framework does not exist
[javadoc] import junit.framework.Test;
[javadoc] ^
[javadoc] /tickets/bouncycastle/src-cvs/java/crypto/build/artifacts/jdk1.5/bcprov-jdk15on-147/src/org/bouncycastle/jce/provider/test/AllTests.java:6: package junit.framework does not exist
[javadoc] import junit.framework.TestCase;
[javadoc] ^
[javadoc] /tickets/bouncycastle/src-cvs/java/crypto/build/artifacts/jdk1.5/bcprov-jdk15on-147/src/org/bouncycastle/jce/provider/test/AllTests.java:7: package junit.framework does not exist
[javadoc] import junit.framework.TestSuite;
Any help is appreciated.
I have managed to generate jar with debug information from bouncy castle source.
in ROOT_SRC/bc-build.properties, set release.debug to true
release.suffix: 147
release.name: 1.47
release.debug: true
The build expects mail (sun implementation) and junit jars to be available in classpath. I have put them on to jdk/jre/lib/ext and the build worked. the artifacts were generated in the ROOT_SRC/build directory.
Instead of rolling your own build, you could exclude bcprov-jdk15on and explicitly pull in the debug-built bcprov-debug-jdk15on artifact.
Maven config example:
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${bouncycastle.version}</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-debug-jdk15on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
This will allow you to debug bouncycastle stuff.

Resources