Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
bean validator issue in jdk 6 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • bean validator issue in jdk 6

    Hi to all,

    I'm using spring-modules-validation (0.7) BeanValidator with annotations
    and I have a strange problem. If I deploy my web application to Tomcat
    running with jdk 5 everything goes well, but if I switch to jdk 6 I get
    a java.lang.NoClassDefFoundError.

    This is my configuration:
    * linux;
    * jdk 6;
    * tomcat 5.5.20;
    * spring 2.0.2;
    * springmodules 0.7;
    * maven 2.0.5 (I use the ibiblio springmodules jar);

    This is a snippet of the configuration file of my web app:

    <!-- This is the annotation validator -->
    	<bean id="validator" 
    		<property name="configurationLoader" ref="configurationLoader"/>
    	<bean id="configurationLoader" 
    <!-- Abstract Controller -->
         <bean id="abstractController" abstract="true">
             <property name="conf">
                 <ref bean="conf"/>
             <property name="validators">
                 <ref bean="validator"/>
             <lookup-method name="dao" bean="daos"/>
             <lookup-method name="blo" bean="blos"/>
    and this is the exception:

    Instantiation of bean failed; nested exception is 
    org.springframework.beans.BeanInstantiationException: Could not 
    instantiate bean class 
    [org.springmodules.validation.bean.BeanValidator]: Constructor threw 
    exception; nested exception is java.lang.NoClassDefFoundError: Could not 
    initialize class org.springmodules.validation.util.LibraryUtils
    I found the same problem if I use winxp: jdk5 works and jdk6 fails.

    Anyone having the same issue?

    Thanks in advance


    PS.: excuse me for crossposting from [email protected] ...

  • #2
    I solved the problem upgrading to commons-lang-2.3.
    The validation framework declares a dependency to commons-lang-2.1 which hasn't got SystemUtils.IS_JAVA_1_6.

    Before loading AnnotationValidator, the ValidatorNamespaceHandler checks if the vm has annotations enabled, using LibraryUtils.JDK_ANNOTATIONS_SUPPORTED, which is:
    SystemUtils.IS_JAVA_1_5 || SystemUtils.IS_JAVA_1_6;

    In java 5 the first part of the boolean expression returns true and the second isn't evaluated ---> No problems

    In java 6 the first part returns false so the second is evaluated ---> using commons-lang-2.3 solves the problem

    By the way, this is a very nice framework, it solves a lot of problems for me: I don't like very much validating against an xml



    • #3

      SystemUtils class is present in the common lang jar -