Websphere Liberty Base 17 上的 EJBConfigurationException
EJBConfigurationException on Websphere Liberty Base 17
我必须将一个软件项目从 Websphere Application Server v8 (WAS8) 迁移到 Webphere Liberty Base v17 (WL17) 并且 运行 遇到 EJB 的问题。例如。有以下 EJB:
@Stateless
@Local(MyUserServiceLocal.class)
public class MyUserServiceBean implements MyUserServiceLocal {
@EJB
private OtherServiceLocal otherServiceLocal;
@Resource
private SessionContext context;
public MyUserServiceBean() {
}
public String getUserEmail() {...}
public String getUserDataId() throws ServiceException {...}
...
}
对应本地接口:
@Local
public interface MyUserServiceLocal {
public String getUserEmail();
public String getUserDataId() throws ServiceException;
...
}
有更多的 EJB 遵循类似的实现方案。
项目构建良好,所有 Eclipse 项目中的所有方面都已正确设置,并且 maven 创建了一个全新的可部署 EAR 文件。但是当我访问应用程序默认页面时,会抛出以下嵌套异常:The MyUserServiceBean bean class for the MyApplication#MyUserServiceEjb.jar#MyUserServiceBean bean does not have a public constructor that does not take parameters.
目前想不通WL17为什么会抛出这个异常。我的 WL 的功能配置如下所示:
<featureManager>
<feature>appSecurity-2.0</feature>
<feature>cdi-1.2</feature>
<feature>distributedMap-1.0</feature>
<feature>ejbLite-3.2</feature>
<feature>ejb-3.2</feature>
<feature>jacc-1.5</feature>
<feature>jaxrs-2.0</feature>
<feature>jaxws-2.2</feature>
<feature>jca-1.7</feature>
<feature>jdbc-4.1</feature>
<feature>jndi-1.0</feature>
<feature>jpa-2.1</feature>
<feature>jsf-2.2</feature>
<feature>jsp-2.3</feature>
<feature>ldapRegistry-3.0</feature>
<feature>mdb-3.2</feature>
<feature>servlet-3.1</feature>
<feature>ssl-1.0</feature>
<feature>webCache-1.0</feature>
<feature>wmqJmsClient-2.0</feature>
</featureManager>
我不加载mdb或者ejb特性的时候也是一样。有什么办法解决这个问题吗?我在谷歌上搜索了很多并阅读了一半的互联网但没有得到答案或解决这个问题的想法。
我发现了EJB的问题。其中一个接口方法被声明为抛出 javax.xml.rpc.ServiceException
。我不明白为什么这应该是个问题,但是在删除接口中的 throws
声明和实现后 class WL 17 能够正确初始化 bean。
我必须将一个软件项目从 Websphere Application Server v8 (WAS8) 迁移到 Webphere Liberty Base v17 (WL17) 并且 运行 遇到 EJB 的问题。例如。有以下 EJB:
@Stateless
@Local(MyUserServiceLocal.class)
public class MyUserServiceBean implements MyUserServiceLocal {
@EJB
private OtherServiceLocal otherServiceLocal;
@Resource
private SessionContext context;
public MyUserServiceBean() {
}
public String getUserEmail() {...}
public String getUserDataId() throws ServiceException {...}
...
}
对应本地接口:
@Local
public interface MyUserServiceLocal {
public String getUserEmail();
public String getUserDataId() throws ServiceException;
...
}
有更多的 EJB 遵循类似的实现方案。
项目构建良好,所有 Eclipse 项目中的所有方面都已正确设置,并且 maven 创建了一个全新的可部署 EAR 文件。但是当我访问应用程序默认页面时,会抛出以下嵌套异常:The MyUserServiceBean bean class for the MyApplication#MyUserServiceEjb.jar#MyUserServiceBean bean does not have a public constructor that does not take parameters.
目前想不通WL17为什么会抛出这个异常。我的 WL 的功能配置如下所示:
<featureManager>
<feature>appSecurity-2.0</feature>
<feature>cdi-1.2</feature>
<feature>distributedMap-1.0</feature>
<feature>ejbLite-3.2</feature>
<feature>ejb-3.2</feature>
<feature>jacc-1.5</feature>
<feature>jaxrs-2.0</feature>
<feature>jaxws-2.2</feature>
<feature>jca-1.7</feature>
<feature>jdbc-4.1</feature>
<feature>jndi-1.0</feature>
<feature>jpa-2.1</feature>
<feature>jsf-2.2</feature>
<feature>jsp-2.3</feature>
<feature>ldapRegistry-3.0</feature>
<feature>mdb-3.2</feature>
<feature>servlet-3.1</feature>
<feature>ssl-1.0</feature>
<feature>webCache-1.0</feature>
<feature>wmqJmsClient-2.0</feature>
</featureManager>
我不加载mdb或者ejb特性的时候也是一样。有什么办法解决这个问题吗?我在谷歌上搜索了很多并阅读了一半的互联网但没有得到答案或解决这个问题的想法。
我发现了EJB的问题。其中一个接口方法被声明为抛出 javax.xml.rpc.ServiceException
。我不明白为什么这应该是个问题,但是在删除接口中的 throws
声明和实现后 class WL 17 能够正确初始化 bean。