在glassfish v3上部署多个继承的Web服务时出错

时间:2012-08-01 11:07:14

标签: web-services java-ee-6 glassfish-3

我尝试在glassfish v3上部署多个Web服务。不幸的是,我在8次尝试中遇到了一个错误,该包不包含bean。

奇怪的是,当我多次尝试时它会起作用。

这是我的代码:

Class BaseWebServie:

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();
}
}

类:WebServiceProxy1

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

@WebService
@Stateless 
public class ConcreteWebService1 extends BaseConcreteWebService {
}

我的项目包含其他几个Web服务。所有都从类BaseWebService继承getResponse()方法。但是,如果我尝试将其部署在glassfish上,则会显示以下错误消息。

Schwerwiegend:引用错误:此包没有名称的bean [BaseConcreteWebService] Schwerwiegend:部署应用程序时出现异常[ConcreteWebService] Schwerwiegend:引用错误:该包在org.glassfish.apf.AnnotationInfo@6c7f1f中没有名称[BaseConcreteWebService]的bean java.lang.IllegalStateException:引用错误:此包在org.glassfish.apf.AnnotationInfo@6c7f1f中没有名称为[BaseConcreteWebService]的bean     在com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:487)     在com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:429)     在com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:405)     在com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:380)     在com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:243)     在com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:252)     在com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:213)     在com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:165)     在org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:185)     在org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:94)     在com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:827)     at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:769)     在com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)     在com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)     在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)     在com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253)     在com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)     在com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)     在com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)     在com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)     在com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69)     在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)     在java.lang.reflect.Method.invoke(Method.java:601)     在com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)     在com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)

有谁知道如何解决这个问题?

非常感谢。

1 个答案:

答案 0 :(得分:0)

EJB的部署顺序不确定,因为它基于循环Java HashSet。因此,当加载子EJB时,GF会尝试查找父EJB,但如果尚未加载父EJB,则会遇到“引用错误:”。我们的解决方法是使用EJB组合而不是继承。我们在GF 3.1.1中遇到了同样的问题。希望这个问题在更新版本的GF中得到解决。