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.
Related
Im trying to run code use protege-owl. So I added the protege.jar and protege-owl.jar to library to import edu.stanford.smi.protegex.owl.* and edu.stanford.smi.protege.*.
I also added jena jar files to use in next steps.
First i wrote simple code to see how it works :
import java.lang.Object;
import edu.stanford.smi.protege.*;
import edu.stanford.smi.protegex.owl.*;
import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
public class Main {
public static void main(String[] args) {
// TODO code application logic here
JenaOWLModel model=ProtegeOWL.createJenaOWLModel();
OWLNamedClass c= model.createOWLNamedClass("A");
System.out.print(c.getName());
}
}
But it gives me this error :
CONFIG: Protege 3.0 Build 141, JVM 1.6.0_20-b02, memory=259M, Windows 7, encoding=UTF-8, language=fa, country=IR
WARNING: Look and feel not found: com.jgoodies.plaf.plastic.PlasticLookAndFeel -- SystemUtilities.loadLookAndFeel()
WARNING: Plugins directory not found: C:\Users\mona\Documents\NetBeansProjects\JavaApplication3\plugins -- PluginUtilities.getPluginsDir()
WARNING: Exception Caught -- java.lang.NoClassDefFoundError: com/toedter/calendar/JDateChooser
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at edu.stanford.smi.protege.plugin.PluginUtilities.isLoadableClass(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.checkPlugin(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.checkPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.processManifest(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadPluginsWithClassLoader(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.createClassLoaderAndLoadPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadSystemPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.init(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.<clinit>(Unknown Source)
at edu.stanford.smi.protege.util.SystemUtilities.init(Unknown Source)
at edu.stanford.smi.protege.util.SystemUtilities.<clinit>(Unknown Source)
at edu.stanford.smi.protege.model.Project.<clinit>(Unknown Source)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModel(ProtegeOWL.java:32)
at javaapplication3.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: com.toedter.calendar.JDateChooser
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method) . . . .
What can I do ?
Update:
I replace protege.jar with protege-3.5.jar and now it gives :
Exception in thread "main" java.lang.NoSuchMethodError: edu.stanford.smi.protege.model.SystemFrames.replaceFrame(Ledu/stanford/smi/protege/model/Frame;)V
at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.createSystemFrames(AbstractOWLModel.java:544)
at edu.stanford.smi.protege.model.DefaultKnowledgeBase.<init>(DefaultKnowledgeBase.java:79)
at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.<init>(AbstractOWLModel.java:318)
at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.<init>(JenaOWLModel.java:62)
at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.createKnowledgeBase(JenaKnowledgeBaseFactory.java:55)
at edu.stanford.smi.protege.model.Project.createDomainKB(Project.java:429)
at edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:447)
at edu.stanford.smi.protege.model.Project.<init>(Project.java:359)
at edu.stanford.smi.protege.model.Project.<init>(Project.java:341)
at edu.stanford.smi.protege.model.Project.createNewProject(Project.java:545)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModel(ProtegeOWL.java:32)
at javaapplication3.Main.main(Main.java:24)
Java Result: 1
Where is the problem?
I downloaded protege-owl.jar which is 3.24MB from different link and now it works.
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.
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.
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.
I have this problem when I run my program in java.However I have main method ,I have saved My file with the name of MyClass and run it in a right path.thanks in advance..
Exception in thread "main" java.lang.NoClassDefFoundError:MyClass
caused by:java.lang.classNotFoundException:MyClass
at java.net.URLClassLoader$1.run(Unknown sourse)
at java.security.AccessCountroller.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown sourse)
at java.lang.ClassLoader.loadClass(Unknown sourse)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown sourse)
at java.lang.ClassLoader.loadClass(Unknown sourse)
could not find the main class:Myclass.program will exit
I wonder about this:
main class:Myclass.program
Myclass is not the same as MyClass. Java is case sensitive.