Linux 中抛出 IllegalAccessError ( suse 10)
在此处输入代码
我们使用 c3p0 jar 进行数据库池。现在从c3p0代码中,出现以下异常
原因:java.lang.IllegalAccessError:尝试从类com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource访问类com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource$1 在 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.setUpPropertyEvents(AbstractPoolBackedDataSource.java:74) 在 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource。(AbstractPoolBackedDataSource.java:63) 在 com.mchange.v2.c3p0.ComboPooledDataSource。(ComboPooledDataSource.java:109) 在 com.mchange.v2.c3p0.ComboPooledDataSource.(ComboPooledDataSource.java:105)
现在位于 AbstractPoolBackedDataSource.java(第 74 行) PropertyChangeListener l = new PropertyChangeListener()
PropertyChangeListener l = new PropertyChangeListener()
{
public void propertyChange( PropertyChangeEvent evt )
{ resetPoolManager(); }
};
所以,PropertyChangeListener是这里的内部类.. AbstractPoolBackedDataSource$1 PropertyChangeListener是一个java类java.beans.PropertyChangeListener!
可能是什么原因?这仅发生在 linux(suse 10) 中。在 Windows 中它工作正常(jdk 1.6_10 和 jre 1.6_20)。我尝试过不同的 jdk、jre 组合( jdk 1.6_25 等)
enter code here
we 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 )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经通过一些尝试和错误解决了这个问题。
我还发现,这并不像我之前怀疑的那样可靠。这很容易重现,看起来像是一个潜在的类加载错误。(尽管我不确定它是在 Equinox 实现中还是在 Java 中!!)。
在解释解决方案之前,让我更详细地描述一下场景。
我们将代码部署在 osgi(equinox) 框架中。有两个包使用 c3p0 jar 进行数据库池,其中之一导出 c3p0 包。该捆绑包先于另一个捆绑包开始。
现在,根据 osgi 规范,osgi 类加载器应该为单独的包维护单独的类加载器实例。现在,当第二个包尝试从 c3p0 jar 加载类时,它的类加载器可能会发现(从父委托)这些类已经加载了!但它们是从不同的上下文加载的,这导致了访问冲突。
这是初步发现,我将尝试使用 Eclipse 代码进行调试,并可能会深入研究它。更改捆绑包启动顺序后,此问题得到解决。
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.