NIFI CONNECTION - apache-nifi

When trying to connect into a oracle database, NiFi returns this error in the connection configuration: 14:36:05 BRT ERROR StandardControllerServiceNode\[service-DBCPConnectionPool\[id=bf90fd3d- 0184-1000-4a92-d8b25677a705\], versionedComponentid=null,
processGroup=Standard ProcessGroup\[identifier-bf056a65-0184-1000-cb2e- 35c3c5842085,name=NiFi Flow\], active=true\] Failed to invoke #OnEnabled method due to java.lang.UnsupportedClass VersionError:
com/microsoft/sqlserver/jdbc/SQLServerDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0: com/microsoft/sqlserver/jdbc/SQLServerDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I have downloaded the OJDBC and paste it in the nifi folder, in the NiFi configuration pannel I've added the connection URL and pointed to the local folder that the driver is.

Related

Application has been compiled by a more recent version of the Java Runtime (class file version 55.0), this versions up to 52.0

I am trying to run the docker image in AWS cloud so in the local ,compiled the application with jdk-11.0.1 and written docker file like this;
Please note that I have not installed any JDK in AWS ec2 instance because I have already included adoptopenjdk/openjdk11:latest image in the final image..
FROM adoptopenjdk/openjdk11:latest
ADD target/demo-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]
EXPOSE 8080
1)create the docker image
2)pushed the docker image to docker hub
3)when I run the docker container then getting below error.
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/example/demo/DemoApplication has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Most probably java got updated in local so you are compiling with a different version than you think. Or the local version is different than "adoptopenjdk/openjdk11:latest".
I suggest you use a multi-stage build so that your classes are always compiled against the same java version.
How you write your build stage depends on your environment so I don't have enough information to post an example. But basically you need to replicated everything you do in local inside the build stage. Then you just copy the jar to the last stage. And this will always work.
Try changing your openjdk version to latest i.e FROM:openjdk:12 work for me as i am using latest java version, use respective openjdk versions to match at runtime
To avoid this kind of issue It is recommend to be very specific about the images.
i.e. FROM adoptopenjdk/openjdk11:jre-11.0.9.1_1-alpine
For this kind of best practices I would suggest to go through this article I found while looking for the solution.

javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;

I'm getting the below error when running Spring Boot app in Intellij:
The following method did not exist:
javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
The method's class, javax.servlet.ServletContext, is available from the following locations:
jar:file:/C:/Program%20Files/Java/jdk1.8.0_05/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.class
jar:file:/C:/Program%20Files/Java/jdk1.8.0_05/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.class
jar:file:/C:/Users/adi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.29/tomcat-embed-core-9.0.29.jar!/javax/servlet/ServletContext.class
It was loaded from the following location:
file:/C:/Program%20Files/Java/jdk1.8.0_05/jre/lib/ext/servlet-api.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext
I would just delete the entire C:/Program Files/Java/jdk1.8.0_05/jre/lib/ext/ directory.
Servlet API should not be a part of the JDK.
This Java version is also ancient, so installing a more recent Java build and using it for your project is probably an even better solution.

wrong java version in heroku

I've created a spring boot app and would like to run it on heroku.
My app is compiled using java 9.
As I'm deploying it to heroku using the CLI plugin I'm getting
Exception in thread "main" java.lang.UnsupportedClassVersionError: io/safeblocks/firewall/FirewallApplication has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Clearly this means java versions mismatch. I added the system.properties file to my resources folder with the property java.runtime.version=9 as explained but still getting the same error.
As I run the command heroku run java -version --app myApp I'm getting:
openjdk version "1.8.0_171-heroku"
OpenJDK Runtime Environment (build 1.8.0_171-heroku-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
So it seems heroku is still not picking up the required java version.
Any ideas?
I see you added the system.properties file to your resources folder, I did the same mistake. The file system.properties must be placed under the root folder of your project.
The content of your file is correct:
java.runtime.version=9
After you moved the file to the root folder, commit your changes and do:
git push heroku master
Everything should be fine then.

Spring Batch Listener defined with #Component not being found

We have multiple jobs that all use a similar pattern.
Class file for MyJobListener is defined with #Component annotation.
Listener in XML is defined:
<batch:listeners>
<batch:listener ref="myJobListener" />
</batch:listeners>
Seems to work just fine in some cases but not for others. In some cases, we are getting an error:
ERROR (CommandLineJobRunner.java:355) - Job Terminated in error: Failed to load bean class: mypackage.myJobListener; nested exception is java.io.FileNotFoundException: class path resource [mypackage/myJobListener.class] cannot be opened because it does not exist
Not certain why it is doing this (the jobs are all coded the same way).
UPDATE
This seems to be an environment issue. The Spring Batch jobs run perfectly fine in one environment, but we are in the process of updating to a new server. On the new server, all of our jobs are getting the error (FileNotFoundException).
Please let me know what other information may be needed.
OLD SERVER
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) Server VM (build 20.14-b01, mixed mode)
Machine hardware: sun4u
SunOS version: 5.10
Processor type: sparc
Hardware: SUNW,Sun-Fire-480R
NEW SERVER
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) Server VM (build 20.14-b01, mixed mode)
Machine hardware: sun4v
SunOS Version: 5.10
Processor type: sparc
Hardware: sparc SUNW,T5240
Since you didn't post your config...
Make sure you define your class like this:
#Component("myJobListener")
public class MyJobListener implements JobExecutionListener{
And make sure you have something like this somewhere in your ApplicationContext.xml
<context:component-scan base-package="mypackage" />
to load your annotated beans (your listeners)
I failed to come out here and notify everyone of the resolution.
Looks like the issue had to do with a corrupted jar file.
We ran jar -tf on all of the project jar files. For one of the jar files, it recieved an error:
java.util.zip.ZipException: invalid END header (bad central directory offset)
Redploying the jar file seemed to take care of the issue.
Not certain why the jar file had issues. We use ANT to build the jar files, and then combine them into a tar file for deployment. We SFTP the tar file to the unix server, and then untar it. For some reason, the jar files sometimes are having issues, but redeploying seemes to clear it up.

JDBC Driver class not found: oracle.jdbc.OracleDriver

I have installed a third party java webservice which uses Oralce jdbc thin driver to write data into Oracle database. When i run this, i get the following error;
JDBC Driver class not found: oracle.jdbc.OracleDriver
I have oracle installed and set classpath variable to following value:
*D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar*
and path variable to following value;
*D:\oracle\product\10.2.0\client_1\bin;C:\Program Files\Java\jdk1.7.0\bin\;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip*
Any suggestion why web service is not able to identify jdbc driver?
Thanks
I know 2 ways of turning Java app into Windows service and both do not use CLASSPATH. One is Java Service Wrapper by Tanuki Software. This tool uses wrapper.conf where you can show directories with .jar libraries:
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=c:\jars\*
wrapper.java.classpath.2=myservice.jar
Second tool I know is JSL: Java Service Launcher. In this tool there is jsl.ini where you put command line to run your server. It can use java with -cp option to show location of .jar libraries:
[defines]
MY_LIBS=d:\jars\*
AXIS_LIBS=d:\axis2-1.5.4\lib\*
CLASSPATH=.;%MY_LIBS%;%AXIS_LIBS%
export = CLASSPATH
...
[java]
...
cmdline = -Dfile.encoding=utf8 -cp %CLASSPATH% example.my.server
In both configuration you can use * to add all .jar files or you can show those files one by one (just like in CLASSPATH).
At first you should know what Windows is trying to execute. Check it in the service properties page. Then try to localize its configuration. If it uses one of tools I know then you know what to change. Other tools probably have similar configuration.
Method 1:
Download ojdbc.jar
add ojdbc6.jar to deployment assembly.
Right click on project->properties->select deployment assembly->click on 'Add'
->select 'Archives from File System'->browse to the folder where ojdbc6.jar is saved.->add the jar->click finish->Apply/OK.
Method 2:
if you want to add ojdbc.jar to your maven dependencies you follow this link:
http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/
.
.
Even if you're using a maven project it is not necessary to add ojdbc to maven dependencies(method 2), method 1 (adding directly to deployment assembly) works just fine.
Make sure you have the ojdbc jar file (make sure you are using the correct one because depending on java version you may need to choose a different one).
use ojdbc14.jar for Java 1.4
use ojdbc5.jar for Java 1.5
ojdbc6.jar for Java 1.6
here is linke where you can download ojdbc6.jar file
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
You also have to add the jdbc jar to your server classpath. if tomcat, rigth-click on your Project->run as->run configurations, click on classpath and add your jdbc jar in Add external jars option
add ojdbc-6.jar to your lib directory of tomcat installation. Maven will downlowd this jar for you in .m2 directory, but you need to have this jar in tomcat lib as well.

Resources