Struts_1.2 + Log4J2_2.0.2 + Hibernate_4.3.6 프로젝트를 제 자신으로 만들고 있습니다. 그리고 간단한 DAO 클래스를 만들고 로컬 환경 (로컬 Java 응용 프로그램으로 실행되는 간단한 Java 클래스)에서 실행되었으며 100 % 정상적으로 작동했습니다.java.lang.NoSuchMethodError는 Tomcat에서만 실행되는 Hibernate Configuration 클래스입니다.
이제 Action Controller에서 동일한 DAO 클래스를 호출했습니다. JSP에서 Action Controller로 데이터를 보낸 다음 DAO로 데이터를 전송했고, 서버는 Tomcat 7.x이고 실행하려고하면 이해 할 수없는 나는 무엇
java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;
톰캣 (로컬 응용 프로그램)하지만 톰캣에 관해서는 클래스의 방법을 찾을 수 없습니다없이 실행되는 동일한 코드입니다. 나는 항아리를 확인했다
, 그것은 파일이 포함 된 해당 파일은 방법 (아무 컴파일러 오류) 사람이 나를 도울 수 있다면
나는 매우 감사 할 것입니다있다.
메이븐 (pom.xml 파일) :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestApp</groupId>
<artifactId>TestApp</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>TestApp</name>
<description>Website</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>struts</groupId>
<artifactId>struts</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.12</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.12</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.12</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</project>
DAO (자바) :
public void saveHitCountInDB(HitCount count) {
session.update(count);
session.flush();
}
POJO (자바) :
@Entity
@Table(name = "hitcounter")
public class HitCount {
@Id
@Column(name = "count", unique = true, nullable = false)
private int hitCount;
//getter and setter and constructors
}
연결 (자바) :
configuration = new Configuration().configure();
configuration.addAnnotatedClass(HitCount.class); //problem reported here
참고 : 더 많은 코드가 필요한지 알려주세요.
"Hibernate Annotation jar"가 잘못되었습니다. jar 버전과 호환되지 않습니다. 그래서''java.lang.NoSuchMethodError' " –
pls가'pom.xml'을 완료 한 것을 보여 주며, 또한'hibernate-commons-annotations'에 대한 pom 의존성 트리를 확인하십시오 –
@ ankur-singhal하지만 어떻게됩니까? 같은 코드가 성공적으로 오프라인에서 실행되고있을 가능성이 있습니다 (PSVM을 사용하여 동일한 DAO 함수를 호출했는데 작동 중입니다)? (위의 pom.xml을 찾으십시오) – Jayesh