Sanmoy
Sanmoy

Reputation: 612

IllegalAccessError throwing in linux ( suse 10)

enter code herewe are using c3p0 jar for databse pooling. Now from c3p0 code, the following exception is comming

Caused by: java.lang.IllegalAccessError: tried to access class com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource$1 from class com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.setUpPropertyEvents(AbstractPoolBackedDataSource.java:74) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.(AbstractPoolBackedDataSource.java:63) at com.mchange.v2.c3p0.ComboPooledDataSource.(ComboPooledDataSource.java:109) at com.mchange.v2.c3p0.ComboPooledDataSource.(ComboPooledDataSource.java:105)

Now in AbstractPoolBackedDataSource.java (line 74) PropertyChangeListener l = new PropertyChangeListener()

PropertyChangeListener l = new PropertyChangeListener()
{
public void propertyChange( PropertyChangeEvent evt )
{ resetPoolManager(); }
};

So, PropertyChangeListener is the inner class here .. AbstractPoolBackedDataSource$1 PropertyChangeListener is a java class java.beans.PropertyChangeListener !!

What can be the reason ? This is only happening in linux(suse 10). In Windows it is working fine(jdk 1.6_10 and jre 1.6_20). I have tried with different jdk,jre combinations ( jdk 1.6_25 etc )

Upvotes: 1

Views: 146

Answers (1)

Sanmoy
Sanmoy

Reputation: 612

I have resolved the problem using some trial and error.

Also I found, this is not os dependable as I have suspected earlier. This is easily reproducible and looks like an potential class loading bug.( though I am not sure whether it is in equinox implementation or in java !!).

Before explaining the solution, let me describe the scenario more elaborately.

We have our code deployed in a osgi(equinox) framework. There are two bundles which uses the c3p0 jar for database pooling and one of them exports the c3p0 packages. This bundle starts before the other one.

Now, according to osgi specification, osgi class loader should maintain separate class loader instances for separate bundles. Now when the second bundle tries to load classes from the c3p0 jar, its class-loader may find (from parent delegation) that the classes are already loaded !! But they are loaded from different context, which is causing the access violation.

This is initial findings, I will try to debug with the eclipse code and may be dig more into it. After changing the bundle start order, this is resolved.

Upvotes: 1

Related Questions