This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar files in Eclipse

 
Mayank Kalbhor
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always add the binary JAR files. The class files are needed and these are usually not available in the source JAR files.
 
Mayank Kalbhor
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic