I am using javaPNS_2.2.jar file to send push notification message to iPhone device.
My Code is:
PushNotificationPayload payload = PushNotificationPayload.complex();
/* Customize the payload */
payload.addAlert("Hello World!");
payload.addCustomDictionary("mykey1", "My Value 1");
payload.addCustomDictionary("mykey2", 2);
/* Push your custom payload */
String keystore = "C:/1.0Eywa_Baba/PushNotificationKey.p12";
String password = "Eywa#12";
boolean production = false;
String devices = "C81DD339-F5C1-529F-BEC4-6C8622BA0BFD";
List<PushedNotification> notifications = Push.payload(payload,
keystore,
password,
production,
devices);
However, I am getting the error:
log4j:WARN No appenders could be found for logger (javapns.notification.Payload).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
at javapns.notification.PushNotificationManager.initializeConnection(PushNotificationManager.java:105)
at javapns.Push.sendPayload(Push.java:171)
at javapns.Push.payload(Push.java:149)
at com.example.SendMSG.send(SendMSG.java:35)
at com.example.APNDemo1.main(APNDemo1.java:20)
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider
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)
What is causing this exception?
Include the bcprov-jdk15-140 jar in classpath of your project.
Include the bouncycastle library in your project.
Related
I have a simple hibernate in java for create table. It is Exception when execute.
public class TestEmployee {
public static void main(String[] args) {
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(Employee.class);
config.configure();
new SchemaExport(config).create(true, true);
}
}
The Exception is :
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Cacheable
at org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java: 988)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:579)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002 )
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:130)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
at com.Hibernate.chapter1.TestEmployee.main(TestEmployee.java:15)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Cacheable
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)
Add hibernate-jpa-2.0-api-1.0.0.Final library in project build path. Download it from Maven Repo. Other versions are available here.
This error may get solved by including hibernate-jpa-2.0-api-1.0.0. in your classpath which can be found at hibernate-distribution-3.5.3-Final\lib\jpa.
I have used opening pdf using following code.
try
{
File file = new File("Sample.pdf");
java.awt.Desktop.getDeskTop().open(file);
System.out.println("File opened successfully");
}catch(Exception ex)
{
System.out.println("Error occurred: "+ex);
}
Now i want disable save,save as,print option in the pdf file before opening.I have tried this link.but it wont work.
It throws following error occur.
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/cms/Recipient
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.cms.Recipient
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
How to disable save,save as,print option for given pdf file?
You missd the most importnat part of the link you attached, you need to use the PdfWriter static fileds, i am not sure it support all your needs but at least some of them like ALLOW_PRINTING.
i am using smsj api to send sms from pc to mobile through gsm modem. as given on the page, i have tried the following code.
package org.marre;
import java.io.IOException;
import org.marre.sms.SmsException;
public class SendMessage {
public void send() {
try{
// Send SMS with clickatell
SmsSender smsSender = SmsSender.getGsmSender("COM7");
String msg ="sample message";
// International number to reciever without leading "+"
String reciever = "9561356345";
// Number of sender (not supported on all transports)
String sender ="9561356345";
// Connect
smsSender.connect();
// Send message
smsSender.sendTextSms(msg, reciever, sender);
// Disconnect
smsSender.disconnect();
} catch(IOException i){
i.printStackTrace();
System.out.println("i");
} catch(SmsException s){
s.printStackTrace();
System.out.println("s");
}
}
public static void main(String args[]){
SendMessage app = new SendMessage();
app.send();
}
}
but i am getting this error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.marre.sms.transport.gsm.SerialComm.<clinit>(SerialComm.java:58)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.marre.sms.transport.gsm.GsmTransport.class$(GsmTransport.java:83)
at org.marre.sms.transport.gsm.GsmTransport.<clinit>(GsmTransport.java:83)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.marre.sms.transport.SmsTransportManager.getTransport(SmsTransportManager.java:75)
at org.marre.SmsSender.<init>(SmsSender.java:112)
at org.marre.SmsSender.getGsmSender(SmsSender.java:180)
at org.marre.SendMessage.send(SendMessage.java:12)
at org.marre.SendMessage.main(SendMessage.java:30)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 12 more
i am a beginner in java. please help me with the code.
note: i have used smslib api earlier for sending a simple text message. but this does not support ems messages. if you have any other library in mind which supports ems messages, please let me know. smsj was one i could easily download.
The real cause of the problem lies here:
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
The compiler couldn't find org.slf4j.LoggerFactory from the classpath.
Download SLF4J and add the library in your classpath and compile your code.
Note: As smsj references a very old version of Slf4J you need to use this old version as well: http://mvnrepository.com/artifact/org.slf4j/slf4j-simple/1.0-beta9
I have an applet that references 2 signed jars:
myapplet.jar
jackson-all-1.9.9.jar
When starting the applet the second time (first time is without errors), I get this:
Exception in thread "thread applet-main.MyApplet-1"
java.lang.ExceptionInInitializerError
at org.codehaus.jackson.map.deser.StdDeserializerProvider.<init>(StdDeserializerProvider.java:81)
at org.codehaus.jackson.map.ObjectMapper.<init>(ObjectMapper.java:398)
at org.codehaus.jackson.map.ObjectMapper.<init>(ObjectMapper.java:358)
at org.codehaus.jackson.map.ObjectMapper.<init>(ObjectMapper.java:328)
at net.Remote.<init>(Remote.java:50)
at main.Env.init(Env.java:44)
at main.MyApplet.init(MyApplet.java:25)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.SecurityException: Prohibited package name: java.util
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.codehaus.jackson.map.deser.BasicDeserializerFactory.<clinit>(BasicDeserializerFactory.java:74)
... 9 more
The line in question is the first one in the following try-catch block:
try {
Class<?> key = Class.forName("java.util.ConcurrentNavigableMap");
Class<?> value = Class.forName("java.util.ConcurrentSkipListMap");
#SuppressWarnings("unchecked")
Class<? extends Map<?,?>> mapValue = (Class<? extends Map<?,?>>) value;
_mapFallbacks.put(key.getName(), mapValue);
} catch (ClassNotFoundException cnfe) { // occurs on 1.5
}
A couple of things I do not understand:
Why does my Java7 JVM not take it out of its runtime library? But rather
Why does it try to download /java/util/ConcurrentNavigableMap.class from my server, which obviously fails with a 404?
As that fails, why does it try to re-download myapplet.jar 25 times in rapid succession, each time successfully (200), and each time returning the same jar file?
Update I'm not sure whether the 25 retries are caused by the class loader trying to load the class, it might be some other code trying to load a resource (which would still be odd, but not related to the CurrentNavigableMap issue), so I'll exclude that from my question.
N.B. I guess it does not try to re-download the jackson jar file, as that one is listed in the cache_archive attribute.
Is this?
wrong:
Class.forName("java.util.ConcurrentNavigableMap");
Correct:
http://java.sun.com/javase/ja/6/docs/ja/api/java/util/concurrent/package-tree.html
Class.forName("java.util.concurrent.ConcurrentNavigableMap");
EDIT:
public static void main(String[] args)throws Exception {
// TODO Auto-generated method stub
System.out.println("debug1");
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer("key","secret");
System.out.println("debug2");
...}
hi when i try to run this script i get this response:
debug1
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at oauth.signpost.signature.OAuthMessageSigner.<init>(OAuthMessageSigner.java:37)
at oauth.signpost.signature.HmacSha1MessageSigner.<init>(HmacSha1MessageSigner.java:30)
at oauth.signpost.AbstractOAuthConsumer.<init>(AbstractOAuthConsumer.java:65)
at oauth.signpost.commonshttp.CommonsHttpOAuthConsumer.<init>(CommonsHttpOAuthConsumer.java:30)
at mein.tester.main(tester.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 5 more
Line 21 is the line before
System.out.println("debug2");
Well i can easily compile the code in eclipse and i added 2 Signpost librabrys and also common-codec.jar as external library as i read in another post.. however, how do i make it available on runtime?(i did like in the post "add it to WEB-INF/lib " -> i created that folder and added the jar
-i also tryed the defaultoauthconsumer -> same error
Right click on the jar and choose "add to build path"? I don't think the ide will automatically add it to your classpath unless you tell it to.