Search code examples
web-servicesjava-ee-6glassfish-3

Error while deploying several inherited web services on glassfish v3


I try to deploy several web services on glassfish v3. Unfortunatly I get in 6 of 8 tries an error that the bundle doesn't contains an bean.

The strange is that it will work when i try it several times.

Here my code:

Class BaseWebServcie:

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.ejb.Stateless;
import javax.jws.WebService; 
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

@WebService
@Stateless
public class BaseWebService {

@PersistenceContext
EntityManager em; 

public long getResponse() {

            //using EntityManager
            ...
    return new Date().getTime();
}
}

Class: WebServiceProxy1

import javax.ejb.Stateless;
import javax.jws.WebService;

@WebService
@Stateless 
public class ConcreteWebService1 extends BaseConcreteWebService {
}

My Project contains several other Web Services. All inherit a getResponse() method from class BaseWebService. But if I try to deploy it on glassfish the following error messages appears.

Schwerwiegend: Referencing error: This bundle has no bean of name [BaseConcreteWebService] Schwerwiegend: Exception while deploying the app [ConcreteWebService] Schwerwiegend: Referencing error: This bundle has no bean of name [BaseConcreteWebService]at org.glassfish.apf.AnnotationInfo@6c7f1f java.lang.IllegalStateException: Referencing error: This bundle has no bean of name [BaseConcreteWebService]at org.glassfish.apf.AnnotationInfo@6c7f1f at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:487) at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:429) at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:405) at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:380) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:243) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:252) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:213) at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:165) 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.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375) at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:219) at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131) at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91) at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82) at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67) at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139) at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78) at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253) at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145) at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136) at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79) at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63) at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69) at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97) at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)

Is there anybody how knows how this problem can be solved?

Much thanks.


Solution

  • The order in which EJBs get deployed is not deterministic since it is based on looping through a Java HashSet. So when a child EJB is loaded, GF tries to lookup the parent EJB, but if the parent EJB has not been loaded yet, you'll encounter the "Referencing error:". Our workaround was to use EJB composition instead of inheritance. We had the same issue with GF 3.1.1.. Hopefully this issue is resolved in newer versions of GF.