Issue 71 in peaberry: java.lang.IllegalAccessError when using LdapFilter

8 views
Skip to first unread message

peab...@googlecode.com

unread,
Jan 4, 2012, 4:06:03 AM1/4/12
to guice...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 71 by jerome.j...@gmail.com: java.lang.IllegalAccessError when
using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

The line

AttributeFilter ldap = Filters.ldap("(module=three)");

produce the following Stack trace

Exception in thread "main" java.lang.IllegalAccessError: tried to access
class org.osgi.framework.FrameworkUtil$FilterImpl from class
org.ops4j.peaberry.internal.FrameworkUtil
at
org.ops4j.peaberry.internal.FrameworkUtil.createFilter(FrameworkUtil.java:76)
at
org.ops4j.peaberry.util.ldap.LdapAttributeFilter.<init>(LdapAttributeFilter.java:39)
at org.ops4j.peaberry.util.Filters.ldap(Filters.java:43)
at Test.main(Test.java:11)

Using Peaberry 1.2


peab...@googlecode.com

unread,
Jul 27, 2012, 6:01:12 PM7/27/12
to guice...@googlegroups.com

Comment #1 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

I think the issue comes from the jarjar plugin configuration

peab...@googlecode.com

unread,
Jul 27, 2012, 6:03:43 PM7/27/12
to guice...@googlegroups.com

Comment #2 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

I would like to know why there are those specific rules:

<rule>
<pattern>org.osgi.framework.Filter</pattern>
<result>org.ops4j.peaberry.internal.Filter</result>
</rule>
<rule>
<pattern>org.osgi.framework.FrameworkUtil</pattern>
<result>org.ops4j.peaberry.internal.FrameworkUtil</result>
</rule>
<rule>
<pattern>org.osgi.framework.InvalidSyntaxException</pattern>

<result>org.ops4j.peaberry.internal.InvalidSyntaxException</result>
</rule>

peab...@googlecode.com

unread,
Jul 27, 2012, 8:18:34 PM7/27/12
to guice...@googlegroups.com

Comment #3 on issue 71 by mccu...@gmail.com: java.lang.IllegalAccessError
There was a feature request for the filter code to work outside of OSGi, so
we embed a filter implementation plus its API - since neither the API or
implementation are exposed outside of the bundle it is meant to be jarjar'd
so that it is truly independent whether running inside OSGi or part of a
classic Java classpath.

It looks like the jarjar repackaging is missing the filter subclass, which
would explain the exception.

peab...@googlecode.com

unread,
Jul 28, 2012, 7:49:59 AM7/28/12
to guice...@googlegroups.com

Comment #4 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

So clearly if you remove those rules everything work fine. Those rules are
here to make filter available outside maven environment?


peab...@googlecode.com

unread,
Jul 28, 2012, 7:54:59 AM7/28/12
to guice...@googlegroups.com

Comment #5 on issue 71 by mccu...@gmail.com: java.lang.IllegalAccessError
The main reason to jarjar the filter implementation is to avoid classpath
conflicts when running outside of OSGi, and to avoid exposing a dependency
on a full OSGi implementation when we really only require the LDAP filter.

peab...@googlecode.com

unread,
Jul 28, 2012, 7:55:59 AM7/28/12
to guice...@googlegroups.com

Comment #6 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

Yes the error comes from the missing inner class. Jarjar does not handle
the inner class or something like that with this configuration.
Are you sure that this configuration will be enough because if you have a
look to the Filter class it required the ServiceReference and then by
transitivity Bundle and ...

Romain

peab...@googlecode.com

unread,
Jul 28, 2012, 8:26:53 AM7/28/12
to guice...@googlegroups.com

Comment #7 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

I'm able to reproduce the issue with an integration test (pax exam) added
in the peaberry.activation.test project.
----
Tests in error:
testLdap(org.ops4j.peaberry.util.FiltersTest):
org/osgi/framework/FrameworkUtil$FilterImpl

Tests run: 11, Failures: 0, Errors: 1, Skipped: 0
----

Romain

peab...@googlecode.com

unread,
Jul 28, 2012, 8:31:44 AM7/28/12
to guice...@googlegroups.com

Comment #8 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

I have updated the pea

peab...@googlecode.com

unread,
Jul 28, 2012, 8:33:24 AM7/28/12
to guice...@googlegroups.com

Comment #9 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

I have updated the jarjar configuration as follow:
<rule>
<pattern>org.osgi.framework.FrameworkUtil*</pattern>
<result>org.ops4j.peaberry.internal.FrameworkUtil@1</result>
</rule>
By this way all the inner classes are moved but I still have the same
exception.

peab...@googlecode.com

unread,
Jul 28, 2012, 9:09:18 AM7/28/12
to guice...@googlegroups.com

Comment #10 on issue 71 by mccu...@gmail.com: java.lang.IllegalAccessError
I've added a basic test and a fix to the jarjar config - make sure you
rebuild from the top-level directory.

peab...@googlecode.com

unread,
Jul 29, 2012, 10:39:22 AM7/29/12
to guice...@googlegroups.com

Comment #11 on issue 71 by romain.g...@gmail.com:
java.lang.IllegalAccessError when using LdapFilter
http://code.google.com/p/peaberry/issues/detail?id=71

Ok everything works on my side I think the issue can be close.
May I suggest you something?
I think the new peaberry integration test project for this test in
particular should not depends on 'osgi.core'.
I have created a patch that reorganize this dependency.

Romain.

Attachments:
reorganize_osgi_core_dependency.patch 26.7 KB

peab...@googlecode.com

unread,
Jul 29, 2012, 11:15:06 AM7/29/12
to guice...@googlegroups.com
Updates:
Status: Fixed

Comment #12 on issue 71 by mccu...@gmail.com: java.lang.IllegalAccessError
peaberry.tests/pom.xml currently excludes compile/system/provided scope
dependencies in the surefire configuration, to make sure inherited compile
dependencies don't accidentally leak onto the test classpath:


http://maven.apache.org/plugins/maven-surefire-plugin/examples/configuring-classpath.html#Removing_Dependency_Classpath_Elements

But yes, probably worth cleaning up the parent dependencies to avoid such a
leak in the first place.

Reply all
Reply to author
Forward
0 new messages