• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BeanCreationException and NoClassDefFoundError : What am I missing in here?

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this FileUploadController which I am trying to run but am getting BeanCreationException and NoClassDefFoundError for FileUploadController.class. I have this class in classpath but still am getting this error, any suggestions, I have web.xml file, servlet-config.xml, exception and classpath information for this question here.

Also please refer to BeanCreationException

FileUploadController.java



Web.xml


spring-context.xml


exception



classpath


Any suggestions would be highly appreciated?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That classpath, is that for the environment that you are running/deploying too, or just the classpath for your IDE for editing your code.

That error is always that the class is not in the classpath.

Mark
 
Raj Shharma
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That classpath, is that for the environment that you are running/deploying too, or just the classpath for your IDE for editing your code.



Its for the environment that am running/deploying too and so I believe it should work.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK I noticed one error in your config stuff. In your web.xml you have

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- Added for File Upload -->
<!-- <init-param> -->
<!-- <param-name>contextConfigLocation</param-name> -->
<!-- <param-value> -->
<!-- /WEB-INF/spring-servlet.xml -->
<!-- </param-value> -->
<!-- </init-param> -->
<!-- Added for FileUpload -->
<load-on-startup>1</load-on-startup>
</servlet>

With the init-param commented out, then the DispatcherServlet is going to look for a file called spring-servlet.xml as its configuration file, in the WEB-INF directory. But your config file name is spring-context.xml, so your config file isn't loading.

Mark
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "tell" on this is where it say "NoClassDefFoundError: Could not initialize class". This doesn't mean that the class doesn't exist...it means that when the classloader is loading the class it runs into trouble.

I can't tell for sure here...not enough info (despite the fact you posted plenty of code, I don't believe the real problem is in any of the stuff you posted). But I'd start looking at your controller and follow all of the types it depends on looking for static types or blocks. Something is going awry *when the class is loading*, which hints to me that it very well could be a problem in some static initializer. Just a guess though...
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic