我正在尝试执行简单的hibernate java程序-
使用的文件:hibernate。cfg。xml,员工。cfg。Java类:HibernateUtil。爪哇,员工们。爪哇,性别。java(Enum),InsertIntoEmployee。JAVA
InsertIntoEmployee的代码。JAVA
package com.action.utilities.businessutilities;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.action.utilities.hibernateutilities.HibernateUtil;
import com.hibernate.models.Employees;
import com.hibernate.models.Gender;
public class InsertIntoEmployee {
public InsertIntoEmployee() {
// TODO Auto-generated constructor stub
}
/**
* @param args
* @throws ClassNotFoundException
* @throws ParseException
*/
public static void main(String[] args) throws ClassNotFoundException {
// TODO Auto-generated method stub
SimpleDateFormat sdf=new SimpleDateFormat("MM/dd/yyyy");
Class.forName("com.action.utilities.hibernateutilities.HibernateUtil");
Session session=HibernateUtil.getSessionFactory().openSession();
try {
Transaction tx=session.beginTransaction();
Employees emp=new Employees();
emp.setFirstName("Gaurav");
emp.setLastName("Palkar");
emp.setBirthDate(sdf.parse("01/17/1983"));
emp.setGender(Gender.MALE);
session.save(emp);
session.getTransaction().commit();
} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(ParseException pe){
pe.printStackTrace();
}catch(Exception ee){
ee.printStackTrace();
}finally{
session.close();
}
}
}
获取以下错误:
java.lang.NoClassDefFoundError: javax/transaction/SystemException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:176)
at com.action.utilities.hibernateutilities.HibernateUtil.<clinit>(HibernateUtil.java:30)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:29)
Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 9 more
Exception in thread "main" java.lang.NullPointerException
at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:30)
Classpath条目如下:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry excluding="src/" kind="src" path=""/>
<classpathentry kind="lib" path="lib/jta.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.18-bin.jar"/>
<classpathentry kind="lib" path="lib/asm-attrs-1.5.3.jar"/>
<classpathentry kind="lib" path="lib/c3p0-0.9.1.jar"/>
<classpathentry kind="lib" path="lib/ehcache-1.2.3.jar"/>
<classpathentry kind="lib" path="lib/ejb3-persistence-1.0.2.GA.jar"/>
<classpathentry kind="lib" path="lib/jdbc-stdext-2.0.jar"/>
<classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/>
<classpathentry kind="lib" path="lib/avro-1.5.1.jar"/>
<classpathentry kind="lib" path="lib/hibernate-commons-annotations-4.0.1.Final.jar"/>
<classpathentry kind="lib" path="lib/hibernate-core-4.1.3.Final.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-asl-1.9.2.jar"/>
<classpathentry kind="lib" path="lib/jackson-mapper-asl-1.9.2.jar"/>
<classpathentry kind="lib" path="lib/javassist-3.15.0-GA.jar"/>
<classpathentry kind="lib" path="lib/jboss-logging-3.1.0.GA.jar"/>
<classpathentry kind="lib" path="lib/lucene-core-3.5.0.jar"/>
<classpathentry kind="lib" path="lib/paranamer-2.3.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/snappy-java-1.0.1-rc3.jar"/>
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/asm-3.1.jar"/>
<classpathentry kind="lib" path="lib/cglib-2.1_3.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.13.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
在过去的三天里,我一直在讨论这个问题。
谷歌搜索后,我开始知道是否应该用javaee-api-5.jar来克服问题,但没有帮助。我得到了如下所附的类格式错误-
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract
in class file javax/transaction/SystemException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:176)
at com.action.utilities.hibernateutilities.HibernateUtil.<clinit>(HibernateUtil.java:30)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:29)
Exception in thread "main" java.lang.NullPointerException
at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:30)
然后我还尝试了glassfish-api-4.0-b77。jar在类路径中也没有帮助。
有人能建议克服例外吗...
尝试添加javax.transaction.jar
。这包含了javax/事务/SystemExctive
当运行我的Spring启动应用程序时,启动时低于异常。不确定是什么依赖导致了这一点。 Spring启动版本-2.3.1 IDE-Intellij 这是一个多模块maven项目。如果需要其他信息,请告诉我。 下面是我的父母pom.xml 4.0.0
login.fxml: 它是在Eclipse中使用JRE 1.8.0而不是IntelliJ思想 这是一个错误:
问题内容: 我想运行在Mahout In Action中找到的以下代码: 我用它编译: 我把它装满了: 现在,我想在我的本地hadoop节点上运行它。我试过了: 但是我得到: 所以我尝试使用libjars参数: 并遇到了同样的问题。我不知道还能尝试什么。 我最终的目标是能够将hadoop fs上的.csv文件读取为稀疏矩阵,然后将其乘以随机向量。 编辑: 看起来Razvan知道了(请注意:请参见下
得到 错误[SpringApplication]应用程序启动失败org.springframework.beans.factory.BeanCreationException:创建名称为myEntityManagerFactory的bean错误定义在类路径资源[com/员工/服务/配置/DBConfiguration.class]:调用init方法失败;嵌套异常是java.lang.NullPoi
我下载了以下链接: http://www.java2s.com/Code/JarDownload/java/java-json.jar.zip 然后,我将jar添加到构建路径:右键单击项目 我能够使用java-json库而不会出现任何错误。然而,当我将项目导出到一个jar时,没有选项将java-json引用库作为jar的一部分。所以我假设通过将库添加到构建路径,我不必导出外部罐(无论如何也没有选项
我通过选择web、安全、验证和spring-boot Cassandra的几个依赖项下载了spring初始化器项目。当我尝试运行./gradlew bootrun时,我在启动过程中遇到以下异常