IllegalArgumentException: Invalid ejb jar: it contains zero ejb

1.9k views Asked by At

I've seem plenty of questions regarding this issue and I still couldn't get it fixed, I'm aware that this exception is thrown when one tries to deploy an ejb module without any classes annotated with @Stateless, @Stateful, @MessageDriven or @Singleton. But that isn't my case, I have several classes annotated like this:

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

and here is the interface:

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

All of my interfaces are located in another project, which have its jar added to my ejb module as a lib.

When I try to deploy I get the following exception:

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).

UPDATE:

It also prints this line just before throwing the exception:

[#|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|#]

UPDATE 2

It seems like netbeans is somehow being able to deploy it! But if I try to deploy directly on the glassfish admin page or via command line("asadmin deploy") I get the exception.

I'm probably missing something, any help would be appreciated.

1

There are 1 answers

1
Leonardo Jines On BEST ANSWER

It seems like for some reason my TestSuperclass could not be extended by the remote EJB, so I had to remove the extends TestSuperclass.

Instead of this:

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

I declade the class like this:

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

Now it's not throwing the exception anymore.