File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BeanCreationException and NoClassDefFoundError : What am I missing in here?

 
Raj Shharma
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • 0
  • Mark post as helpful
  • send pies
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic