File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes jar files in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "jar files in Eclipse" Watch "jar files in Eclipse" New topic

jar files in Eclipse

Mayank Kalbhor

Joined: Feb 26, 2011
Posts: 17
Hi all,

I have a question for you all. In eclipse we have to add jars for many applications like struts,spring, jdbc etc

I am confused whether we have to add binary jars or source jars.

Like here we have

both source and binary not sure which one to add to the build path of the eclipse can you guys help out?

Thank you

Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

Always add the binary JAR files. The class files are needed and these are usually not available in the source JAR files.

How To Ask Questions How To Answer Questions
Mayank Kalbhor

Joined: Feb 26, 2011
Posts: 17
Thank you for the reply....Actually

I am doing this project where i am using spring with JDBC. I have imported most of the jars from common logging, commons-pool, dbcp also but its still giving me this error:

Apr 11, 2011 1:48:33 PM ationContext prepareRefresh
INFO: Refreshing plicationContext@133f1d7: startup date [Mon Apr 11 13:48:33 IST 2011]; root of context hierarchy
Apr 11, 2011 1:48:33 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [personconfig.xml]
Apr 11, 2011 1:48:33 PM istableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in istableBeanFactory@15212bc: defining beans [dataSource,jdbcTemplate,personDAO]; root of factory hierarchy
Apr 11, 2011 1:48:33 PM ingletonBeanRegistry destroySingletons
INFO: Destroying singletons in istableBeanFactory@15212bc: defining beans [dataSource,jdbcTemplate,personDAO]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in class path resource [personconfig.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
at AutowireCapableBeanFactory.instantiateBean(Abstrac
at AutowireCapableBeanFactory.createBeanInstance(Abst
at AutowireCapableBeanFactory.doCreateBean(AbstractAu
at AutowireCapableBeanFactory.createBean(AbstractAuto
at BeanFactory$1.getObject( 95)
at ingletonBeanRegistry.getSingleton(DefaultSingleton
at BeanFactory.doGetBean( )
at BeanFactory.getBean(
at istableBeanFactory.preInstantiateSingletons(Defaul
at ationContext.finishBeanFactoryInitialization(Abstr
at ationContext.refresh(AbstractApplicationContext.ja va:455)
at plicationContext.<init>(ClassPathXmlApplicationCon
at plicationContext.<init>(ClassPathXmlApplicationCon
at com.springtry.MyMainClass.main(
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at stantiationStrategy.instantiate(SimpleInstantiatio
at AutowireCapableBeanFactory.instantiateBean(Abstrac
... 13 more

what is this error can any body help here?

I am on java 1.6 and the other related jars for JDBC that are there are :


Please let me know if you need additional details

Thank you in advance.

Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

It looks like you have the source JAR files instead of the binary JAR files. That's not going to work, because the source JAR files do not have the class files (and if they do, it's in the wrong place inside the JAR file).
I agree. Here's the link:
subject: jar files in Eclipse
It's not a secret anymore!