gpt4 book ai didi

java - 非法参数异常 : Invalid ejb jar: it contains zero ejb

转载 作者:太空宇宙 更新时间:2023-11-04 13:43:55 25 4
gpt4 key购买 nike

我似乎对这个问题有很多疑问,但我仍然无法解决它,我知道当尝试部署没有任何用 @Stateless、@Stateful、@MessageDriven 或 @Singleton 注释的类的 ejb 模块时会抛出此异常。但这不是我的情况,我有几个类注释如下:

@Stateless
@Remote(TestServiceInterface.class)
public class TestService extends TestSuperclass implements TestServiceInterface<Test>, Serializable{
}

这是界面:

public interface TestServiceInterface<T> extends AnotherInterface<T>{
}

我的所有接口(interface)都位于另一个项目中,该项目的 jar 作为 lib 添加到我的 ejb 模块中。

当我尝试部署时,出现以下异常:

1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. 
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:76)
at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:128)
at com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:730)
at com.sun.enterprise.deployment.Application.visit(Application.java:1765)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:195)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:185)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:94)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:827)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:769)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:745).

更新:

它还在抛出异常之前打印此行:

[#|2015-06-25T08:43:22.256-0300|WARNING|glassfish3.1.2|global|_ThreadID=126;_ThreadName=Thread-2;|Error in annotation processing: java.lang.NoClassDefFoundError: com/packageName/TestServiceInterface|#]

更新2

看起来 netbeans 能够以某种方式部署它!但是,如果我尝试直接在 glassfish 管理页面上或通过命令行(“asadmin deploy”)进行部署,则会出现异常。

我可能遗漏了一些东西,任何帮助将不胜感激。

最佳答案

由于某种原因,我的 TestSuperclass 似乎无法由远程 EJB 扩展,因此我必须删除 extends TestSuperclass

而不是这个:

@Stateless
@Remote(TestServiceInterface.class)
public class TestService extends TestSuperclass implements TestServiceInterface<Test>, Serializable{
}

我这样声明该类:

@Stateless
@Remote(TestServiceInterface.class)
public class TestService implements TestServiceInterface<Test>, Serializable{
}

现在它不再抛出异常了。

关于java - 非法参数异常 : Invalid ejb jar: it contains zero ejb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31050067/

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