gpt4 book ai didi

java - weblogic Server10.6中EJB定时器异常

转载 作者:行者123 更新时间:2023-12-01 14:03:10 25 4
gpt4 key购买 nike

我是EJB新手,我在EJB中编写了一个小定时器,我想在特定的时间间隔调用webservice。我已经尝试过编程计时器、自动计时器,但仍然遇到同样的错误。我不知道我错过了什么。

以下相同。

package timer;

import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timer;
import java.util.*;

@Stateless
public class Timer2 {
private Date lastProgrammaticTimeout;
private Timer _timer;

@SuppressWarnings("unused")
@Schedule(minute="*/3", hour="*")
private void scheduledTimeout(final Timer t) {
_timer=t;
System.out.println("@time remaining: " + _timer.getTimeRemaining());
}

public void cancelMySimpleTimer() {
if( _timer!=null)
_timer.cancel();
System.out.println("@Schedule called at: "+ lastProgrammaticTimeout);
}
}

以下是我生成的ejb.jar

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">

<display-name>EJBTimer </display-name>

</ejb-jar>

将其部署到服务器时出现以下错误

Module named 'EJBTimer' failed to deploy. See Error Log view for more detail.
weblogic.application.ModuleException: Exception preparing module: EJBModule(EJBTimer)


Unable to deploy EJB: EJBTimer from EJBTimer:



There are 1 nested errors:

weblogic.ejb.container.compliance.ComplianceException: No business interface, component interface or web service endpoint interface found for Session Bean Timer2
at weblogic.ejb.container.compliance.SessionBeanClassChecker.checkInterfacesExist(SessionBeanClassChecker.java:177)
at weblogic.ejb.container.compliance.Ejb30SessionBeanClassChecker.checkInterfacesExist(Ejb30SessionBeanClassChecker.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.ejb.container.compliance.EJBComplianceChecker.check(EJBComplianceChecker.java:331)
at weblogic.ejb.container.compliance.EJBComplianceChecker.checkDeploymentInfo(EJBComplianceChecker.java:280)
at weblogic.ejb.container.ejbc.EJBCompiler.checkCompliance(EJBCompiler.java:791)
at weblogic.ejb.container.ejbc.EJBCompiler.doCompile(EJBCompiler.java:222)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:463)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:429)
at weblogic.ejb.container.deployer.EJBDeployer.runEJBC(EJBDeployer.java:439)
at weblogic.ejb.container.deployer.EJBDeployer.compileJar(EJBDeployer.java:795)
at weblogic.ejb.container.deployer.EJBDeployer.compileIfNecessary(EJBDeployer.java:683)
at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:1254)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:442)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:518)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:54)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:159)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:47)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:649)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:54)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:44)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:209)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:749)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:160)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:47)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)




Exception received from deployment driver. See Error Log view for more detail.

请帮助我..

最佳答案

您拥有的是一个用 Java EE6 完成的无状态 session bean。 Weblogic Server 10.3.6 (11g) 不支持这一点。请参阅compability chart - 它仅支持 Java EE 5。

要使用 EE5,需要 example in Wikipedia .

如果你将它用于你的bean,它会像

package timer;

import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timer;
import java.util.*;

@Stateless
public class Timer2 implements TimerService {
private Date lastProgrammaticTimeout;
private Timer _timer;

@SuppressWarnings("unused")
@Schedule(minute="*/3", hour="*")
private void scheduledTimeout(final Timer t) {
_timer=t;
System.out.println("@time remaining: " + _timer.getTimeRemaining());
}

public void cancelMySimpleTimer() {
if( _timer!=null)
_timer.cancel();
System.out.println("@Schedule called at: "+ lastProgrammaticTimeout);
}
}

package timer;

import javax.ejb.Remote;

@Remote
public interface TimerService {
void cancelMySimpleTimer();
}

关于java - weblogic Server10.6中EJB定时器异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19181124/

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