当前位置: 首页 > 知识库问答 >
问题:

EJB 3.1 绑定在 Websphere 应用程序服务器上不起作用

鱼安然
2023-03-14

我想从另一个 ejb 项目中的另一个单例 EJB 中调用 ejb 上的本地无状态 EJB。两个 EJB 项目都位于同一个 ear 文件中。应用程序服务器是 WebSphere 应用程序服务器 8.0.0.1。

第一个EJB 3.1-项目(PersistenceEJB.jar):

连接

@Local
public interface TaskInfoDao extends DaoTemplate<TaskInfo> {
    public int deleteAll();
}

无状态Bean:

@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class TaskInfoDaoImpl implements TaskInfoDao {
    private static final long serialVersionUID = 1L;

    @PersistenceContext(unitName = "MyDatasource")
    private EntityManager em;

    @Override
    public int deleteAll() {
        Query query = em.createQuery("DELETE FROM TaskInfo t");
        int count = query.executeUpdate();
        return count;
    }

}

ejb jar。xml和ibm ejb jar bnd。xml为空。

第二个EJB 3.1项目(SchedulerEJB.jar):

单身:

@Startup
@Singleton
public class StartUpBean {
    private final static Logger LOGGER = Logger.getLogger(StartUpBean.class
            .getName());

    @EJB
    private TaskInfoDao taskInfoDao;

    @PostConstruct
    public void onStart() {
        LOGGER.info("DELETED: " + taskInfoDao.deleteAll());
   }
}

META-INF公司

Manifest-Version: 1.0
Class-Path: PersistenceEJB.jar

我的“ejb-jar.xml”和“ibm-ejb-jar-bnd.xml”都是空的(在两个项目中)。

Eear-File:-META-INF|-application.xml|-ibm-application-ext.xml|-ibm-applcaiton-bnd.xml|-MANIFEST.MF-PersistenceEJB.jar-SchedulerEJB.jar

应用.xml:

<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="6"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
    <description>...</description>
    <display-name>SchedulerAppEAR</display-name>
    <module id="Module_1392974920540">
        <ejb>SchedulerEJB.jar</ejb>
    </module>
    <module id="Module_1392975196627">
        <ejb>PersistenceEJB.jar</ejb>
    </module>
</application>

ear META-INF中的其他文件是空的。

在JVM-Startup上,我得到以下异常:

[21.02.14 13:15:16:760 CET] 0000003a EJBApplicatio E   CNTR0190E: The StartUpBean startup singleton session bean in the SchedulerEJB.jar module failed initialization with exception:
javax.ejb.NoSuchEJBException: An error occurred during initialization of singleton session bean SchedulerAppEAR#SchedulerEJB.jar#StartUpBean, resulting in the discarding of the singleton instance.; nested exception is: javax.ejb.EJBException: The scheduler.StartUpBean/taskInfoDao EJB reference in the StartUpBean component in the SchedulerEJB.jar module of the SchedulerAppEAR application could not be resolved; nested exception is: com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
javax.ejb.EJBException: The scheduler.StartUpBean/taskInfoDao EJB reference in the StartUpBean component in the SchedulerEJB.jar module of the SchedulerAppEAR application could not be resolved; nested exception is: com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
    at com.ibm.ejs.container.HomeOfHomes.getHomeByInterface(HomeOfHomes.java:928)
    at com.ibm.ws.ejbcontainer.injection.factory.EJBLinkObjectFactory.getObjectInstance(EJBLinkObjectFactory.java:261)
    at com.ibm.ws.ejbcontainer.injection.factory.EJBLinkObjectFactory.getObjectInstance(EJBLinkObjectFactory.java:167)
    at com.ibm.ws.injectionengine.processor.EJBInjectionBinding.getInjectionObject(EJBInjectionBinding.java:1181)
    at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectableObject(InjectionBinding.java:1003)
    at com.ibm.wsspi.injectionengine.InjectionTarget.inject(InjectionTarget.java:198)
    at com.ibm.ws.injectionengine.AbstractInjectionEngine.inject(AbstractInjectionEngine.java:924)
    at com.ibm.ejs.container.SingletonBeanO.initialize(SingletonBeanO.java:382)
    at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:147)
    at com.ibm.ejs.container.EJSHome.createSingletonBeanO(EJSHome.java:4985)
    at com.ibm.ejs.csi.EJBApplicationMetaData.createStartupBeans(EJBApplicationMetaData.java:971)
    at com.ibm.ejs.csi.EJBApplicationMetaData.startedModule(EJBApplicationMetaData.java:695)
    at com.ibm.ws.runtime.component.EJBContainerImpl.stateChanged(EJBContainerImpl.java:5501)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.stateChanged(ApplicationMgrImpl.java:1083)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectEvent(DeployedApplicationImpl.java:1352)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:247)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:243)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:641)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:967)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:744)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1332)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2128)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:663)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5315)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5531)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:677)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:621)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1224)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:49)
    at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:256)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1085)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:966)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
    at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181)
    at com.ibm.ws.management.connector.ipc.CallRouter.route(CallRouter.java:247)
    at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.doWork(IPCConnectorInboundLink.java:353)
    at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.ready(IPCConnectorInboundLink.java:132)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1650)
javax.ejb.EJBException: The scheduler.StartUpBean/taskInfoDao EJB reference in the StartUpBean component in the SchedulerEJB.jar module of the SchedulerAppEAR application could not be resolved; nested exception is: com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
Caused by: com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
    at com.ibm.ejs.container.HomeOfHomes.getHomeByInterface(HomeOfHomes.java:928)
    at com.ibm.ws.ejbcontainer.injection.factory.EJBLinkObjectFactory.getObjectInstance(EJBLinkObjectFactory.java:261)
    at com.ibm.ws.ejbcontainer.injection.factory.EJBLinkObjectFactory.getObjectInstance(EJBLinkObjectFactory.java:167)
    at com.ibm.ws.injectionengine.processor.EJBInjectionBinding.getInjectionObject(EJBInjectionBinding.java:1181)
    at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectableObject(InjectionBinding.java:1003)
    at com.ibm.wsspi.injectionengine.InjectionTarget.inject(InjectionTarget.java:198)
    at com.ibm.ws.injectionengine.AbstractInjectionEngine.inject(AbstractInjectionEngine.java:924)
    at com.ibm.ejs.container.SingletonBeanO.initialize(SingletonBeanO.java:382)
    at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:147)
    at com.ibm.ejs.container.EJSHome.createSingletonBeanO(EJSHome.java:4985)
    at com.ibm.ejs.csi.EJBApplicationMetaData.createStartupBeans(EJBApplicationMetaData.java:971)
    at com.ibm.ejs.csi.EJBApplicationMetaData.startedModule(EJBApplicationMetaData.java:695)
    at com.ibm.ws.runtime.component.EJBContainerImpl.stateChanged(EJBContainerImpl.java:5501)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.stateChanged(ApplicationMgrImpl.java:1083)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectEvent(DeployedApplicationImpl.java:1352)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:247)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:243)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:641)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:967)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:744)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1332)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2128)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:663)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5315)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5531)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:677)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:621)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1224)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:49)
    at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:256)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1085)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:966)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
    at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181)
    at com.ibm.ws.management.connector.ipc.CallRouter.route(CallRouter.java:247)
    at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.doWork(IPCConnectorInboundLink.java:353)
    at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.ready(IPCConnectorInboundLink.java:132)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1650)
javax.ejb.NoSuchEJBException: An error occurred during initialization of singleton session bean SchedulerAppEAR#SchedulerEJB.jar#StartUpBean, resulting in the discarding of the singleton instance.; nested exception is: javax.ejb.EJBException: The scheduler.StartUpBean/taskInfoDao EJB reference in the StartUpBean component in the SchedulerEJB.jar module of the SchedulerAppEAR application could not be resolved; nested exception is: com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
Caused by: javax.ejb.EJBException: The scheduler.StartUpBean/taskInfoDao EJB reference in the StartUpBean component in the SchedulerEJB.jar module of the SchedulerAppEAR application could not be resolved; nested exception is: com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
Caused by: com.ibm.ejs.container.EJBNotFoundException: EJB with interface persistence.dao.TaskInfoDao not present in application SchedulerAppEAR
    at com.ibm.ejs.container.HomeOfHomes.getHomeByInterface(HomeOfHomes.java:928)
    at com.ibm.ws.ejbcontainer.injection.factory.EJBLinkObjectFactory.getObjectInstance(EJBLinkObjectFactory.java:261)
    at com.ibm.ws.ejbcontainer.injection.factory.EJBLinkObjectFactory.getObjectInstance(EJBLinkObjectFactory.java:167)
    at com.ibm.ws.injectionengine.processor.EJBInjectionBinding.getInjectionObject(EJBInjectionBinding.java:1181)
    at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectableObject(InjectionBinding.java:1003)
    at com.ibm.wsspi.injectionengine.InjectionTarget.inject(InjectionTarget.java:198)
    at com.ibm.ws.injectionengine.AbstractInjectionEngine.inject(AbstractInjectionEngine.java:924)
    at com.ibm.ejs.container.SingletonBeanO.initialize(SingletonBeanO.java:382)
    at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:147)
    at com.ibm.ejs.container.EJSHome.createSingletonBeanO(EJSHome.java:4985)
    at com.ibm.ejs.csi.EJBApplicationMetaData.createStartupBeans(EJBApplicationMetaData.java:971)
    at com.ibm.ejs.csi.EJBApplicationMetaData.startedModule(EJBApplicationMetaData.java:695)
    at com.ibm.ws.runtime.component.EJBContainerImpl.stateChanged(EJBContainerImpl.java:5501)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.stateChanged(ApplicationMgrImpl.java:1083)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectEvent(DeployedApplicationImpl.java:1352)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:247)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:243)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:641)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:967)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:744)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1332)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2128)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:663)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5315)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5531)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:677)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:621)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1224)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:49)
    at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:256)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1085)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:966)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
    at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181)
    at com.ibm.ws.management.connector.ipc.CallRouter.route(CallRouter.java:247)
    at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.doWork(IPCConnectorInboundLink.java:353)
    at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.ready(IPCConnectorInboundLink.java:132)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1650)

那么我的代码有什么问题?

提前感谢!

编辑:当我为我的startupbean使用ibm.websphere.startupservice接口时,bean注入工作正常。为了使用这个接口,我移除了@Startup @ Singleton接口。此外,我将我的类别更改为:

public class StartUpBean implements javax.ejb.SessionBean {
 ...
 public boolean start() throws FileNotFoundException {
   ...
   return true;
 }
}

还有我的电子罐子.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="3.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
    <display-name>SchedulerEJB</display-name>
    <enterprise-beans>
        <session id="StartUp">
            <ejb-name>StartUp</ejb-name>
            <home>com.ibm.websphere.startupservice.AppStartUpHome</home>
            <remote>com.ibm.websphere.startupservice.AppStartUp</remote>
            <ejb-class>ejb.StartUpBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Bean</transaction-type>
        </session>
        </enterprise-beans>
</ejb-jar>

但我不喜欢这种方式,因为它取决于我使用的应用程序服务器...

共有1个答案

太叔乐家
2023-03-14

由于 TaskInfoDaoImpl Bean 包含在与包含客户机类的模块不同的模块中,因此请尝试在@EJB注释中使用可移植的 JNDI 名称,如下所示:

@EJB(name="java:app/PersistenceEJB/TaskInfoDaoImpl")
private TaskInfoDao taskInfoDao;

更多信息请点击这里。

 类似资料:
  • 应用服务器:IBM Websphere Java 6 问题: 以下是web应用程序的文件夹结构: WEB-INF/库/道具/ 问题是下面的代码不工作: this.getClass(). getResourceAsStream('/props'/fileName),其中fileName是WEB-INF/lib/pros的props文件夹中的有效文件名。 调用上述方法的类位于JAR中,并包含在lib中

  • 我想知道是否有一种方法可以在一个地方管理多个was liberty profile应用服务器?就像WAS full profile有一个WAS控制台,在那里你可以开始,停止,配置,生成-插件等功能,但类似的东西?

  • 问题内容: 我对此设置有问题,甚至无法查看日志。 这是我的 EJB: 的: Maven pom: 问题答案: 您具有无效的bean类型作为@DependsOn的属性。DependsOn用于表达两个Singleton会话Bean之间的依赖性,而不是Singleton和Stateless之间的依赖性。您应该将SchedulerEJB更改为Singleton或删除依赖项。 如果您决定将Scheduler

  • 我在WebSphere控制台上部署了WAR文件,并将其映射到数据源。我能够测试我用PostgreSQL服务器详细信息配置的数据源。但是我的应用程序没有连接到服务器。我是新来的WebSphere,谁能帮我配置基于下面context.xml文件的数据源。我的应用程序在tomcat中工作得很好,但在WebSphere中却不行。 我认为我在数据源配置中做错了什么。

  • 我尝试在azure应用程序服务中使用扩展将COMPLUS\u LoaderOptimization环境变量设置为1。在我检查kudu中的process explorer时,COMPLUS\u LoaderOptimization被设置为1,但它仍然无法按预期工作,无法以非域无关的方式加载程序集。azure应用程序服务是否支持此功能?

  • 我创建了一个工作正常的Spring启动应用程序,但我无法获得与该应用程序捆绑在一起的Rest服务。请找到下面的代码。我能够访问urlhttp://localhost:8080/springbootr/但无法访问web服务urlhttp://localhost:8080/springbootr/Hello/,在web服务调用时得到404。 pom。xml: 我是这个应用程序的新手,请帮助我。