我正在开发Java EE 7 Web应用程序。我使用的技术:Maven,JPA 2.1,EJB 3.2,JSF 2.2,WildFly 10 Final。
我注意到EJB注入错误
使用类型'... InsuranceHouseDAO'的接口找到多个EJB进行绑定... InsuranceHouseServiceBean / insuranceHouseDAO“。
以下是InsuranceHouseDAO
类,位于 pm-domain Maven模块中:
@Local
public interface InsuranceHouseDAO extends BaseDao<InsuranceHouse> {
}
这是InsuranceHouseDAOBean
类,它实现了接口:
@Stateless
public class InsuranceHouseDAOBean extends BaseDAOBean<InsuranceHouse> implements InsuranceHouseDAO {
public InsuranceHouseDAOBean() {
super(InsuranceHouse.class);
}
}
pm-services 模块中的InsuranceHouseService
接口如下:
@Local
public interface InsuranceHouseService {
public void create(final InsuranceHouseTO insuranceHouseTO);
public InsuranceHouseTO find(Long id);
public void update(InsuranceHouseTO insuranceHouseTO);
public void delete(InsuranceHouseTO insuranceHouseTO);
public List<InsuranceHouseTO> findAll() throws Exception;
public void deleteAll();
public boolean exists(Long id);
public Long count();
}
这是它的实现,InsuranceHouseServiceBean
类:
@Stateless
public class InsuranceHouseServiceBean implements InsuranceHouseService {
@EJB
private InsuranceHouseDAO insuranceHouseDAO;
@EJB
private InsuranceHouseAssembler insuranceHouseAssembler;
public InsuranceHouseServiceBean() {
}
@Override
public void create(InsuranceHouseTO insuranceHouseTO) {
InsuranceHouse insuranceHouse = insuranceHouseAssembler.dtoToModel(insuranceHouseTO);
insuranceHouseDAO.create(insuranceHouse);
}
@Override
public List<InsuranceHouseTO> findAll() throws Exception {
List<InsuranceHouseTO> dtoList = new LinkedList<>();
List<InsuranceHouse> insuranceHouseList;
try {
insuranceHouseList = insuranceHouseDAO.findAll();
if(insuranceHouseList != null){
for (InsuranceHouse insuranceHouse : insuranceHouseList) {
dtoList.add(insuranceHouseAssembler.modelToDto(insuranceHouse));
}
}
} catch (Exception e) {
// OK, the exception handling isn't perfect yet...
e.printStackTrace();
}
return dtoList;
}
// +other methods, which I haven't implemented yet
}
这是堆栈跟踪:
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Alpha7:deploy (default) on project pm-ear: Deployment failed: Operation failed: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {
[ERROR] "WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"patient-manager.ear\".\"pm-services-0.0.1-SNAPSHOT.jar\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"patient-manager.ear\".\"pm-services-0.0.1-SNAPSHOT.jar\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of subdeployment \"pm-services-0.0.1-SNAPSHOT.jar\" of deployment \"patient-manager.ear\"
[ERROR] Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0052: Failed to install component InsuranceHouseServiceBean
[ERROR] Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0408: More than one EJB found with interface of type 'edu.sapientia.patientmanager.domain.dao.InsuranceHouseDAO' for binding edu.sapientia.patientmanager.service.local.InsuranceHouseServiceBean/insuranceHouseDAO. Found: [View of type edu.sapientia.patientmanager.domain.dao.InsuranceHouseDAO for org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.subunit.\"patient-manager.ear\".\"pm-web-0.0.1-SNAPSHOT.war\".component.InsuranceHouseDAOBean}@5764b8ee, View of type edu.sapientia.patientmanager.domain.dao.InsuranceHouseDAO for org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.subunit.\"patient-manager.ear\".\"pm-domain-0.0.1-SNAPSHOT.jar\".component.InsuranceHouseDAOBean}@77e9c91c]"},
[ERROR] "WFLYCTL0180: Services with missing/unavailable dependencies" => [
[ERROR] "jboss.deployment.subunit.\"patient-manager.ear\".\"pm-services-0.0.1-SNAPSHOT.jar\".weld.weldClassIntrospector is missing [jboss.deployment.subunit.\"patient-manager.ear\".\"pm-services-0.0.1-SNAPSHOT.jar\".beanmanager]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean.ORB is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean.HandleDelegate is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantAssemblerBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean.InAppClientContainer is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean.ORB is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".PatientServiceBean.InstanceName is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".PatientServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean.ORB is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean]",
[ERROR] "jboss.deployment.unit.\"patient-manager.ear\".deploymentCompleteService is missing [jboss.deployment.subunit.\"patient-manager.ear\".\"pm-services-0.0.1-SNAPSHOT.jar\".deploymentCompleteService]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AdminServiceBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AdminServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean.InstanceName is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorServiceBean.ValidatorFactory is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseServiceBean.ValidatorFactory is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseServiceBean.ORB is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean.ValidatorFactory is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean.HandleDelegate is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean.InstanceName is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean.InstanceName is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".PatientServiceBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".PatientServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AdminServiceBean.HandleDelegate is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AdminServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".PatientAssemblerBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".PatientAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AdminServiceBean.InstanceName is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AdminServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean.HandleDelegate is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantAssemblerBean.ValidatorFactory is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean.Validator is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorServiceBean.InstanceName is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorServiceBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean.ValidatorFactory is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantAssemblerBean.ORB is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".AssistantAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean.ValidatorFactory is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".UserAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean.InstanceName is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".InsuranceHouseAssemblerBean]",
[ERROR] "jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorServiceBean.HandleDelegate is missing [jboss.naming.context.java.comp.patient-manager.\"pm-services-0.0.1-SNAPSHOT\".DoctorServiceBean]"
我也尝试使用@Inject
注释而不是@EJB
,但在这种情况下有一个有趣的行为:编译成功,但是每次部署都有一个例外。
当我尝试打开从findAll()
类调用InsuranceHouseServiceBean
方法的某个页面时,会发生以下错误:
无法将... InsuranceHouseService字段设置为... InsuranceHouseService $ 2112160917 $ Proxy $ _ $$ _ Weld $ EnterpriseProxy $。
每次部署都会很好。
我已将 beans.xml 放在META-INF和WEB-INF文件夹中。
这是我的支持bean,我在其中调用服务bean的findAll()
方法:
@Named
@RequestScoped
public class InsuranceHouseController {
@Inject
private InsuranceHouseService insuranceHouseService;
private InsuranceHouseTO insuranceHouseTO;
@Inject
private NavigationController navigationController;
private List<InsuranceHouseTO> insuranceHouses;
@PostConstruct
public void init(){
insuranceHouseTO = new InsuranceHouseTO();
insuranceHouses = new ArrayList<InsuranceHouseTO>();
try {
insuranceHouses = insuranceHouseService.findAll();
} catch (Exception e) {
// TODO: make exception handling...
e.printStackTrace();
}
}
public InsuranceHouseTO getInsuranceHouseTO() {
return insuranceHouseTO;
}
public void setInsuranceHouseTO(InsuranceHouseTO insuranceHouseTO) {
this.insuranceHouseTO = insuranceHouseTO;
}
public List<InsuranceHouseTO> getInsuranceHouses() {
return insuranceHouses;
}
public void setInsuranceHouses(List<InsuranceHouseTO> insuranceHouses) {
this.insuranceHouses = insuranceHouses;
}
public void registerInsuranceHouse(){
insuranceHouseService.create(insuranceHouseTO);
navigationController.moveToAdminCreateInsuranceHouse();
}
}
堆栈跟踪,属于此错误:
SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-118) Error Rendering View[/admin/insurancehousemanagement.xhtml]: java.lang.IllegalArgumentException: Can not set edu.sapientia.patientmanager.service.InsuranceHouseService field edu.sapientia.patientmanager.web.backingbeans.InsuranceHouseController.insuranceHouseService to edu.sapientia.patientmanager.service.local.InsuranceHouseService$2112160917$Proxy$_$$_Weld$EnterpriseProxy$
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:94)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:378)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:389)
at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:70)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72)
at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:121)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:101)
at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:178)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742)
at org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
at org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
at org.jboss.as.jsf.injection.weld.ForwardingELResolver.getValue(ForwardingELResolver.java:46)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
at com.sun.el.parser.AstValue.getBase(AstValue.java:150)
at com.sun.el.parser.AstValue.getValue(AstValue.java:199)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIData.getValue(UIData.java:732)
at org.primefaces.component.api.UIData.getDataModel(UIData.java:759)
at javax.faces.component.UIData.getRowCount(UIData.java:356)
at org.primefaces.component.api.UIData.calculateFirst(UIData.java:210)
at org.primefaces.component.datatable.DataTableRenderer.preRender(DataTableRenderer.java:115)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:83)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at org.omnifaces.facesviews.FacesViewsForwardingFilter.filterExtensionLess(FacesViewsForwardingFilter.java:128)
at org.omnifaces.facesviews.FacesViewsForwardingFilter.doFilter(FacesViewsForwardingFilter.java:89)
at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
有什么问题?
更新
父pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>pm-ear</module>
<module>pm-web</module>
<module>pm-services</module>
<module>pm-domain</module>
<module>pm-common</module>
</modules>
</project>
来自pm-domain
模块的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>pm-domain</artifactId>
<packaging>ejb</packaging>
<dependencies>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
来自pm-services
模块的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>pm-services</artifactId>
<packaging>ejb</packaging>
<dependencies>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-domain</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
来自pm-web
模块的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>pm-web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-services</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
来自pm-common
模块的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>pm-common</artifactId>
<packaging>jar</packaging>
</project>
来自pm-ear
模块的和pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>pm-ear</artifactId>
<packaging>ear</packaging>
<build>
<finalName>patient-manager</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<finalName>patient-manager</finalName>
<defaultLibBundleDir>lib/</defaultLibBundleDir>
<skinnyWars>true</skinnyWars>
<modules>
<webModule>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-web</artifactId>
</webModule>
<ejbModule>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-services</artifactId>
</ejbModule>
<ejbModule>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-domain</artifactId>
</ejbModule>
<jarModule>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-common</artifactId>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-web</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-services</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-domain</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-common</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
我只包含了poms的相关部分,主要是模块的依赖关系。
答案 0 :(得分:1)
我阅读了所有评论,我认为@Nikos Paraskevopoulos指出了正确的方向。
请注意,ejb模块“pm-services”,“pm-domain”和“pm-common”包含在文件根目录的ear文件 patient-manager.ear 中
此外,“pm-services”和“pm-common”是“pm-web”的编译依赖项,将包含在pm-web.war / WEB-INF / lib /
中因此,在编译时没有错误,但在 InsuranceHouseDAO 的运行时两个实例中,一个已加载:
如您所见,第一个日志在这方面是不言自明的。
所以解决方案是声明为 pm-web pom.xml的依赖项“pm-services”和“pm-common”:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>pm-web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-services</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>edu.sapientia.patientmanager</groupId>
<artifactId>pm-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>