Context
Using KNIME 4.1.2, Windows 10, x64, JDK 1.8, Java Edit Snippet
I am attempting to use the Java Snippet to read a CSV file, pgp encrypt it using a public key, and save the resulting file to a temporary folder
I have been attempting to use BounceCastle Library v1.65
try {
encryptFile(
"encryptedfile.csv.pgp",
"original.csv",
"/key/pub.asc",
false,
false);
} catch(Exception e) {
out_result = "fail";
}
The challenge is, I get the following error in the console INTERMITTENTLY and I am unclear what I am incorrectly providing to the library / not including. The confounding is because it is intermittent and sometimes yields the properly encrypted file.
Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/jcajce/provider/asymmetric/rsa/BCRSAPublicKey
at org.bouncycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.engineGeneratePublic(Unknown Source)
at java.security.KeyFactory.generatePublic(KeyFactory.java:328)
at org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter.implGeneratePublic(Unknown Source)
at org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter.getPublicKey(Unknown Source)
at org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator.encryptSessionInfo(Unknown Source)
at org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator.generate(Unknown Source)
at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source)
at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source)
at JSnippet.encryptFile(JSnippet.java:144)
at JSnippet.encryptFile(JSnippet.java:107)
at JSnippet.snippet(JSnippet.java:174)
at org.knime.base.node.jsnippet.JavaSnippetCellFactory.getCells(JavaSnippetCellFactory.java:300)
Related
I'm simply trying to run this sample code below:
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
public class Translator {
public static void main(String[] args) throws Exception {
Translate.setClientId("ID GOES HERE");
Translate.setClientSecret("SECRET GOES HERE");
String translatedText = Translate.execute("Bonjour le monde",
Language.FRENCH, Language.ENGLISH);
System.out.println(translatedText);
}
}
and I'm getting the following Exception:
Exception in thread "main" java.lang.Exception: [microsoft-translator-api] Error retrieving translation : datamarket.accesscontrol.windows.net
at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:202)
at com.memetix.mst.translate.Translate.execute(Translate.java:61)
at Translator.main(Translator.java:10)
Caused by: java.net.UnknownHostException: datamarket.accesscontrol.windows.net
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
at com.memetix.mst.MicrosoftTranslatorAPI.getToken(MicrosoftTranslatorAPI.java:133)
at com.memetix.mst.MicrosoftTranslatorAPI.retrieveResponse(MicrosoftTranslatorAPI.java:160)
at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:199)
... 2 more
I know it seems like I'm not even trying to figure this out on my own but I'm a complete beginner and can't really understand the Exception trace at all by myself. I'm pretty sure I got the right client Secret. In my azure account I only see an application ID and an Object ID. I'm using the application ID as the client ID.
Does anyone have any ideas on what might be causing this? Any help is greatly appreciated.
Thank you!
The third party Java wrapper boatmeme/microsoft-translator-java-api for MS Azure Translator API is too old & unavailable, because it wrappered the old Microsoft Translator - Text Translation which is old & unavailable now.
There is a notice at the page top of the site Azure datamarket.
DataMarket and Data Services are being retired and will stop accepting new orders after 12/31/2016. Existing subscriptions will be retired and cancelled starting 3/31/2017. Please reach out to your service provider for options if you want to continue service.
For using the new Azure Translator API on Azure portal, you need to refer to the document Announcements: Microsoft Translator Moves to the Azure portal to know how to create the new one on Azure portal and use it via the new REST APIs. Meanwhile, just as reference, you can see my answer in Java for the other SO thread Microsoft Translator API Java, How to get client new ID with Azure.
Hope it helps.
I am trying to run the Trusted Computing API JSR321 in Eclipse by following the tutorial provide at Getting Started with JSR321 in Windows 7.
After successfully enabling my TPM (manufacturer: STM & version: 1.2).
I tried to run the code given in the tutorial,
import javax.trustedcomputing.tpm.TPMContext;
public class HellowWorld {
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
TPMContext context = TPMContext.getInstance();
context.connect(null);
//Do somthing cool here
context.close();
}
catch (Exception e){
e.printStackTrace();
}
}
}
I also added the external jar files as Classpaths in eclipse for the IAIK jTSS (jTSS 0.7.1a), they also mentioned that
It is necessary to set the jsr321.tpmcontextimpl property to the classname of your TPMContext implementation.
For example java -cp YourClasspath -Djsr321.tpmcontextimpl=iaik.tc.jsr321.tpm.TPMContextImpl yourjavaapplication.class
So I added the above code by right clicking on the project and going to the Run As -> Run Configuration and in the Arguments tab in the section provided for VM arguments I inserted the following command
-cp C:\Users\workspace\HelloWorld\bin -Djsr321.tpmcontextimpl=iaik.tc.jsr321.tpm.TPMContextImpl HellowWorld
But I am getting the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/trustedcomputing/tpm/TPMContext
at HellowWorld.main(HellowWorld.java:10)
Caused by: java.lang.ClassNotFoundException: javax.trustedcomputing.tpm.TPMContext
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I have already added all the mentioned dependencies in Java Build Paths inside Project Properties.
Kindly suggest a solution.
Thanks
I'm trying to make an online drawing game. For that I'm using the Path class in Android and I need to send it to my Java server. To do that, I had tried to extend the Path class, as follows:
public class SerializedPath extends Path implements Serializable {
private static final long serialVersionUID = -5974912367682897467L;
}
To simplify things and to narrow down the problem, all I did was to send it with outputStream.writeObject(new SerializedPath) and then outputStream.flush() where outputStream is an instance of ObjectOutputStream. Over the server I simply read it using inputStream.readObject() where inputStream is an instance of ObjectInputStream. The exception I'm getting is:
java.io.InvalidClassException: com.droplay.drawingonline.path.SerializedPath; unable to create instance
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.droplay.drawingonline.Session.run(Session.java:71)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedSerializationConstructorAccessor1.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.io.ObjectStreamClass.newInstance(Unknown Source)
... 5 more
Caused by: java.lang.RuntimeException: Stub!
at android.graphics.Path.(Path.java:24)
... 8 more
Now, to isolate the problem, I had tried creating a new class that doesn't have any members and doesn't extend anything and it did work. The server didn't throw any exception and it worked like a charm. I made sure the packages names are the same, the names of the classes are the same, the server uses the same SDK files as my Android project and the files' code in both the Android app and the Java server are EXACTLY the same, but I keep getting this exception. The app doesn't throw any exception. It sends the object just fine. Please, what's wrong with my code? Thank you for helping! :)
Well I managed to solve it by sending the position of each click to the server, instead of a path class. But why didn't it work when I serialized it?
While trying to use ProGuard (4.9) to obfuscate and optimise a desktop application everything works up until I use something from an external library such as JSoup.connect("http://google.com/").get();. I would get the following error:
Exception in thread "Thread-2" java.lang.ExceptionInInitializerError
at org.jsoup.b.l.<clinit>(Unknown Source)
at org.jsoup.b.f.<init>(Unknown Source)
at org.jsoup.b.e.<init>(Unknown Source)
at org.jsoup.c.bh.b(Unknown Source)
at org.jsoup.c.bh.a(Unknown Source)
at org.jsoup.c.b.a(Unknown Source)
at org.jsoup.c.D.a(Unknown Source)
at org.jsoup.a.a.a(Unknown Source)
at org.jsoup.a.i.e(Unknown Source)
at org.jsoup.a.e.a(Unknown Source)
at package.a.a(Unknown Source)
at package.a.b(Unknown Source)
at package.w.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at org.jsoup.b.k.d(Unknown Source)
at org.jsoup.b.k.<clinit>(Unknown Source)
... 14 more
I have tried searching for a solution but the answer would always be for an android application. With no luck I have attempted the following:
Turn off Use mixed-class names
Added to config -keep public enum * { public static **[] values(); public static ** valueOf(java.lang.String); }
Recently, going through with this process using ProGuard 5.2, not much has changed. Here is the updated process to fixing the issue:
Go to the Obfuscation tab.
Go to the bottom for Keep additional class names and class member names
Click on Add... to the right
Go down to Extends/implements class and type in your library matching the examples below then press Ok. Repeat for every library.
For JSoup: org.jsoup.**
For Apache Commons Net: org.apache.commons.net.**
For SwingX: org.jdesktop.**
For GSON: org.google.gson.**
Go to the Information tab.
Turn off Skip non-public library class members
Turn on Ignore warnings about possibly erroneous input
Process!
I tried making a simple project for my skype-bot, and it looks like this:
import com.skype.Skype;
import com.skype.SkypeException;
public class SkypeDemo {
public static void main(String[] args) throws SkypeException {
System.out.println(Skype.getVersion());
}
}
But when i started it i get this error:
Exception in thread "main" com.skype.SkypeException: Loading libskype.jnilib failed.
at com.skype.Utils.convertToSkypeException(Unknown Source)
at com.skype.Utils.getProperty(Unknown Source)
at com.skype.Skype.getVersion(Unknown Source)
at SkypeDemo.main(SkypeDemo.java:6)
Caused by: com.skype.connector.LoadLibraryException: Loading libskype.jnilib failed.
at com.skype.connector.ConnectorUtils.loadLibrary(Unknown Source)
at com.skype.connector.osx.SkypeFramework.init(Unknown Source)
at com.skype.connector.osx.OSXConnector.initializeImpl(Unknown Source)
at com.skype.connector.Connector.initialize(Unknown Source)
at com.skype.connector.Connector.connect(Unknown Source)
at com.skype.connector.Connector.assureAttached(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
... 3 more
So how do I fix this error? Keep in mind I have both Skype jars in the build path.
The error is telling you that it cannot load a native library ("libskype.jnilib"). This is (probably) neither Eclipse or Skype's fault.
It is most likely your fault because either the native library is not where it needs to be (or you haven't told Eclipse where to look), or because you have the wrong flavour of native code (DLL, .so or whatever)
(If there was another chained "cause" in the stack trace, it might tell you more ...)
Reference:
This blog post explains how to add a native library to an Eclipse project - http://www.eclipsezone.com/eclipse/forums/t49342.html (In fact, it describes two ways ...)