Announcement Announcement Module
No announcement yet.
java/validation/validation error Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • java/validation/validation error

    I am very new to both Java and the Spring framework so please forgive me if this is a newbie error and maybe this is the wrong forum to post this considering the components involved.

    I am trying to write a Spring framework based Google App Engine web site. I have some empty @annotation based controllers implemented but when i try to run the site on the GAE dev server, i get an error about a missing dependency for javax.validation. After Googling for this library, I've found that JSR 303 spec for validation is implemented by a hibernate-validation library. I've added this to my maven project POM file which gets bundled into the app, but it still doesn't work.

    Any ideas on what i'm doing wrong?

    The maven dependency is:


    The errors are:
    SEVERE: Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.validation.beanvalidation.Loc alValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
    at AutowireCapableBeanFactory.initializeBean(Abstract
    at AutowireCapableBeanFactory.doCreateBean(AbstractAu
    at AutowireCapableBeanFactory.createBean(AbstractAuto
    at BeanFactory$1.getObject( 93)
    at ingletonBeanRegistry.getSingleton(DefaultSingleton
    at BeanFactory.doGetBean( )
    at BeanFactory.getBean(
    at istableBeanFactory.preInstantiateSingletons(Defaul
    at ationContext.finishBeanFactoryInitialization(Abstr
    at ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext( 67)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext( 83)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext( )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(
    at it(
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.mortbay.jetty.servlet.ServletHolder.initServle t(
    at org.mortbay.jetty.servlet.ServletHolder.doStart(Se
    at org.mortbay.component.AbstractLifeCycle.start(Abst
    at org.mortbay.jetty.servlet.ServletHandler.initializ e(
    at org.mortbay.jetty.servlet.Context.startContext(Con
    at org.mortbay.jetty.webapp.WebAppContext.startContex t(
    at org.mortbay.jetty.handler.ContextHandler.doStart(C
    at org.mortbay.jetty.webapp.WebAppContext.doStart(Web
    at org.mortbay.component.AbstractLifeCycle.start(Abst
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(H
    at org.mortbay.component.AbstractLifeCycle.start(Abst
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(H
    at org.mortbay.jetty.Server.doStart(
    at org.mortbay.component.AbstractLifeCycle.start(Abst
    at nerService.startContainer(JettyContainerService.ja va:186)
    at tainerService.startup(AbstractContainerService.jav a:182)
    at rImpl.start(
    at rMain$StartAction.apply(
    at$ParseResult .applyArgs(
    at rMain.<init>(
    at rMain.main(
    Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader. java:631)
    at java.lang.ClassLoader.defineClass( :615)
    at .java:283)
    at$000(URLClassLoader. java:58)
    at$ 197)
    at Method)
    at ava:190)
    at java.lang.ClassLoader.loadClass( 06)
    at ClassLoader.loadClass( 176)
    at java.lang.ClassLoader.loadClass( 47)
    at org.springframework.validation.beanvalidation.Loca lValidatorFactoryBean.afterPropertiesSet(LocalVali
    at AutowireCapableBeanFactory$
    at Method)
    at AutowireCapableBeanFactory.invokeInitMethods(Abstr
    at AutowireCapableBeanFactory.initializeBean(Abstract
    ... 36 more

    The total list of jar dependencies within WEB-INF/lib are:

    -rw-rw-r-- 1 spaulger spaulger 4.4K Oct 29 11:56 aopalliance-1.0.jar
    -rw-rw-r-- 1 spaulger spaulger 19M Oct 28 21:21 appengine-api-1.0-sdk-1.5.5.jar
    -rw-rw-r-- 1 spaulger spaulger 60K Oct 28 21:21 commons-logging-1.1.1.jar
    -rw-rw-r-- 1 spaulger spaulger 132K Oct 28 21:21 com.springsource.javax.persistence-2.0.0.jar
    -rw-rw-r-- 1 spaulger spaulger 903K Oct 28 21:21 freemarker-2.3.18.jar
    -rw-rw-r-- 1 spaulger spaulger 358K Oct 28 21:21 hibernate-validator-4.2.0.Final.jar
    -rw-rw-r-- 1 spaulger spaulger 953K Oct 29 11:20 javaee-api-6.0-SNAPSHOT.jar
    -rw-rw-r-- 1 spaulger spaulger 25K Oct 28 21:21 slf4j-api-1.6.1.jar
    -rw-rw-r-- 1 spaulger spaulger 314K Oct 29 11:56 spring-aop-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 52K Oct 29 11:56 spring-asm-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 544K Oct 29 11:56 spring-beans-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 655K Oct 29 11:56 spring-context-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 100K Oct 29 11:56 spring-context-support-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 374K Oct 29 11:56 spring-core-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 166K Oct 29 11:56 spring-expression-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 389K Oct 29 11:56 spring-web-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 410K Oct 29 11:56 spring-webmvc-3.0.6.RELEASE.jar
    -rw-rw-r-- 1 spaulger spaulger 47K Oct 28 21:21 validation-api-1.0.0.GA.jar

  • #2
    classpath update

    After doing some more digging, i've copied the hibernate files and another jar, validation-api, to the JRE ext class path directory and tried again.

    This time, Google App engine is reporting this class is not provided by the environment at Google, which is correct and is refusing to permit loading of the library.

    However, if I am not using any @valid annotations, is there a way to disable the spring validation from ever loading this bean?

    Also, and this may be a more generic java question, if the validation-api jar is part of the war file in WEB-INF/lib, which is on the class path, how come it doesn't get picked up with all the other jars when loading as a package that provides the javax.validation namespace?


    • #3
      I have now removed the annotation based approach that used <mvc:annotation-driven /> in the servlet context file and manually specified each controller. This has resolve my problem.

      Seems like a bug to me, since the JSR spec should only be loaded if found on the class path and I am not using any @valid annotations requesting validation...