简体   繁体   中英

Jonas - Spring - Jersey REST - Bean Validation : ValidationException: No Validation Provider Found

I'm building a REST webservice application using Jonas 5.2.4, Jersey 2.15, Spring 4.13. 'til this point everything's allright. The application compile, deploy and react as expected.

Then I've tryed to add Bean Validation (JSR-303) of input rest resources fellowing thoses indications/exemples: https://jersey.java.net/documentation/latest/bean-validation.html or http://blog.trifork.com/2009/08/04/bean-validation-integrating-jsr-303-with-spring/

when I add the validation dependencies :

<dependency>
   <groupId>javax.validation</groupId>
   <artifactId>validation-api</artifactId>
   <version>1.1.0.Final</version>
</dependency>
<dependency>
   <groupId>org.glassfish.jersey.ext</groupId>
   <artifactId>jersey-bean-validation</artifactId>
   <version>2.15</version>
</dependency>

I have the fellowing stack :

[DEBUG] 2015-02-02 11:08:31,876 org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'beanValidator'
[WARN] 2015-02-02 11:08:31,879 org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanValidator' defined in file [C:\applications\java\jonas-full-5.2.4\EFInstance\work\webapps\jonas\single\yyyyyyRestEForce_2015.02.02-11.08.22.war\WEB-INF\classes\com\xxxxxx\crme\yyyyyyeforce\rest\BeanValidator.class]: Invocation of init method failed; nested exception is javax.validation.ValidationException: Could not create Configuration.
-  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
- at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
- at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
- at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
- at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
- at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
- at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
- at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
- at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
- at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
- at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
- at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
- at org.ow2.jonas.web.tomcat6.JOnASStandardContext.start(JOnASStandardContext.java:312)
- at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
- at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
- at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
- at org.ow2.jonas.web.tomcat6.Tomcat6Service.__doRegisterWar(Tomcat6Service.java:764)
- at org.ow2.jonas.web.tomcat6.Tomcat6Service.doRegisterWar(Tomcat6Service.java)
- at org.ow2.jonas.web.base.BaseWebContainerService.registerWar(BaseWebContainerService.java:1025)
- at org.ow2.jonas.web.base.BaseWebContainerService.registerWar(BaseWebContainerService.java:1263)
- at org.ow2.jonas.web.base.proxy.HttpOnDemandProxy.addWar(HttpOnDemandProxy.java:352)
- at org.ow2.jonas.web.base.WARDeployer.doDeploy(WARDeployer.java:70)
- at org.ow2.util.ee.deploy.impl.deployer.AbsDeployer$1.execute(AbsDeployer.java:93)
- at org.ow2.util.ee.deploy.impl.deployer.AbsDeployer$1.execute(AbsDeployer.java:91)
- at org.ow2.util.execution.helper.RunnableHelper.execute(RunnableHelper.java:77)
- at org.ow2.util.ee.deploy.impl.deployer.AbsDeployer.deploy(AbsDeployer.java:91)
- at org.ow2.util.ee.deploy.impl.deployer.DeployerManager.deploy(DeployerManager.java:148)
- at org.ow2.jonas.deployablemonitor.DeployableMonitor.checkModifiedDeployables(DeployableMonitor.java:675)
- at org.ow2.jonas.deployablemonitor.DeployableMonitor.updateArchives(DeployableMonitor.java:319)
- at org.ow2.jonas.deployablemonitor.DeployableMonitor.run(DeployableMonitor.java:213)
Caused by: javax.validation.ValidationException: Could not create Configuration.
- at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:198)
- at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:67)
- at com.xxxxxx.crme.yyyyyeforce.rest.BeanValidator.afterPropertiesSet(BeanValidator.java:23)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
- ... 32 more
Caused by: javax.validation.ValidationException: No Validation Provider Found. Check that a Validation Provider implementation is provided
- at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:193)
... 36 more

Here is the maven tree of the application. (Dependencies are pulled from the dao project part to be sure they're available everywhere):

[INFO] com.xxxxx.crme.yyyyyyEForce:yyyyyyEForceRest:war:0.0.1-SNAPSHOT
[INFO] +- com.xxxxx.crme.yyyyyyEForce:yyyyyyEForceServices:jar:0.0.1-SNAPSHOT:compile
[INFO] |  +- com.xxxxx.crme.yyyyyyEForce:yyyyyyEForceDao:jar:0.0.1-SNAPSHOT:compile
[INFO] |  |  +- org.springframework:spring-context:jar:4.1.3.RELEASE:compile
[INFO] |  |  |  +- org.springframework:spring-aop:jar:4.1.3.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-expression:jar:4.1.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-webmvc:jar:4.1.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:4.1.3.RELEASE:compile
[INFO] |  |  |  +- org.springframework:spring-jdbc:jar:4.1.3.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-tx:jar:4.1.3.RELEASE:compile
[INFO] |  |  +- org.springframework.security:spring-security-web:jar:3.1.4.RELEASE:compile
[INFO] |  |  |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  |  |  \- org.springframework.security:spring-security-core:jar:3.1.4.RELEASE:compile
[INFO] |  |  +- org.hibernate:hibernate-core:jar:4.3.8.Final:compile
[INFO] |  |  |  +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] |  |  |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] |  |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  |  |  +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO] |  |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  |  \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] |  |  \- org.jboss.logging:jboss-logging:jar:3.2.0.Final:compile
[INFO] |  +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.15:compile
[INFO] |  |  +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.15:compile
[INFO] |  |  +- org.glassfish.jersey.core:jersey-common:jar:2.15:compile
[INFO] |  |  |  +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] |  |  |  +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.15:compile
[INFO] |  |  |  \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] |  |  \- org.glassfish.jersey.core:jersey-server:jar:2.15:compile
[INFO] |  |     \- org.glassfish.jersey.core:jersey-client:jar:2.15:compile
[INFO] |  +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.15:compile
[INFO] |  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.3.2:compile
[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-core:jar:2.3.2:compile
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-databind:jar:2.3.2:compile
[INFO] |  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.3.2:compile
[INFO] |  |  |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.3.2:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.2:compile
[INFO] |  +- com.sun.jersey:jersey-json:jar:1.18.2:compile
[INFO] |  |  +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] |  |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] |  |  |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |  |  |     \- javax.activation:activation:jar:1.1:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] |  |  \- com.sun.jersey:jersey-core:jar:1.18.2:compile
[INFO] |  +- org.glassfish.jersey.ext:jersey-spring3:jar:2.15:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:3.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-core:jar:3.2.3.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-web:jar:3.2.3.RELEASE:compile
[INFO] |  +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b06:compile
[INFO] |  +- org.glassfish.hk2:hk2-api:jar:2.4.0-b06:compile
[INFO] |  |  +- javax.inject:javax.inject:jar:1:compile
[INFO] |  |  +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b06:compile
[INFO] |  |  \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b06:compile
[INFO] |  +- org.glassfish.hk2:hk2-locator:jar:2.4.0-b06:compile
[INFO] |  |  \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] |  +- org.glassfish.hk2:hk2:jar:2.4.0-b06:compile
[INFO] |  |  +- org.glassfish.hk2:config-types:jar:2.4.0-b06:compile
[INFO] |  |  +- org.glassfish.hk2:core:jar:2.4.0-b06:compile
[INFO] |  |  +- org.glassfish.hk2:hk2-config:jar:2.4.0-b06:compile
[INFO] |  |  |  \- org.jvnet:tiger-types:jar:1.4:compile
[INFO] |  |  +- org.glassfish.hk2:hk2-runlevel:jar:2.4.0-b06:compile
[INFO] |  |  \- org.glassfish.hk2:class-model:jar:2.4.0-b06:compile
[INFO] |  |     \- org.glassfish.hk2.external:asm-all-repackaged:jar:2.4.0-b06:compile
[INFO] |  +- org.glassfish.hk2:spring-bridge:jar:2.4.0-b06:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  +- org.glassfish.jersey.ext:jersey-bean-validation:jar:2.15:compile
[INFO] |  |  +- org.hibernate:hibernate-validator:jar:5.1.2.Final:compile
[INFO] |  |  |  \- com.fasterxml:classmate:jar:1.0.0:compile
[INFO] |  |  +- javax.el:javax.el-api:jar:2.2.4:compile
[INFO] |  |  \- org.glassfish.web:javax.el:jar:2.2.4:compile
[INFO] |  \- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] \- org.mockito:mockito-all:jar:1.10.8:test

Of course I've made the recommended changes: - The bean validator class

package com.xxxxx.crme.yyyyyeforce.rest;
import java.util.Set;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.ConstraintViolation;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;

@Component
public class BeanValidator implements 
        org.springframework.validation.Validator, 
        InitializingBean {

    private Validator validator;

    public void afterPropertiesSet() throws Exception {
        ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
        validator = validatorFactory.usingContext().getValidator();
    }

    public boolean supports(Class clazz) {
        return true;
    }

    public void validate(Object target, Errors errors) {
        Set<ConstraintViolation<Object>> constraintViolations = validator.validate(target);
        for (ConstraintViolation<Object> constraintViolation : constraintViolations) {
            String propertyPath = constraintViolation.getPropertyPath().toString();
            String message = constraintViolation.getMessage();
            errors.rejectValue(propertyPath, "", message);
        }
    }
}

The controller class managing rest requests :

package com.xxxxx.crme.yyyyyeforce.rest;

/** Classe <code>CountryResource</code><br /> */
@Path("/country")
@Controller
public class CountryResource {
    Logger logger = Logger.getLogger(CountryServiceImpl.class) ;

    @Autowired @Qualifier("countryService")
    private CountryService countryService ;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getAllCountries() {
        logger.debug("CountryResource - recherche de tous les pays");
        List<CountryDto> countryDtos = null ;
        Response serviceResponse = null ;
        if (countryService!=null) {
            try {
                countryDtos = countryService.getAllCountries();
                if (countryDtos != null) {
                    serviceResponse = Response.status(Response.Status.OK).
                        entity(countryDtos).
                        build();
                } else {
                    serviceResponse = Response.status(Response.Status.NO_CONTENT).entity("Numl list returned").build();
                }
            } catch (NoSuchElementException nse) {
                serviceResponse = Response.status(Response.Status.NO_CONTENT).entity(nse.getMessage()).build();

            } catch (InternalServerErrorException ise) {
                serviceResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ise.getMessage()).build();
            }
        } else {
            serviceResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("CountryService not available").build();
        }
        return serviceResponse;
    }

    /**Methode <code>getCountryByCode</code>*/
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("{code}")
    public Response getCountryByCode(@PathParam("code")
                @Pattern(regexp = "[A-Z]{3}", message = "The code must made of three capital letter")
                String code) {
        logger.debug("CountryResource - recherche du pays "+ code);
        Response serviceResponse = null ;
        CountryDto countryDto = null ; 
        if (countryService!=null) {
            try {
                countryDto = countryService.getCountryByCode(code) ;
                if (countryDto != null) {
                    serviceResponse = Response.status(Response.Status.OK).
                        entity(countryDto).
                        build();
                    logger.debug("CountryResource - Retourne pays "+ countryDto.toString());
                } else {
                    serviceResponse = Response.status(Response.Status.NOT_ACCEPTABLE).entity("Invalid contry found").build();
                }
            } catch (NoSuchElementException nse) {
                serviceResponse = Response.status(Response.Status.NO_CONTENT).entity("No content found").build();
                logger.debug("CountryResource - Pas de pays correspondant ");

            } catch (IllegalArgumentException iae) {
                serviceResponse = Response.status(Response.Status.NOT_ACCEPTABLE).entity("Invalid country code").build();
            }
        } else {
            serviceResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("CountryService not available").build();
        }
        return serviceResponse ;
    }

    @POST
    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Produces(MediaType.TEXT_HTML)
    public Response createCountry(@Valid CountryDto countryDto) {
        Response serviceResponse = null ;
        if (countryService!=null) {
            try {
                if (countryService.createCountry(countryDto)) {
                    serviceResponse = Response.status(Response.Status.CREATED).entity(countryDto.getLabel()+ " added").build();
                } else { 
                    serviceResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Une erreur est survenue lors du traitement").build() ;
                }
            } catch (InternalServerErrorException e) {
                e.printStackTrace();
                serviceResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Une erreur est survenue:"+ e.getCause() +" - "+ e.getMessage()).build();           
            }
        } else {
            /** Erreur d'injection spring */
            serviceResponse = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("CountryService not available").build();            
        }
        return serviceResponse ;
    }
}

The class configuring validation (Straight from exemples; comments are removed for shortness) :

package com.xxxxxx.crme.yyyyyyeforce.rest;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import javax.validation.ParameterNameProvider;
import javax.validation.Validation;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import org.glassfish.jersey.server.validation.ValidationConfig;
import org.glassfish.jersey.server.validation.internal.InjectingConstraintValidatorFactory;

/**Custom configuration of validation.*/
@Provider
public class ValidationConfigurationContextResolver implements ContextResolver<ValidationConfig> {

    @Context
    private ResourceContext resourceContext;    

    /**Get a context*/
    @Override
    public ValidationConfig getContext(Class<?> type) {
        final ValidationConfig config = new ValidationConfig();
        config.constraintValidatorFactory(resourceContext.getResource(InjectingConstraintValidatorFactory.class));
        config.parameterNameProvider(new CustomParameterNameProvider());
        return config;
    }

    private class CustomParameterNameProvider implements ParameterNameProvider {
        private final ParameterNameProvider nameProvider;
        public CustomParameterNameProvider() {
            nameProvider = Validation.byDefaultProvider().configure().getDefaultParameterNameProvider();
        }

        @Override
        public List<String> getParameterNames(final Constructor<?> constructor) {
            return nameProvider.getParameterNames(constructor);
        }

        @Override
        public List<String> getParameterNames(final Method method) {
            return nameProvider.getParameterNames(method);
        }
    }
}

Class registering REST configuration

 package com.xxxxxx.crme.yyyyyyyeforce.rest;
 import org.apache.log4j.Logger;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
 import com.xxxxxx.crme.yyyyyyyeforce.services.exceptions.ConstraintViolationExceptionMapper;
 import com.xxxxxx.crme.yyyyyyyeforce.services.exceptions.IllegalArgumentExceptionMapper;
 import com.xxxxxx.crme.yyyyyyyeforce.services.exceptions.NoSuchElementExceptionMapper;

/** */
public class EFacadeApplication extends ResourceConfig {

    /** Register JAX-RS application components. */
    public EFacadeApplication() {

        register(ValidationConfigurationContextResolver.class) ;
        register(RequestContextFilter.class);

        register(IllegalArgumentExceptionMapper.class);
        register(NoSuchElementExceptionMapper.class);
        register(ConstraintViolationExceptionMapper.class);

        register(CountryResource.class) ;
    }
}

The web.xml of the application :

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    version="2.5">
    <display-name>yyyyyy EForce</display-name>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:config/log4j.properties</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:config/applicationContext.xml</param-value>
    </context-param>
    <servlet>
        <servlet-name>jersey-config-serlvet</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>com.xxxxxx.crme.yyyyyyeforce.rest.YYYYYYApplication</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.xxxxxx.crme</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.beanValidation.enableOutputValidationErrorEntity.server</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jersey-config-serlvet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

And the spring configuration :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <bean id="illegalArgumentExceptionMapper" class="com.xxxxxx.crme.yyyyyyeforce.services.exceptions.IllegalArgumentExceptionMapper" />
    <bean id="noSuchElementExceptionMapper" class="com.xxxxxx.crme.yyyyyyeforce.services.exceptions.NoSuchElementExceptionMapper" />

    <context:component-scan base-package="com.xxxxxx.crme.*" />
    <bean id="poxDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" scope="singleton">
        <property name="jndiName" value="poxBackDS" />
        <property name="resourceRef" value="true" />        
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="poxDataSource" />
        <property name="annotatedClasses">
            <list>
                <value>com.xxxxxx.crme.yyyyyyeforce.models.Country</value>
            </list>
        </property> 
    </bean>

    <tx:annotation-driven />
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:errors/validationMessages.properties" />
    </bean>

    <bean id="countryService" class="com.xxxxxx.crme.yyyyyyeforce.services.impl.CountryServiceImpl" /> 
    <bean id="countryDao" class="com.xxxxxx.crme.yyyyyyeforce.dao.impl.CountryDaoImpl" /> 
</beans>

Specific built Jonas class excluded for the application (to use app. jars) :

<filter-name>org.apache.commons.digester.*</filter-name>
<filter-name>org.springframework.*</filter-name> 
<filter-name>org.hibernate.*</filter-name>
<filter-name>org.glassfish.*</filter-name>
<filter-name>javax.validation.*</filter-name>

Jonas services activated :

jonas.services    jtm,db,security,resource,ejb3,web,ear,depmonitor

In this configuration, the application compile not errors show up. When I try to deploy it on the server, I got the stack shown above. Can someone help me to find where I'am wrong... or what part of the implementation I missed.

Thanks

Thanks to thedoctor who point where to the pb: The server was using his own class and for giving me the way to check this.

Jonas class filtering file (classloader-default-filtering.xml) I was editing was not the one used by the server. For strange reasons, it was not using the classloader-default-filtering.xml in the current configuration folder, but in [JONAS_ROOT]/EFInstance/conf.

Adding javax.validation.* to this one solve (roughly) the issue. A second step will be to understand why it doesnot care about the right file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM