i got java.lang.NoClassDefFoundError: javax.smartcardio.TerminalFactory - java

import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
import javax.smartcardio.TerminalFactory;
TerminalFactory terminalFactory = TerminalFactory.getDefault();
i want to use usb Host communicating with smart card on android pad
but why do i get java.lang.NoClassDefFoundError: javax.smartcardio.TerminalFactory
i already import......
and i don't know how to package this lib into app

When you did the development the required jar which contains
javax.smartcardio.TerminalFactory
is in the classpath.
But when you did installation/deployment/packaging, did you ensure that the required jar is also packaged along with app.

Related

How to correctly develop, upload java library with dependencies to Oracle DB and call my Java function from PL\SQL?

I have:
Oracle 19c
java 8 on its machine
What i did:
I write simple class with one method in Java 8.
package <mypackage>;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import com.networknt.schema.ValidationMessage;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.Set;
import java.util.stream.Collectors;
public class <classname> {
<some simple validation function>
}
I compile my project with maven and maven-assembly-plugin to build .jar file with dependencies.
I upload it with loadtool: loadjava -f -r -v -synonym -oracleresolver -resolve -grant <user> -thin -user <credentials> <filename>.jar
There were 0 errors during upload. All uploaded classes (including dependencies) have 'VALID' status in dba_objects table.
I write PL/SQL wrapper over my Java function.
create FUNCTION <funcname>(P_IN_BODY_TEXT CLOB, P_IN_BODY_SCHEMA_TEXT CLOB)
RETURN VARCHAR2
AS LANGUAGE JAVA NAME '<packagename>.<classname>.<funcname>(java.sql.Clob, java.sql.Clob) return java.lang.String';
/
I use this function in my ORDS REST Service.
When doing request to ORDS i am getting this exception:
The request could not be processed because an error occurred whilst attempting to evaluate
the SQL statement associated with this resource.
Please check the SQL statement is correctly formed and executes without error. SQL Error Code: 29532,
Error Message: ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NoClassDefFoundError ORA-06512: at <rest stacktrace that gives me nothing>
Quiestion is:
What is root of this problem? By -synonym flag tool creates synonyms for me, all classes is valid. Do i need some permisions to use java packages liike java.sql that in my class imports? I upload some others open sources java libraries into my Oracle, but they doesn't hava dependencies - is that the problem?
Problem was in slf4j library that throws this exception. slf4j was dependency of library that i used.
Didn't dig the problem, I just pick another labrary with less dependencies and its works.

Hadoop 2.7 - Simple Java code to create directory in HDFS

All I am trying is to create a directory in HDFS using Java programmatically.
I am getting this error.
Exception in thread "main" java.util.ServiceConfigurationError: org.apache.hadoop.fs.FileSystem: Provider org.apache.hadoop.fs.s3a.S3AFileSystem could not be instantiated
Caused by: java.lang.NoClassDefFoundError: com/amazonaws/AmazonServiceException
Caused by: java.lang.ClassNotFoundException: com.amazonaws.AmazonServiceException
Not sure where all these Amazon S3 came over here. Please help.
Here's the code. This is Hadoop 2.7
package tas.module1;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class JavaClient {
public JavaClient() {
}
public static void main(String[] args) throws IOException {
JavaClient jc = new JavaClient();
Configuration config = new Configuration();
config.addResource(new Path("/usr/local/hadoop-2.7.1/etc/hadoop/core-site.xml"));
config.addResource(new Path("/usr/local/hadoop-2.7.1/etc/hadoop/hdfs-site.xml"));
config.set("fs.hdfs.impl",
org.apache.hadoop.hdfs.DistributedFileSystem.class.getName()
);
config.set("fs.file.impl",
org.apache.hadoop.fs.LocalFileSystem.class.getName()
);
FileSystem dfs = FileSystem.get(config);
String dirName = "TestDirectory";
System.out.println(dfs.getWorkingDirectory() +" this is from /n/n");
Path src = new Path(dfs.getWorkingDirectory()+"/"+dirName);
dfs.mkdirs(src);
System.out.println("created dir");
dfs.close();
}
}
ah, this is a bug fixed a while back in HADOOP-12636, which relates to the java service API and classpaths. Hadoop 2.7.2 enumerates all available filesystem implementation classes in JARs, and fails here due to the transient classpath problems.
If you drop the hadoop-aws JAR from your CP this will go away, or just upgrade to Hadoop 2.7.3
It seems that you are missing some dependency related to the working with S3 file system. In order to work with it, you need to have aws java sdk jars deployed in your cluster. You can download aws-java-sdk from http://sdk-for-java.amazonwebservices.com/latest/aws-java-sdk.zip. Then you need to unzip it, and copy every jar in aws-java-sdk/lib/ and aws-java-sdk/third-party/ to your datanodes.
Another option is to create uber jar and include this dependency directly into your jar through maven:
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.91</version>
</dependency>

Selenium WebDriver Automation with NW.js and Chromium Extended Framework Desktop application implemented in web technologies

I'm trying to Automate my application which is a standalone desktop based application implemented with web technologies and with chromium embedded framework that uses NW.js
The Application which iam testing, is a desktop based with web technologies implementation with NW.JS
The Application to be tested is actually embedded inside the Web Kit, which uses chromium and is a normal window and browser independent.
It does not make use of any of the traditional browsers(ie firefox,or IE or Safari, or Google chrome)
I wonder if selenium web driver can be used to test NW.JS sort of applications.
I will be grateful if anyone can help me
The selenium WebDriver Automated code is as follows
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Formatter;
import java.util.Locale;
import java.util.TimeZone;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class MyDummyTest
{
public static void main(String args[])
{
File chromium = new File("C:\\Program Files (x86)\\ChartInstaller Standalone\\nw.exe");
System.setProperty("webdriver.chrome.driver","C:/Program Files (x86)/ChartInstaller Standalone/chromedriver2_server.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--remote-debugging-port=9222");
options.setBinary(chromium);
WebDriver driver = new ChromeDriver(options);
}
}
but when I execute this, I see a dialog box is displayed (as shown below).
Can anyone help me how to solve this problem?
I have installed already the NW.js package on windows 7 environment.
Here is your answer : You need to use zip class of Selenium Web driver
http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html and here is class detail page. Free to use your function that fit in your requirement. I think my example code should work too
https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/io/Zip.java
Here is java Code
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.io.Zip;
public class tempUnit {
public void test() {
Zip zip = new Zip();
try {
zip.unzip(new File("D:\\TmpFS"), new File("D:\\TmpFS.zip"));
} catch (IOException e) {
e.printStackTrace();
}
}
}

Apache Spark Mllib Fp-growth Function not found Java

I'm new with spark, and I want to use the Fp Growth found in Mllib with java and maven. But I get this error during the compilation:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/cjd/fpgexample/src/main/java/org/fpgexample/FpgTest.java:[25,7] cannot find symbol
symbol: class Function
location: class org.fpgexample.FpgTest
this are the imports and the error line:
package org.fpgexample;
import java.util.Arrays;
import java.util.List;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.mllib.fpm.AssociationRules;
import org.apache.spark.mllib.fpm.FPGrowth;
import org.apache.spark.mllib.fpm.FPGrowthModel;
JavaRDD<List<String>> transactions = data.map( new Function<String, List<String>>() {`
I update the maven compiler to the 3.3 (using JDK 1.7), and spark-core and mllib 2.11 (1.5.1) versions. (with the mllib 2.10 1.4 maven didn't recognize the fpm.AssociationRules).
EDIT: I changed the maven compiler, pom.xml and JDK to 1.8 from 1.7, but the error persist.
You should import the correct package as below:
import org.apache.spark.api.java.function.Function;

Java issue NoClassDefFound javax.xml.soap.SOAPPart

I have been given a java app to modify with the following:
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
But When I run it from cmd it throws the error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/axis/SOAPP art
It seems to find the other imports without issue. Does 'NoClassDefFound' mean the class itself wasn't found? If so how can I check it is there and replace it if not? (I am using Eclipse)
Update: Okay I have found the class in 'JRE System Library>rt.jar>javax.xml.soap>SOAPPart.class' So if the class is there why do I get the error?
Turns out I needed to choose Export> 'Runnable JAR file' in eclipse instead of 'JAR file'

Categories