wood burning stoves 2.0*
The moose likes JDBC and the fly likes jar files in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jar files in Eclipse" Watch "jar files in Eclipse" New topic
Author

jar files in Eclipse

Mayank Kalbhor
Greenhorn

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

http://commons.apache.org/dbcp/download_dbcp.cgi

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

Thank you

Mike
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Mayank Kalbhor
Greenhorn

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 org.springframework.context.support.AbstractApplic ationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlAp 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 org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@15212bc: defining beans [dataSource,jdbcTemplate,personDAO]; root of factory hierarchy
Apr 11, 2011 1:48:33 PM org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultL 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 org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:965)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:911)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:485)
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 95)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:292 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:900)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:455)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
at com.springtry.MyMainClass.main(MyMainClass.java:9)
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 org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:65)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:958)
... 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 :

mysql-connector-java-3.1.6-bin.jar
com.springsource.org.apache.commons.dbcp-sources-1.2.2.osgi.jar
com.springsource.org.apache.commons.pool-sources-1.5.3.jar
commons-dbcp.jar


Please let me know if you need additional details


Thank you in advance.

Mike
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

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).
 
Consider Paul's rocket mass heater.
 
subject: jar files in Eclipse