• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble interpreting the error from the console  RSS feed

 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run a sample application that uses dom4j and log4j and am getting the following error:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'datasource' defined in class path resource [application.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [application.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [application.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.virtualpairprogrammers.client.SimpleClientTest.main(SimpleClientTest.java:21)

Can anyone please give me hints on where to start digging? Thanks!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me that


says you should start digging for the org.dom4j.DocumentException library - it does not appear to be on the classpath used by your application.

Bill
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill and thank you. I checked my ide's referenced libraries and dom4j.jar is in there. Am I missing more? Thanks, Dan.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you clarify what "in there" means in that statement?

Also, what jar are all of those org.springframework classes in? Is that jar in your application's classpath, or is it somewhere else?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just because your IDE knows about the library does not automatically make your application know about the library when executing outside the IDE.

(digression)See - thats what I hate about IDEs - they do all this stuff behind your back.... (/digression)

Bill
 
Paul Witten
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:says you should start digging for the org.dom4j.DocumentException library - it does not appear to be on the classpath used by your application.

I'd lay a ten-spot on that call. NoClassDefFound don't lie.
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, All Spring framework collections are in the spring.jar jar which is referenced and 'on the build path'.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that it's not enough to have the libraries on the classpath only when you build the application; they also have to be on the classpath when you run the application.
 
Paul Witten
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Note that it's not enough to have the libraries on the classpath only when you build the application; they also have to be on the classpath when you run the application.

Aya, when you run.

As a console app you clearly need to add all libraries to both the build and run time classpaths. And if you add a library only for build time it will definitely build. It won't run though, and the NoClassDef is the expected result.

Obviously even in an IDE you can't build without the library being there and doing your import statements, etc. But at runtime the library can be placed in the classpath automatically and transparently by some IDEs. I am using Netbeans now and although I have not made too much effort to research it I cannot find any explicit runtime classpath. I can't fiddle with it (that I can see so far). Phooey on that. I thought Eclipse used to require you to add jars to the runtime classpath. More work but at least you know what the hell you're working with.

The OP should try adding the library.jar in his runtime options under classpath (however he is running it) and his problem is solved.

OP, NoClassDef errors are actually quite helpful. They name the class and they aren't lying or mistaken. Never assume that because you could compile successfully that it will find all resources at runtime.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!