gpt4 book ai didi

java - NoClassDefFound错误: org/springframework/scheduling/quartz/SimpleTriggerBean when using SimpleTriggerFactoryBean

转载 作者:行者123 更新时间:2023-11-30 07:08:29 28 4
gpt4 key购买 nike

我正在尝试将项目从 spring 2.5.6 和 java 6 迁移到 spring 4.2.3 和 java 8,在 Wildfly 9 服务器上运行。我已根据讨论和示例更新了 SimpleTriggerBean 对 SimpleTriggerFactoryBean 的引用(例如 http://websystique.com/spring/spring-4-quartz-scheduler-integration-example/ )

但是,当我运行该应用程序时,我收到以下错误;

WARN [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 66) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'invalSvc' defined in ServletContext resource [/WEB-INF/classes/resources/spring/spring-cfg.xml]: Cannot resolve reference to bean 'changeHelper' while setting bean property 'changeHelper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'changeHelper' defined in ServletContext resource [/WEB-INF/classes/resources/spring/spring-cfg.xml]: Cannot resolve reference to bean 'invalRpcHelper' while setting bean property 'invalRpcHelper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'invalRpcHelper' defined in ServletContext resource [/WEB-INF/classes/resources/spring/spring-cfg.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/scheduling/quartz/SimpleTriggerBean

我正在运行的代码没有任何对 SimpeTriggerBean 的视觉引用,我无法弄清楚为什么会发生这种情况。 SimpleTriggerFactoryBean 应该可以在 Quartz 1.x 和 2.x 中工作。

Spring xml数据;

<bean name="retryHandlerImpl" class="com.myproject.code.rpc.vscall.RetryHandlerImpl">
<property name="passwordManager" ref="passwordManager" />
<property name="signal" ref="signal" />
<property name="handleToSTB" ref="fileTrigger" />
<property name="serverLoader" ref="serverLoader" />
<property name="serializeHelper" ref="serializeHelper" />
</bean>

<bean name="invalRpcHelper" class="com.myproject.code.rpc.calls.InvalRpcHelperImpl">
<property name="rpcHelper" ref="retryHandlerImpl" />
</bean>

<bean name="inputController"
class="com.myproject.code.control.InputController">
<property name="partnerDao" ref="partnerDao" />
<property name="passwordManager" ref="passwordManager" />
<property name="appData" ref="appData" />
<property name="signal" ref="signal" />
<property name="fileHelper" ref="fileHelper" />
</bean>


<!-- Non Quartz Job Scheduling -->
<bean id="scheduleFileReaderJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="inputController"/>
<property name="targetMethod" value="startFrontEndProcesses" >

</property>

<!-- dont want two instances of reader bean to run -->
<property name="concurrent" value="false" />
</bean>

<bean id="fileTrigger"
class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="scheduleFileReaderJob" />
<property name="startDelay" value="0" />
<property name="repeatInterval" value="${FILE_POLL_INTERVAL}" />
</bean>

RetryHandlerImpl的相关剪出;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import org.apache.log4j.Logger;
/* upgrading from spring 2.5.4 */
//import org.springframework.scheduling.quartz.SimpleTriggerBean;
/* to */
import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean;

// -> a lot of project class imports go here

public class RetryHandlerImpl extends RpcHelperImpl {

private static PasswordManager passwordManager;

private static Signal signal;

private static SimpleTriggerFactoryBean handleToSTB;

private static ServerLoader serverLoader;

private static SerializeHelper serializeHelper;

private static Logger log = Logger.getLogger(RetryHandlerImpl.class
.getName());

private static int noOfRetries = 0;

private static final int MAX_RETRIES;

private static final int HIBERNATE_TIME_IN_MINUTES;

static {
try {
MAX_RETRIES = Integer.parseInt(VMProps.get(CommonCons.MAX_RETRIES));
HIBERNATE_TIME_IN_MINUTES = Integer.parseInt(VMProps
.get(VMCons.HIBERNATE_TIME_IN_MINUTES));
} catch (Exception ignore) {
throw new AppException(CommonCons.APP_INIT_ERROR);
}
}

/**
* This code sets the application to hibernate.
*
* The second argument:
*
* If it is true, it means that the same server must be used for processing
* as already a call has gone to this server
*
* If it is false, then it starts trying from the first server in the list
* of serverLoader.servers
*
*/
private void setAppToHibernateMode(boolean callNotPlaced,
Server currentServer) {

makeItEasyForUsByLogging(log, callNotPlaced, currentServer);

// Select the hibernate time
Calendar c = Calendar.getInstance();
c.add(Calendar.MINUTE, HIBERNATE_TIME_IN_MINUTES);
Date date = c.getTime();
handleToSTB.setStartTime(date);

if (callNotPlaced) {
log.info("Since callNotPlaced is " + callNotPlaced
+ " setting currentServer to null ");
signal.setCurrentServer(null);
}

serializeHelper.serializeSignal(signal);

// There shall be no more retries,
// while loop shall exit automatically,
// Instead we throw the error.
throw new VSException(ErrCons.APP_HIBERNATE);

}

public void setSignal(Signal sig) {
signal = sig;
}

public void setHandleToSTB(SimpleTriggerFactoryBean handleToST) {
this.handleToSTB = handleToST;
}

@Override
public void setServerLoader(ServerLoader serverLoad) {
this.serverLoader = serverLoad;
}

public void setSerializeHelper(SerializeHelper serializeHelper) {
this.serializeHelper = serializeHelper;
}

private void logboth(String message) {
log.error(message);
Metrics.writeln(message);
}
}

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Spring version utility -->
<spring.version>4.3.2.RELEASE</spring.version>
<spring-ws.version>2.2.4.RELEASE</spring-ws.version>

</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<!-- I have tested with multiple versions of quartz and without it, but to no avail.
<dependency>
<groupId>quartz</groupId>
<artifactId>quartz</artifactId>
<version>1.5.2</version>
</dependency>

<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.5</version>
</dependency>

<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>

<dependency>
<groupId>org.apache.archiva.redback.components</groupId>
<artifactId>spring-quartz</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jobs</artifactId>
<version>2.0.2</version>
</dependency>

<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.spring-context-support</artifactId>
<version>4.0.1.RELEASE_4</version>
</dependency>
-->

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.46</version>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk16</artifactId>
<version>1.46</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>

<dependency>
<groupId>toplink.essentials</groupId>
<artifactId>toplink-essentials</artifactId>
<version>2.1-60f</version>
</dependency>

<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>

<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4.1</version>
</dependency>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>3.1.3</version>
</dependency>

<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-common</artifactId>
<version>3.1.3</version>
</dependency>

<dependency>
<groupId>org.apache.ws.commons.util</groupId>
<artifactId>ws-commons-util</artifactId>
<version>1.0.2</version>
</dependency>

<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-server</artifactId>
<version>3.1.3</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>${spring-ws.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core-tiger</artifactId>
<version>1.5.10</version>
</dependency>

<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-security</artifactId>
<version>${spring-ws.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-support</artifactId>
<version>${spring-ws.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
<version>${spring-ws.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.2.0</version>
</dependency>

<dependency>
<groupId>org.codehaus.castor</groupId>
<artifactId>castor</artifactId>
<version>1.2</version>
<!-- <scope>provided</scope> -->
</dependency>

<dependency>
<groupId>logkit</groupId>
<artifactId>logkit</artifactId>
<version>1.0.1</version>
<!-- <scope>provided</scope> -->
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.6.4</version>
</dependency>

<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1.3</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>

</dependencies>
</project>

我已经测试了多个版本的 Spring 和 quartz 。

如果我删除所有对 retryHandlerImpl 的引用(包括 inputController、scheduleFileReaderJob 和 fileTrigger),异常仍然会抛出。

<bean name="retryHandlerImpl" class="com.myproject.code.rpc.vscall.RetryHandlerImpl">
/*
<property name="passwordManager" ref="passwordManager" />
<property name="signal" ref="signal" />
<property name="handleToSTB" ref="fileTrigger" />
<property name="serverLoader" ref="serverLoader" />
<property name="serializeHelper" ref="serializeHelper" />
*/
</bean>

<bean name="invalRpcHelper" class="com.myproject.code.rpc.calls.InvalRpcHelperImpl">
//<property name="rpcHelper" ref="retryHandlerImpl" />
</bean>

关于为什么存在这种依赖关系,或者哪个库的哪个版本将成为神奇组合的任何想法或想法都将受到欢迎。

最诚挚的问候,

最佳答案

解决方案: 在从 ant 升级到 maven 的过程中出现了一个错误,类的编译版本被放置在 WEB-INF 目录中。

这导致了运行时一些离散的冲突。只有根本不加载所涉及的类,应用程序才能绕过该问题,从而出现可疑的症状。

从 WEB-INF 中删除该文件夹解决了问题。

关于java - NoClassDefFound错误: org/springframework/scheduling/quartz/SimpleTriggerBean when using SimpleTriggerFactoryBean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39621574/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com