Announcement Announcement Module
Collapse
No announcement yet.
java/validation/validation error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.2.0.Final</version>
    </dependency>


    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 org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 93)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:290 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:192)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 67)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 83)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:358 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:325)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.mortbay.jetty.servlet.ServletHolder.initServle t(ServletHolder.java:440)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(Se rvletHolder.java:263)
    at org.mortbay.component.AbstractLifeCycle.start(Abst ractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initializ e(ServletHandler.java:685)
    at org.mortbay.jetty.servlet.Context.startContext(Con text.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContex t(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(C ontextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(Web AppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(Abst ractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(H andlerWrapper.java:130)
    at org.mortbay.component.AbstractLifeCycle.start(Abst ractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(H andlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(Abst ractLifeCycle.java:50)
    at com.google.appengine.tools.development.JettyContai nerService.startContainer(JettyContainerService.ja va:186)
    at com.google.appengine.tools.development.AbstractCon tainerService.startup(AbstractContainerService.jav a:182)
    at com.google.appengine.tools.development.DevAppServe rImpl.start(DevAppServerImpl.java:172)
    at com.google.appengine.tools.development.DevAppServe rMain$StartAction.apply(DevAppServerMain.java:164)
    at com.google.appengine.tools.util.Parser$ParseResult .applyArgs(Parser.java:48)
    at com.google.appengine.tools.development.DevAppServe rMain.<init>(DevAppServerMain.java:113)
    at com.google.appengine.tools.development.DevAppServe rMain.main(DevAppServerMain.java:89)
    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(ClassLoader.java :615)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader .java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader. java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at com.google.appengine.tools.development.IsolatedApp ClassLoader.loadClass(IsolatedAppClassLoader.java: 176)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
    at org.springframework.validation.beanvalidation.Loca lValidatorFactoryBean.afterPropertiesSet(LocalVali datorFactoryBean.java:183)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$5.run(AbstractAutowireC apableBeanFactory.java:1467)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1465)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1417)
    ... 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?

    Comment


    • #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...

      Comment

      Working...
      X