• Post Reply Bookmark Topic Watch Topic
  • New Topic

confusing exception  RSS feed

 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting the following exception and puzzled as to why:

C:\NCiper\src\tconn\NFConnectionPool.java:27: cannot resolve symbol
symbol : constructor GenericObjectPool (tconn.NFConnectionFactory)
location: class org.apache.commons.pool.impl.GenericObjectPool
gop = new GenericObjectPool(new NFConnectionFactory());
1 error
BUILD FAILED (total time: 0 seconds)

The signature of the constructor is:
GenericObjectPool(PoolableObjectFactory factory)

PoolableObjectFactory is an interface which is implemented by BasePoolableObjectFactory, and NFConnectionFactory extends BasePoolableObjectFactory.

Based on this structure NFConnection factory is a subclass of PoolableObjectFactory, so why am I getting this exception ?

(note: NFConnectionFactory is in a package called tconn, but this shouldn't make a difference ?)

thanks in advance,

jc
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on your description, everything sounds fine; therefore, you are forced to conclude that your description is wrong.

At least, that the description doesn't quite match the reality that the compiler is seeing. You might have some old class files that the compiler is seeing, previous versions that didn't quite fit the contract you're describing; finding and removing them could help. For example, you might have old class files from when these classes were defined in the default package, or some other package, and your class doesn't extend the class you think it does.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an aside, notice that you aren't getting an exception, but a compile time error, which are two very different things.
 
Adam Nace
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that the version of GenericObjectPool that is in your jar file is the same version of the class that you have been consulting the documentation for?

It is entirely possible that you have a version of that class in your jar file that does not contain that constructor because it was added later or removed earlier.

Do you perhaps have more than one version installed to your jre? Is it possible that the incorrect version is being loaded?

What IDE are you using for this project? Often, when I have problems with symbols that cannot be resolved, my IDE can help me identify why. If your IDE has a symbol completion function, or allows you to browse API's, you should be able to search for and locate that constructor. If you cannot, then it means that the constructor does not exist in a jar file that your IDE is aware of.

- Adam
 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks folks, after I provided the fully qualified class name, my problem was solved, there must have been another class in my path somewhere that had the same name.

thanks,
jc
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!