0

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

下面是一样的。

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.

请帮我..

4

1 回答 1

1

您所拥有的是在 Java EE6 中完成的无状态会话 bean。Weblogic Server 10.3.6 (11g) 不支持。请参阅兼容性图表- 它仅支持 Java EE 5。

要使用 EE5,Wikipedia 中有一个示例

如果你把它用在你的豆子上,它会像

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();
}
于 2013-10-04T13:00:47.997 回答