spaghetti_code
spaghetti_code

Reputation: 145

Dependency injection error on Java EE project

I'm working on a Java EE 7 webapplication. The technologies, that I use: Maven, JPA 2.1, EJB 3.2, JSF 2.2, WildFly 10 Final.

I get an error by EJB injection saying

More than one EJB found with interface of type '...InsuranceHouseDAO' for binding ...InsuranceHouseServiceBean/insuranceHouseDAO".

Here is the InsuranceHouseDAO class, which is in the pm-domain Maven module:

@Local
public interface InsuranceHouseDAO extends BaseDao<InsuranceHouse> {

}

And here is the InsuranceHouseDAOBean class, which implements the interface:

@Stateless
public class InsuranceHouseDAOBean extends BaseDAOBean<InsuranceHouse> implements InsuranceHouseDAO {

    public InsuranceHouseDAOBean() {
        super(InsuranceHouse.class);
    }

}

The InsuranceHouseService interface in the pm-services module is the following:

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

}

And here is its implementation, the InsuranceHouseServiceBean class:

@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

}

And here is the stack trace:

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

I have also tried with @Inject annotation instead of @EJB, but in this case there is an interesting behavior: the compilation is successful, but by every second deploy there is an exception.

When I try to open a certain page, which call the findAll() method from the InsuranceHouseServiceBean class, the following error occurs:

Can not set ...InsuranceHouseService field to ...InsuranceHouseService$2112160917$Proxy$_$$_Weld$EnterpriseProxy$.

And it works well by every second deploy.

I have put the beans.xml in the META-INF and in the WEB-INF folders.

Here is my backing bean, where I call the findAll() method of the service bean:

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

}

And the stack trace, which belongs to this error:

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)

What is the problem?

UPDATE:

parent 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>

pom from pm-domain module:

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

pom from pm-services module:

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

pom from pm-web module:

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

pom from pm-common module:

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

and pom from pm-ear module:

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

I have included only the relevant parts of the poms, mainly the dependencies of the modules.

Upvotes: 0

Views: 2499

Answers (1)

Juan Pablo Perata
Juan Pablo Perata

Reputation: 43

I read all comments and I think @Nikos Paraskevopoulos is pointing you to the right direction.

Please take note that the ejb modules "pm-services", "pm-domain" and "pm-common" are included in ear file patient-manager.ear at the root of the file.

Besides, "pm-services" and "pm-common" are compile dependencies of "pm-web" and will be included in pm-web.war/WEB-INF/lib/

So, at compile time there are no errors, but in runtime two instances of InsuranceHouseDAO, one loaded:

  • one by the ejb pm-domain-0.0.1-SNAPSHOT.jar located at "patient-manager.ear"."pm-domain-0.0.1-SNAPSHOT.jar"
  • the other by "patient-manager.ear"."pm-web-0.0.1-SNAPSHOT.war"\WEB-INF\lib\pm-domain-0.0.1-SNAPSHOT.jar

The first log is self explanatory in this aspect as you can see.

So the solution would be to declare as provided the dependencies "pm-services" and "pm-common" of pm-web 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>
    <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>

Upvotes: 1

Related Questions