You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Stefan Seelmann <se...@apache.org> on 2010/11/16 13:08:21 UTC

Use classloader with index to extract schema

Hi guys,

I'm trying to get Studio's UI tests working again. I updated ApacheDS
and Shared dependencies to current trunk. I had problems when using
the FrameworkRunner (which starts an embedded ApacheDS). The schema
extractor uses the java.class.path to scan the JARs for schema LDIF
files. However in the Eclipse RCP (OSGi) environment the
java.class.path only contains the bootstrap JAR. Similar issues were
already reported in [1] and [2].

Owen Jacobson proposed in [2] to use an index file that lists all
schema LDIF files. I think that's a great idea. I tested the solution
in a branch [3] and it works fine for the UI tests. I think it should
also work for other cases. Unfortunately I can't run the full ApacheDS
test suite atm.

I created the index file with
    find src/main/resources/schema -name "*.ldif" | sed
's:src/main/resources/::'
and added it to SVN
(src/main/resources/META-INF/apacheds-schema.index). A better solution
would be to generate the index file during the build, and to avoid its
addition to version control. One way would be to execute that (or a
similar) command using the exec-maven-plugin, but it only works on
Unix. A better way would be to create a new Maven plugin (I searched
but didn't find an existsing Maven plugin that scan the file system
and creates a file list).

@Owen
You volunteered to create a Maven Plugin :-) Do you still want to give
it a try and contribute it to the Directory project?

Kind Regards,
Stefan


[1] https://issues.apache.org/jira/browse/DIRSERVER-1504
[2] http://mail-archives.apache.org/mod_mbox/directory-users/201009.mbox/%3CAANLkTi=-QYedzbfWpsE850NTuqq9vvoJJ0Z5rnLzgbf_@mail.gmail.com%3E
[3] https://svn.apache.org/repos/asf/directory/shared/branches/ldap-schema-index

Re: Use classloader with index to extract schema

Posted by Stefan Seelmann <se...@apache.org>.
On Tue, Nov 16, 2010 at 1:58 PM, Alex Karasulu <ak...@apache.org> wrote:
> This schema file will need to be updated I guess when users create a new
> schema in ApacheDS correct?

I don't think so. The shared-ldap-schema contains the ApacheDS default
schema that is extracted when the server is started the first time. So
changes on the extracted schema or not a problem.

But there is still a pb when a user wants to add another schema.jar to
the classpath (e.g. of an embedded server). In that case he must also
generate the index file and add it to the JAR. And we need to modify
the code and use the ClassLoader.getResources() method, in order to
find and process all index files available in the class loader.

Thanks Alex.

Kind Regards,
Stefan

Re: Use classloader with index to extract schema

Posted by Pierre-Arnaud Marcelot <pa...@marcelot.net>.
On 16 nov. 2010, at 14:18, Kiran Ayyagari wrote:

> On Tue, Nov 16, 2010 at 6:28 PM, Alex Karasulu <ak...@apache.org> wrote:
>> 
>> 
>> On Tue, Nov 16, 2010 at 2:08 PM, Stefan Seelmann <se...@apache.org>
>> wrote:
>>> 
>>> Hi guys,
>>> 
>>> I'm trying to get Studio's UI tests working again. I updated ApacheDS
>>> and Shared dependencies to current trunk. I had problems when using
>>> the FrameworkRunner (which starts an embedded ApacheDS). The schema
>>> extractor uses the java.class.path to scan the JARs for schema LDIF
>>> files. However in the Eclipse RCP (OSGi) environment the
>>> java.class.path only contains the bootstrap JAR. Similar issues were
>>> already reported in [1] and [2].
>>> 
>>> Owen Jacobson proposed in [2] to use an index file that lists all
>>> schema LDIF files. I think that's a great idea. I tested the solution
>>> in a branch [3] and it works fine for the UI tests. I think it should
>>> also work for other cases. Unfortunately I can't run the full ApacheDS
>>> test suite atm.
>>> 
>>> I created the index file with
>>>    find src/main/resources/schema -name "*.ldif" | sed
>>> 's:src/main/resources/::'
>>> and added it to SVN
>>> (src/main/resources/META-INF/apacheds-schema.index). A better solution
>>> would be to generate the index file during the build, and to avoid its
>>> addition to version control. One way would be to execute that (or a
>>> similar) command using the exec-maven-plugin, but it only works on
>>> Unix. A better way would be to create a new Maven plugin (I searched
>>> but didn't find an existsing Maven plugin that scan the file system
>>> and creates a file list).
>>> 
>> 
>> This schema file will need to be updated I guess when users create a new
>> schema in ApacheDS correct?
> users have two options:
> 1. if a user wants his schema to be loaded by the server then bundling
> the schema within the
>    standard apacheds-ldap-schema jar and updating this file is the
> only way to go
> 
> 2. load their custom schema using a LDAP client or through their
> application code
> 
> we should suggest users to use the 2nd method so that we can find the
> default schema files using
> the index file which will solve all the classpath related issues we
> are facing to load schema.

+1

We would also need to implement option #2 in our LDAP Unit Test Framework where the user would be able to specify either a custom schema index file or the list of custom schema files.

>> So I guess there would be more we would need to do with this. Also this
>> reminds me sort of by the index file we used to have in the past for
>> partition index files for the schema partition. I remember running into
>> several build problems when we were using it. But this does not mean we will
>> have the same problem here.
>> 
>>> 
>>> @Owen
>>> You volunteered to create a Maven Plugin :-) Do you still want to give
>>> it a try and contribute it to the Directory project?
>>> 
>>> Kind Regards,
>>> Stefan
>>> 
>>> 
>>> [1] https://issues.apache.org/jira/browse/DIRSERVER-1504
>>> [2]
>>> http://mail-archives.apache.org/mod_mbox/directory-users/201009.mbox/%3CAANLkTi=-QYedzbfWpsE850NTuqq9vvoJJ0Z5rnLzgbf_@mail.gmail.com%3E
>>> [3]
>>> https://svn.apache.org/repos/asf/directory/shared/branches/ldap-schema-index
>> 
>> 
>> 
>> --
>> Alex Karasulu
>> My Blog :: http://www.jroller.com/akarasulu/
>> Apache Directory Server :: http://directory.apache.org
>> Apache MINA :: http://mina.apache.org
>> To set up a meeting with me: http://tungle.me/AlexKarasulu
>> 
> 
> 
> 
> -- 
> Kiran Ayyagari


Re: Use classloader with index to extract schema

Posted by Kiran Ayyagari <ka...@apache.org>.
On Tue, Nov 16, 2010 at 6:28 PM, Alex Karasulu <ak...@apache.org> wrote:
>
>
> On Tue, Nov 16, 2010 at 2:08 PM, Stefan Seelmann <se...@apache.org>
> wrote:
>>
>> Hi guys,
>>
>> I'm trying to get Studio's UI tests working again. I updated ApacheDS
>> and Shared dependencies to current trunk. I had problems when using
>> the FrameworkRunner (which starts an embedded ApacheDS). The schema
>> extractor uses the java.class.path to scan the JARs for schema LDIF
>> files. However in the Eclipse RCP (OSGi) environment the
>> java.class.path only contains the bootstrap JAR. Similar issues were
>> already reported in [1] and [2].
>>
>> Owen Jacobson proposed in [2] to use an index file that lists all
>> schema LDIF files. I think that's a great idea. I tested the solution
>> in a branch [3] and it works fine for the UI tests. I think it should
>> also work for other cases. Unfortunately I can't run the full ApacheDS
>> test suite atm.
>>
>> I created the index file with
>>    find src/main/resources/schema -name "*.ldif" | sed
>> 's:src/main/resources/::'
>> and added it to SVN
>> (src/main/resources/META-INF/apacheds-schema.index). A better solution
>> would be to generate the index file during the build, and to avoid its
>> addition to version control. One way would be to execute that (or a
>> similar) command using the exec-maven-plugin, but it only works on
>> Unix. A better way would be to create a new Maven plugin (I searched
>> but didn't find an existsing Maven plugin that scan the file system
>> and creates a file list).
>>
>
> This schema file will need to be updated I guess when users create a new
> schema in ApacheDS correct?
users have two options:
1. if a user wants his schema to be loaded by the server then bundling
the schema within the
    standard apacheds-ldap-schema jar and updating this file is the
only way to go

2. load their custom schema using a LDAP client or through their
application code

we should suggest users to use the 2nd method so that we can find the
default schema files using
the index file which will solve all the classpath related issues we
are facing to load schema.

> So I guess there would be more we would need to do with this. Also this
> reminds me sort of by the index file we used to have in the past for
> partition index files for the schema partition. I remember running into
> several build problems when we were using it. But this does not mean we will
> have the same problem here.
>
>>
>> @Owen
>> You volunteered to create a Maven Plugin :-) Do you still want to give
>> it a try and contribute it to the Directory project?
>>
>> Kind Regards,
>> Stefan
>>
>>
>> [1] https://issues.apache.org/jira/browse/DIRSERVER-1504
>> [2]
>> http://mail-archives.apache.org/mod_mbox/directory-users/201009.mbox/%3CAANLkTi=-QYedzbfWpsE850NTuqq9vvoJJ0Z5rnLzgbf_@mail.gmail.com%3E
>> [3]
>> https://svn.apache.org/repos/asf/directory/shared/branches/ldap-schema-index
>
>
>
> --
> Alex Karasulu
> My Blog :: http://www.jroller.com/akarasulu/
> Apache Directory Server :: http://directory.apache.org
> Apache MINA :: http://mina.apache.org
> To set up a meeting with me: http://tungle.me/AlexKarasulu
>



-- 
Kiran Ayyagari

Re: Use classloader with index to extract schema

Posted by Alex Karasulu <ak...@apache.org>.
On Tue, Nov 16, 2010 at 2:08 PM, Stefan Seelmann <se...@apache.org>wrote:

> Hi guys,
>
> I'm trying to get Studio's UI tests working again. I updated ApacheDS
> and Shared dependencies to current trunk. I had problems when using
> the FrameworkRunner (which starts an embedded ApacheDS). The schema
> extractor uses the java.class.path to scan the JARs for schema LDIF
> files. However in the Eclipse RCP (OSGi) environment the
> java.class.path only contains the bootstrap JAR. Similar issues were
> already reported in [1] and [2].
>
> Owen Jacobson proposed in [2] to use an index file that lists all
> schema LDIF files. I think that's a great idea. I tested the solution
> in a branch [3] and it works fine for the UI tests. I think it should
> also work for other cases. Unfortunately I can't run the full ApacheDS
> test suite atm.
>
> I created the index file with
>    find src/main/resources/schema -name "*.ldif" | sed
> 's:src/main/resources/::'
> and added it to SVN
> (src/main/resources/META-INF/apacheds-schema.index). A better solution
> would be to generate the index file during the build, and to avoid its
> addition to version control. One way would be to execute that (or a
> similar) command using the exec-maven-plugin, but it only works on
> Unix. A better way would be to create a new Maven plugin (I searched
> but didn't find an existsing Maven plugin that scan the file system
> and creates a file list).
>
>
This schema file will need to be updated I guess when users create a new
schema in ApacheDS correct?

So I guess there would be more we would need to do with this. Also this
reminds me sort of by the index file we used to have in the past for
partition index files for the schema partition. I remember running into
several build problems when we were using it. But this does not mean we will
have the same problem here.



> @Owen
> You volunteered to create a Maven Plugin :-) Do you still want to give
> it a try and contribute it to the Directory project?
>
> Kind Regards,
> Stefan
>
>
> [1] https://issues.apache.org/jira/browse/DIRSERVER-1504
> [2]
> http://mail-archives.apache.org/mod_mbox/directory-users/201009.mbox/%3CAANLkTi=-QYedzbfWpsE850NTuqq9vvoJJ0Z5rnLzgbf_@mail.gmail.com%3E
> [3]
> https://svn.apache.org/repos/asf/directory/shared/branches/ldap-schema-index
>



-- 
Alex Karasulu
My Blog :: http://www.jroller.com/akarasulu/
Apache Directory Server :: http://directory.apache.org
Apache MINA :: http://mina.apache.org
To set up a meeting with me: http://tungle.me/AlexKarasulu