You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lécharny <el...@gmail.com> on 2018/12/12 11:08:10 UTC
Re: Exception Running ApacheDS embedded
Hi Shawn,
if you include ApacheDS, it will implicitely include LDAP API, so
including ldap-api-all will be a duplicate, AFAIR.
The thing is that we store the schema elements in LDIF format, and here,
it's found twice, which is problematic.
I'll have a closer look later today. What command are you executing
that I can run to get the same result ?
On 11/12/2018 17:50, Shawn McKinney wrote:
> Hello,
>
> I’m interested in running ApacheDS as an embedded process within Apache Fortress Rest component, which deploys as a .war file inside Apache Tomcat (and other servlet containers).
>
> The idea here is to provide a stand-alone capability for users to test, develop with. Later, when they move to production, it would instead point to an external directory, replicated, backed up, etc.
>
> So, my first step is to run this junit test suite inside fortress core:
>
> https://github.com/apache/directory-fortress-core/blob/master/src/test/java/org/apache/directory/fortress/core/impl/apacheds/FortressJUnitApachedsTest.java
>
> Which uses this to initialize the embedded server:
>
>
> @RunWith(FrameworkRunner.class)
> @CreateDS(name = "classDS", partitions =
> { @CreatePartition(name = "example", suffix = "dc=example,dc=com") })
> @CreateLdapServer(
> transports =
> {
> @CreateTransport(protocol = "LDAP", port = 10389)
> })
> @ApplyLdifFiles(
> { "fortress-schema.ldif", "init-ldap.ldif"/*, "test-data.ldif"*/})
>
> The LDIF files referenced here exist here:
> https://github.com/apache/directory-fortress-core/tree/master/src/test/resources
>
> When I execute the test case, this exception below.
>
> Any clues on what could be going wrong?
>
> *** Here are the versions:
> <version.apacheds>2.0.0.AM25</version.apacheds>
> <version.api.all>1.0.2</version.api.all>
>
> *** The Exception:
> 2018-12-04 07:40:046 INFO CacheService:131 - no custom cache configuration was set, loading the default cache configuration
> 2018-12-04 07:40:046 INFO DefaultSchemaLdifExtractor:110 - Schema directory '/tmp/server-work-classDS/partitions/schema' does NOT exist: extracted state set to false.
>
> org.apache.directory.api.ldap.schema.extractor.UniqueResourceException: Problem locating LDIF file in schema repository
> Multiple copies of resource named 'schema/ou=schema/cn=apachedns/ou=objectclasses/m-oid=1.3.6.1.4.1.18060.0.4.2.3.9.ldif' located on classpath at urls
> jar:file:/home/smckinn/.m2/repository/org/apache/directory/api/api-all/1.0.2/api-all-1.0.2.jar!/schema/ou%3dschema/cn%3dapachedns/ou%3dobjectclasses/m-oid%3d1.3.6.1.4.1.18060.0.4.2.3.9.ldif
> jar:file:/home/smckinn/.m2/repository/org/apache/directory/api/api-ldap-schema-data/2.0.0.AM1/api-ldap-schema-data-2.0.0.AM1.jar!/schema/ou%3dschema/cn%3dapachedns/ou%3dobjectclasses/m-oid%3d1.3.6.1.4.1.18060.0.4.2.3.9.ldif
> at org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.getUniqueResource(DefaultSchemaLdifExtractor.java:366)
> at org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.getUniqueResourceAsStream(DefaultSchemaLdifExtractor.java:343)
> at org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.extractFromClassLoader(DefaultSchemaLdifExtractor.java:381)
> at org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.extractOrCopy(DefaultSchemaLdifExtractor.java:169)
> at org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.extractOrCopy(DefaultSchemaLdifExtractor.java:190)
> at org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory.initSchema(DefaultDirectoryServiceFactory.java:172)
> at org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory.build(DefaultDirectoryServiceFactory.java:256)
> at org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory.init(DefaultDirectoryServiceFactory.java:125)
> at org.apache.directory.server.core.factory.DSAnnotationProcessor.createDS(DSAnnotationProcessor.java:100)
> at org.apache.directory.server.core.factory.DSAnnotationProcessor.getDirectoryService(DSAnnotationProcessor.java:333)
> at org.apache.directory.server.core.integ.FrameworkRunner.run(FrameworkRunner.java:112)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
> at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
>
> 2018-12-04 07:40:046 ERROR FrameworkRunner:196 - ERR_181 Failed to run the class org.apache.directory.fortress.core.impl.apacheds.FortressJUnitApachedsTest
> 2018-12-04 07:40:046 ERROR FrameworkRunner:197 - Problem locating LDIF file in schema repository
> Multiple copies of resource
>
> Shawn
>
>
>
>
>
Re: Exception Running ApacheDS embedded
Posted by Shawn McKinney <sm...@apache.org>.
> On Dec 19, 2018, at 9:39 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
>
> sorry for the delayed response.
>
> For some reason, ldap-api-all is being loaded while it should not. I have tried to get rid of it, but it's also present in many dependencies (as a third party), so it's quite painful.
>
> One solution would be to exclude the api-ldap-schema-data from all the dependencies that use it. It's pretty hard to do it by hand (you'll have to check every single dependency), but thanks to Eclipse maven integration, you can have it done automatically :
Hey Emmanuel. No worries.
I tried the exclusion, but didn’t get all of the dependencies, and gave up. Went with Lucas’ workaround.
>
> On Dec 19, 2018, at 9:39 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
>
> Note:when I run the test, I have a failure, but that might be due to some other reasons (like I'm using a more recent version of the API). Here is the trace I get :
>
> java.lang.InstantiationError: org.apache.directory.api.ldap.model.entry.Value
> at org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition.initInstance(AbstractBTreePartition.java:268)
Exactly where I’m stuck, using the API version:
<version.api.all>1.0.2</version.api.all>
Thanks,
—Shawn
Re: Exception Running ApacheDS embedded
Posted by Emmanuel Lécharny <el...@gmail.com>.
Hi Shawn,
sorry for the delayed response.
For some reason, ldap-api-all is being loaded while it should not. I
have tried to get rid of it, but it's also present in many dependencies
(as a third party), so it's quite painful.
One solution would be to exclude the api-ldap-schema-data from all the
dependencies that use it. It's pretty hard to do it by hand (you'll have
to check every single dependency), but thanks to Eclipse maven
integration, you can have it done automatically :
- select your project in the Project Explorer
- go to 'Maven Dependencies', and open it
- select the api-ldap-schema-data dependency
- right click, select the Maven entry in the menu
- select 'Exclude Maven Artifact'
and you are good to go !
FTR, here is the modified pom.xml diff attached
Note:when I run the test, I have a failure, but that might be due to
some other reasons (like I'm using a more recent version of the API).
Here is the trace I get :
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in
[jar:file:/Users/elecharny/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/Users/elecharny/.m2/repository/org/slf4j/slf4j-nop/1.7.5/slf4j-nop-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
log4j: reset attribute= "false".
log4j: Threshold ="null".
log4j: Desired logger sub-class: [org.apache.log4j.Logger]
log4j: Setting [org.apache.directory.fortress.core] additivity to [false].
log4j: Level value for org.apache.directory.fortress.core is [INFO].
log4j: Desired Level sub-class: [org.apache.log4j.Level]
log4j: org.apache.directory.fortress.core level set to INFO
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:sss}
%-5p %c{1}:%L - %m%n].
log4j: Adding appender named [console] to category
[org.apache.directory.fortress.core].
log4j: Level value for root is [INFO].
log4j: Desired Level sub-class: [org.apache.log4j.Level]
log4j: root level set to INFO
log4j: Adding appender named [console] to category [root].
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2018-12-19 16:33:011 INFO DefaultLdapCodecService:113 - Registered
pre-bundled control factory: 1.3.6.1.4.1.18060.0.0.1
2018-12-19 16:33:011 INFO DefaultLdapCodecService:117 - Registered
pre-bundled control factory: 2.16.840.1.113730.3.4.7
2018-12-19 16:33:011 INFO DefaultLdapCodecService:121 - Registered
pre-bundled control factory: 2.16.840.1.113730.3.4.2
2018-12-19 16:33:011 INFO DefaultLdapCodecService:125 - Registered
pre-bundled control factory: 2.16.840.1.113730.3.4.18
2018-12-19 16:33:011 INFO DefaultLdapCodecService:129 - Registered
pre-bundled control factory: 1.2.840.113556.1.4.319
2018-12-19 16:33:011 INFO DefaultLdapCodecService:133 - Registered
pre-bundled control factory: 2.16.840.1.113730.3.4.3
2018-12-19 16:33:011 INFO DefaultLdapCodecService:137 - Registered
pre-bundled control factory: 1.3.6.1.4.1.4203.1.10.1
2018-12-19 16:33:011 INFO DefaultLdapCodecService:141 - Registered
pre-bundled control factory: 1.2.840.113556.1.4.473
2018-12-19 16:33:011 INFO DefaultLdapCodecService:145 - Registered
pre-bundled control factory: 1.2.840.113556.1.4.474
2018-12-19 16:33:011 INFO CodecFactoryUtil:105 - Registered pre-bundled
control factory: 1.3.6.1.4.1.18060.0.0.1
2018-12-19 16:33:011 INFO CodecFactoryUtil:109 - Registered pre-bundled
control factory: 2.16.840.1.113730.3.4.7
2018-12-19 16:33:011 INFO CodecFactoryUtil:113 - Registered pre-bundled
control factory: 2.16.840.1.113730.3.4.2
2018-12-19 16:33:011 INFO CodecFactoryUtil:117 - Registered pre-bundled
control factory: 2.16.840.1.113730.3.4.18
2018-12-19 16:33:011 INFO CodecFactoryUtil:121 - Registered pre-bundled
control factory: 1.2.840.113556.1.4.319
2018-12-19 16:33:011 INFO CodecFactoryUtil:125 - Registered pre-bundled
control factory: 2.16.840.1.113730.3.4.3
2018-12-19 16:33:011 INFO CodecFactoryUtil:129 - Registered pre-bundled
control factory: 1.3.6.1.4.1.4203.1.10.1
2018-12-19 16:33:011 INFO CodecFactoryUtil:133 - Registered pre-bundled
control factory: 1.3.6.1.4.1.42.2.27.8.5.1
2018-12-19 16:33:011 INFO CodecFactoryUtil:138 - Registered pre-bundled
control factory: 2.16.840.1.113730.3.4.9
2018-12-19 16:33:011 INFO CodecFactoryUtil:143 - Registered pre-bundled
control factory: 2.16.840.1.113730.3.4.10
2018-12-19 16:33:011 INFO CodecFactoryUtil:147 - Registered pre-bundled
control factory: 1.3.6.1.4.1.4203.1.9.1.3
2018-12-19 16:33:011 INFO CodecFactoryUtil:151 - Registered pre-bundled
control factory: 1.3.6.1.4.1.4203.1.9.1.4
2018-12-19 16:33:011 INFO CodecFactoryUtil:155 - Registered pre-bundled
control factory: 1.3.6.1.4.1.4203.1.9.1.1
2018-12-19 16:33:011 INFO CodecFactoryUtil:159 - Registered pre-bundled
control factory: 1.3.6.1.4.1.4203.1.9.1.2
2018-12-19 16:33:011 INFO CodecFactoryUtil:163 - Registered pre-bundled
control factory: 1.2.840.113556.1.4.473
2018-12-19 16:33:011 INFO CodecFactoryUtil:167 - Registered pre-bundled
control factory: 1.2.840.113556.1.4.474
2018-12-19 16:33:011 INFO CodecFactoryUtil:171 - Registered pre-bundled
control factory: 1.2.840.113556.1.4.841
2018-12-19 16:33:011 INFO CodecFactoryUtil:175 - Registered pre-bundled
control factory: 1.2.840.113556.1.4.417
2018-12-19 16:33:011 INFO CodecFactoryUtil:179 - Registered pre-bundled
control factory: 1.2.840.113556.1.4.1413
2018-12-19 16:33:011 INFO CodecFactoryUtil:183 - Registered pre-bundled
control factory: 1.2.840.113556.1.4.528
2018-12-19 16:33:011 INFO CodecFactoryUtil:208 - Registered pre-bundled
extended operation factory: 1.3.6.1.1.8
2018-12-19 16:33:011 INFO CodecFactoryUtil:212 - Registered pre-bundled
extended operation factory: 1.3.6.1.4.1.18060.0.1.8
2018-12-19 16:33:011 INFO CodecFactoryUtil:216 - Registered pre-bundled
extended operation factory: 1.3.6.1.4.1.18060.0.1.3
2018-12-19 16:33:011 INFO CodecFactoryUtil:220 - Registered pre-bundled
extended operation factory: 1.3.6.1.4.1.18060.0.1.6
2018-12-19 16:33:011 INFO CodecFactoryUtil:224 - Registered pre-bundled
extended operation factory: 1.3.6.1.4.1.18060.0.1.5
2018-12-19 16:33:011 INFO CodecFactoryUtil:228 - Registered pre-bundled
extended operation factory: 1.3.6.1.4.1.4203.1.11.1
2018-12-19 16:33:011 INFO CodecFactoryUtil:232 - Registered pre-bundled
extended operation factory: 1.3.6.1.4.1.4203.1.11.3
2018-12-19 16:33:011 INFO CodecFactoryUtil:236 - Registered pre-bundled
extended operation factory: 1.3.6.1.4.1.1466.20037
2018-12-19 16:33:011 INFO CacheService:131 - no custom cache
configuration was set, loading the default cache configuration
2018-12-19 16:33:011 INFO DefaultSchemaLdifExtractor:110 - Schema
directory
'/var/folders/kz/kzvhcwd904b5ww36551nmvtm0000gn/T/server-work-classDS/partitions/schema'
does NOT exist: extracted state set to false.
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading system
enabled schema:
Schema Name: system
Disabled: false
Owner: uid=admin,ou=system
Dependencies: []
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading core
enabled schema:
Schema Name: core
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading apache
enabled schema:
Schema Name: apache
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading apachemeta
enabled schema:
Schema Name: apachemeta
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading other
enabled schema:
Schema Name: other
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, system, apache, apachemeta]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading cosine
enabled schema:
Schema Name: cosine
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading
inetorgperson enabled schema:
Schema Name: inetorgperson
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, system, cosine]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - apachemeta schema
has already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading krb5kdc
enabled schema:
Schema Name: krb5kdc
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - apache schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading java
enabled schema:
Schema Name: java
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading pwdpolicy
enabled schema:
Schema Name: pwdpolicy
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - cosine schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading collective
enabled schema:
Schema Name: collective
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - core schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - apache schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:1303 - system schema has
already been loaded
2018-12-19 16:33:012 INFO DefaultSchemaManager:783 - Loading adsconfig
enabled schema:
Schema Name: adsconfig
Disabled: false
Owner: uid=admin,ou=system
Dependencies: [core, apache, system]
SchemaLoader : LdifSchemaLoader
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
2018-12-19 16:33:012 INFO LdifReader:1637 - No version information :
assuming version: 1
java.lang.InstantiationError:
org.apache.directory.api.ldap.model.entry.Value
at
org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition.initInstance(AbstractBTreePartition.java:268)
at
org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition.<init>(AbstractBTreePartition.java:242)
at
org.apache.directory.server.core.partition.impl.avl.AvlPartition.<init>(AvlPartition.java:77)
at
org.apache.directory.server.core.partition.ldif.AbstractLdifPartition.<init>(AbstractLdifPartition.java:68)
at
org.apache.directory.server.core.partition.ldif.LdifPartition.<init>(LdifPartition.java:139)
at
org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory.initSchema(DefaultDirectoryServiceFactory.java:201)
at
org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory.build(DefaultDirectoryServiceFactory.java:256)
at
org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory.init(DefaultDirectoryServiceFactory.java:125)
at
org.apache.directory.server.core.factory.DSAnnotationProcessor.createDS(DSAnnotationProcessor.java:100)
at
org.apache.directory.server.core.factory.DSAnnotationProcessor.getDirectoryService(DSAnnotationProcessor.java:333)
at
org.apache.directory.server.core.integ.FrameworkRunner.run(FrameworkRunner.java:112)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Re: Exception Running ApacheDS embedded
Posted by Shawn McKinney <sm...@apache.org>.
Nicely done Lucas! I changed it a bit. AOP dependency is test scope. I’m also keeping its resources under test as well.
Now past the duplicate schema problem. Yes, it’s a workaround, but fairly easy to get going. Thanks for taking the time to put this together.
--Shawn
> On Dec 18, 2018, at 4:59 PM, Lucas Theisen <lu...@pastdev.com> wrote:
>
> Hi Shawn,
>
> Sorry for the delay, took me a bit to extract out a working example. I published it here: https://github.com/lucastheisen/apacheds-test
>
> The README has the details (_i am pretty sure_) that are needed for your project. However, even if i missed something in the README, the project itself is a fully working example that demonstrates how i test my password policy. It should not be all that difficult to adapt to your use case. Hope it helps!
>
> Lucas
>
> On Fri, Dec 14, 2018 at 11:38 AM Shawn McKinney <sm...@apache.org> wrote:
> Lucas,
>
> My lack of any proficiency in aspects (whatsoever) means I can’t piece together how your example gets wired into the execution chain in order to try it out.
>
> Currently, there’s this in the test class that I’m using:
>
> @RunWith(FrameworkRunner.class)
> @CreateDS(name = "classDS", partitions =
> { @CreatePartition(name = "example", suffix = "dc=example,dc=com") })
> @CreateLdapServer(
> transports =
> {
> @CreateTransport(protocol = "LDAP", port = 10389)
> })
> @ApplyLdifFiles(
> { "fortress-schema.ldif", "init-ldap.ldif"/*, "test-data.ldif"*/})
> public class FortressJUnitApachedsTest extends AbstractLdapTestUnit
>
> ***
>
> How does your aspect get hooked in? Sorry for the rudimentary question. Is there a more complete example you can point me to?
>
> Thanks,
>
> Shawn
>
> > On Dec 12, 2018, at 11:27 AM, Lucas Theisen <lu...@pastdev.com> wrote:
> >
> > Not sure this helps much, but my team works around this for our integration test by using aop. Specifically:
> >
> > <aspectj>
> > <aspects>
> > <aspect name=" com.pastdev.apacheds.server.GetUniqueResourceReplacer" />
> > </aspects>
> > </aspectj>
> >
> >
> > And this implementation
> >
> > /**
> > * An aspect workaround for <a
> > * href="https://issues.apache.org/jira/browse/DIRSERVER-1606"
> > * >DIRSERVER-1606</a>
> > *
> > * @author LTHEISEN
> > */
> > @Aspect
> > public class GetUniqueResourceReplacer {
> > private static final Logger log = LoggerFactory.getLogger( GetUniqueResourceReplacer.class );
> >
> > @Pointcut( "execution(* org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.getUniqueResource(String,String)) &&" +
> > "args(resourceName,resourceDescription)" )
> > private void getUniqueResourceReplacer( String resourceName, String resourceDescription ) {
> > }
> >
> > @Around( "com.pastdev.apacheds.server.GetUniqueResourceReplacer.getUniqueResourceReplacer(resourceName,resourceDescription)" )
> > public URL getFirstMatchingResource( String resourceName, String resourceDescription ) throws IOException {
> > Enumeration<URL> resources = DefaultSchemaLdifExtractor.class.getClassLoader().getResources( resourceName );
> > if ( !resources.hasMoreElements() ) {
> > throw new UniqueResourceException( resourceName, resourceDescription );
> > }
> > URL result = resources.nextElement();
> > if ( resources.hasMoreElements() ) {
> > log.debug( "found more than one copy of " + resourceName + " using first one" );
> > }
> > return result;
> > }
> > }
> >
> > As stated in the comment, this issue relates to https://issues.apache.org/jira/browse/DIRSERVER-1606
> >
> > Maybe that will work for you too.
> >
> > On Wed, Dec 12, 2018 at 8:58 AM Shawn McKinney <sm...@apache.org> wrote:
> >
> > > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
> > >
> > > if you include ApacheDS, it will implicitely include LDAP API, so including ldap-api-all will be a duplicate, AFAIR.
> >
> > Here, fortress core apacheDS depends are: <scope>test</scope>, and of course we have compile-time dependency on the api.
> >
> > >
> > > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
> > >
> > > I'll have a closer look later today. What command are you executing that I can run to get the same result ?
> >
> > Simply executed the test class inside IDE, but it could command-line:
> >
> > $ mvn -Dtest=FortressJUnitApachedsTest test
> >
> > Thanks,
> > —Shawn
> >
>
Re: Exception Running ApacheDS embedded
Posted by Lucas Theisen <lu...@pastdev.com>.
Hi Shawn,
Sorry for the delay, took me a bit to extract out a working example. I
published it here: https://github.com/lucastheisen/apacheds-test
The README has the details (_i am pretty sure_) that are needed for your
project. However, even if i missed something in the README, the project
itself is a fully working example that demonstrates how i test my password
policy. It should not be all that difficult to adapt to your use case.
Hope it helps!
Lucas
On Fri, Dec 14, 2018 at 11:38 AM Shawn McKinney <sm...@apache.org>
wrote:
> Lucas,
>
> My lack of any proficiency in aspects (whatsoever) means I can’t piece
> together how your example gets wired into the execution chain in order to
> try it out.
>
> Currently, there’s this in the test class that I’m using:
>
> @RunWith(FrameworkRunner.class)
> @CreateDS(name = "classDS", partitions =
> { @CreatePartition(name = "example", suffix = "dc=example,dc=com") })
> @CreateLdapServer(
> transports =
> {
> @CreateTransport(protocol = "LDAP", port = 10389)
> })
> @ApplyLdifFiles(
> { "fortress-schema.ldif", "init-ldap.ldif"/*, "test-data.ldif"*/})
> public class FortressJUnitApachedsTest extends AbstractLdapTestUnit
>
> ***
>
> How does your aspect get hooked in? Sorry for the rudimentary question.
> Is there a more complete example you can point me to?
>
> Thanks,
>
> Shawn
>
> > On Dec 12, 2018, at 11:27 AM, Lucas Theisen <lu...@pastdev.com>
> wrote:
> >
> > Not sure this helps much, but my team works around this for our
> integration test by using aop. Specifically:
> >
> > <aspectj>
> > <aspects>
> > <aspect name="
> com.pastdev.apacheds.server.GetUniqueResourceReplacer" />
> > </aspects>
> > </aspectj>
> >
> >
> > And this implementation
> >
> > /**
> > * An aspect workaround for <a
> > * href="https://issues.apache.org/jira/browse/DIRSERVER-1606"
> > * >DIRSERVER-1606</a>
> > *
> > * @author LTHEISEN
> > */
> > @Aspect
> > public class GetUniqueResourceReplacer {
> > private static final Logger log = LoggerFactory.getLogger(
> GetUniqueResourceReplacer.class );
> >
> > @Pointcut( "execution(*
> org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.getUniqueResource(String,String))
> &&" +
> > "args(resourceName,resourceDescription)" )
> > private void getUniqueResourceReplacer( String resourceName, String
> resourceDescription ) {
> > }
> >
> > @Around(
> "com.pastdev.apacheds.server.GetUniqueResourceReplacer.getUniqueResourceReplacer(resourceName,resourceDescription)"
> )
> > public URL getFirstMatchingResource( String resourceName, String
> resourceDescription ) throws IOException {
> > Enumeration<URL> resources =
> DefaultSchemaLdifExtractor.class.getClassLoader().getResources(
> resourceName );
> > if ( !resources.hasMoreElements() ) {
> > throw new UniqueResourceException( resourceName,
> resourceDescription );
> > }
> > URL result = resources.nextElement();
> > if ( resources.hasMoreElements() ) {
> > log.debug( "found more than one copy of " + resourceName + "
> using first one" );
> > }
> > return result;
> > }
> > }
> >
> > As stated in the comment, this issue relates to
> https://issues.apache.org/jira/browse/DIRSERVER-1606
> >
> > Maybe that will work for you too.
> >
> > On Wed, Dec 12, 2018 at 8:58 AM Shawn McKinney <sm...@apache.org>
> wrote:
> >
> > > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com>
> wrote:
> > >
> > > if you include ApacheDS, it will implicitely include LDAP API, so
> including ldap-api-all will be a duplicate, AFAIR.
> >
> > Here, fortress core apacheDS depends are: <scope>test</scope>, and of
> course we have compile-time dependency on the api.
> >
> > >
> > > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com>
> wrote:
> > >
> > > I'll have a closer look later today. What command are you executing
> that I can run to get the same result ?
> >
> > Simply executed the test class inside IDE, but it could command-line:
> >
> > $ mvn -Dtest=FortressJUnitApachedsTest test
> >
> > Thanks,
> > —Shawn
> >
>
>
Re: Exception Running ApacheDS embedded
Posted by Shawn McKinney <sm...@apache.org>.
Lucas,
My lack of any proficiency in aspects (whatsoever) means I can’t piece together how your example gets wired into the execution chain in order to try it out.
Currently, there’s this in the test class that I’m using:
@RunWith(FrameworkRunner.class)
@CreateDS(name = "classDS", partitions =
{ @CreatePartition(name = "example", suffix = "dc=example,dc=com") })
@CreateLdapServer(
transports =
{
@CreateTransport(protocol = "LDAP", port = 10389)
})
@ApplyLdifFiles(
{ "fortress-schema.ldif", "init-ldap.ldif"/*, "test-data.ldif"*/})
public class FortressJUnitApachedsTest extends AbstractLdapTestUnit
***
How does your aspect get hooked in? Sorry for the rudimentary question. Is there a more complete example you can point me to?
Thanks,
Shawn
> On Dec 12, 2018, at 11:27 AM, Lucas Theisen <lu...@pastdev.com> wrote:
>
> Not sure this helps much, but my team works around this for our integration test by using aop. Specifically:
>
> <aspectj>
> <aspects>
> <aspect name=" com.pastdev.apacheds.server.GetUniqueResourceReplacer" />
> </aspects>
> </aspectj>
>
>
> And this implementation
>
> /**
> * An aspect workaround for <a
> * href="https://issues.apache.org/jira/browse/DIRSERVER-1606"
> * >DIRSERVER-1606</a>
> *
> * @author LTHEISEN
> */
> @Aspect
> public class GetUniqueResourceReplacer {
> private static final Logger log = LoggerFactory.getLogger( GetUniqueResourceReplacer.class );
>
> @Pointcut( "execution(* org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.getUniqueResource(String,String)) &&" +
> "args(resourceName,resourceDescription)" )
> private void getUniqueResourceReplacer( String resourceName, String resourceDescription ) {
> }
>
> @Around( "com.pastdev.apacheds.server.GetUniqueResourceReplacer.getUniqueResourceReplacer(resourceName,resourceDescription)" )
> public URL getFirstMatchingResource( String resourceName, String resourceDescription ) throws IOException {
> Enumeration<URL> resources = DefaultSchemaLdifExtractor.class.getClassLoader().getResources( resourceName );
> if ( !resources.hasMoreElements() ) {
> throw new UniqueResourceException( resourceName, resourceDescription );
> }
> URL result = resources.nextElement();
> if ( resources.hasMoreElements() ) {
> log.debug( "found more than one copy of " + resourceName + " using first one" );
> }
> return result;
> }
> }
>
> As stated in the comment, this issue relates to https://issues.apache.org/jira/browse/DIRSERVER-1606
>
> Maybe that will work for you too.
>
> On Wed, Dec 12, 2018 at 8:58 AM Shawn McKinney <sm...@apache.org> wrote:
>
> > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
> >
> > if you include ApacheDS, it will implicitely include LDAP API, so including ldap-api-all will be a duplicate, AFAIR.
>
> Here, fortress core apacheDS depends are: <scope>test</scope>, and of course we have compile-time dependency on the api.
>
> >
> > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
> >
> > I'll have a closer look later today. What command are you executing that I can run to get the same result ?
>
> Simply executed the test class inside IDE, but it could command-line:
>
> $ mvn -Dtest=FortressJUnitApachedsTest test
>
> Thanks,
> —Shawn
>
Re: Exception Running ApacheDS embedded
Posted by Lucas Theisen <lu...@pastdev.com>.
Not sure this helps much, but my team works around this for our integration
test by using aop. Specifically:
<aspectj>
<aspects>
<aspect name=" com.pastdev.apacheds.server.GetUniqueResourceReplacer" />
</aspects>
</aspectj>
And this implementation
/**
* An aspect workaround for <a
* href="https://issues.apache.org/jira/browse/DIRSERVER-1606"
* >DIRSERVER-1606</a>
*
* @author LTHEISEN
*/
@Aspect
public class GetUniqueResourceReplacer {
private static final Logger log = LoggerFactory.getLogger(
GetUniqueResourceReplacer.class );
@Pointcut( "execution(*
org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.getUniqueResource(String,String))
&&" +
"args(resourceName,resourceDescription)" )
private void getUniqueResourceReplacer( String resourceName, String
resourceDescription ) {
}
@Around(
"com.pastdev.apacheds.server.GetUniqueResourceReplacer.getUniqueResourceReplacer(resourceName,resourceDescription)"
)
public URL getFirstMatchingResource( String resourceName, String
resourceDescription ) throws IOException {
Enumeration<URL> resources =
DefaultSchemaLdifExtractor.class.getClassLoader().getResources(
resourceName );
if ( !resources.hasMoreElements() ) {
throw new UniqueResourceException( resourceName,
resourceDescription );
}
URL result = resources.nextElement();
if ( resources.hasMoreElements() ) {
log.debug( "found more than one copy of " + resourceName + "
using first one" );
}
return result;
}
}
As stated in the comment, this issue relates to
https://issues.apache.org/jira/browse/DIRSERVER-1606
Maybe that will work for you too.
On Wed, Dec 12, 2018 at 8:58 AM Shawn McKinney <sm...@apache.org> wrote:
>
> > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com>
> wrote:
> >
> > if you include ApacheDS, it will implicitely include LDAP API, so
> including ldap-api-all will be a duplicate, AFAIR.
>
> Here, fortress core apacheDS depends are: <scope>test</scope>, and of
> course we have compile-time dependency on the api.
>
> >
> > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com>
> wrote:
> >
> > I'll have a closer look later today. What command are you executing
> that I can run to get the same result ?
>
> Simply executed the test class inside IDE, but it could command-line:
>
> $ mvn -Dtest=FortressJUnitApachedsTest test
>
> Thanks,
> —Shawn
>
>
Re: Exception Running ApacheDS embedded
Posted by Shawn McKinney <sm...@apache.org>.
> On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
>
> if you include ApacheDS, it will implicitely include LDAP API, so including ldap-api-all will be a duplicate, AFAIR.
Here, fortress core apacheDS depends are: <scope>test</scope>, and of course we have compile-time dependency on the api.
>
> On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
>
> I'll have a closer look later today. What command are you executing that I can run to get the same result ?
Simply executed the test class inside IDE, but it could command-line:
$ mvn -Dtest=FortressJUnitApachedsTest test
Thanks,
—Shawn