ClassCastException in rename()

View: New views
4 Messages — Rating Filter:   Alert me  

ClassCastException in rename()

by John D'Emic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey All,

I'm encountering a ClassCastException in the rename() method of ServerContext. I'm not sure if I'm doing something wrong, but the code works with OpenLDAP but not with ApacheDS.  Here's the relevant lines from ServerContext:

 public void rename( Name oldName, Name newName ) throws NamingException
    {
        LdapDN oldDn = buildTarget( oldName );
        LdapDN newDn = buildTarget( newName );
       
        if ( oldDn.size() == 0 )
        {
            throw new LdapNoPermissionException( "can't rename the rootDSE" );
        }

        // calculate parents
        LdapDN oldBase = ( LdapDN ) oldName.clone();  <<<< ClassCastException

My client code is passing in org.springframework.ldap.support.DistinguishedName objects.  I could be mistaken, but it seems like the clone() should be on oldDn and not oldName.

Any help is appreciated,
-jd
       

Re: ClassCastException in rename()

by Emmanuel Lecharny-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

as you can see, the two DN are supposed to be LdapDN objects. If you pass some
org.springframework.ldap.support.DistinguishedName objects, you will
certainly get some ClasscastException, for sure...

On 9/30/07, jdemic <john.demic@...> wrote:

>
> Hey All,
>
> I'm encountering a ClassCastException in the rename() method of
> ServerContext. I'm not sure if I'm doing something wrong, but the code works
> with OpenLDAP but not with ApacheDS.  Here's the relevant lines from
> ServerContext:
>
>  public void rename( Name oldName, Name newName ) throws NamingException
>     {
>         LdapDN oldDn = buildTarget( oldName );
>         LdapDN newDn = buildTarget( newName );
>
>         if ( oldDn.size() == 0 )
>         {
>             throw new LdapNoPermissionException( "can't rename the rootDSE"
> );
>         }
>
>         // calculate parents
>         LdapDN oldBase = ( LdapDN ) oldName.clone();  <<<<
> ClassCastException
>
> My client code is passing in
> org.springframework.ldap.support.DistinguishedName objects.  I could be
> mistaken, but it seems like the clone() should be on oldDn and not oldName.
>
> Any help is appreciated,
> -jd
>
> --
> View this message in context: http://www.nabble.com/ClassCastException-in-rename%28%29-tf4545255.html#a12970503
> Sent from the Apache Directory Project mailing list archive at Nabble.com.
>
>


--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Re: ClassCastException in rename()

by John D'Emic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hmmm...shouldnt the method signature take LdapDN instances then instead of instances of Name?

Emmanuel Lecharny-3 wrote:
Hi,

as you can see, the two DN are supposed to be LdapDN objects. If you pass some
org.springframework.ldap.support.DistinguishedName objects, you will
certainly get some ClasscastException, for sure...

On 9/30/07, jdemic <john.demic@gmail.com> wrote:
>
> Hey All,
>
> I'm encountering a ClassCastException in the rename() method of
> ServerContext. I'm not sure if I'm doing something wrong, but the code works
> with OpenLDAP but not with ApacheDS.  Here's the relevant lines from
> ServerContext:
>
>  public void rename( Name oldName, Name newName ) throws NamingException
>     {
>         LdapDN oldDn = buildTarget( oldName );
>         LdapDN newDn = buildTarget( newName );
>
>         if ( oldDn.size() == 0 )
>         {
>             throw new LdapNoPermissionException( "can't rename the rootDSE"
> );
>         }
>
>         // calculate parents
>         LdapDN oldBase = ( LdapDN ) oldName.clone();  <<<<
> ClassCastException
>
> My client code is passing in
> org.springframework.ldap.support.DistinguishedName objects.  I could be
> mistaken, but it seems like the clone() should be on oldDn and not oldName.
>
> Any help is appreciated,
> -jd
>
> --
> View this message in context: http://www.nabble.com/ClassCastException-in-rename%28%29-tf4545255.html#a12970503
> Sent from the Apache Directory Project mailing list archive at Nabble.com.
>
>


--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Re: ClassCastException in rename()

by Emmanuel Lecharny-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

yes, for sure.

But we are just in the middle of a big cleanup, to get rid of such
horrible things ...

On 9/30/07, jdemic <john.demic@...> wrote:

>
>
> Hmmm...shouldnt the method signature take LdapDN instances then instead of
> instances of Name?
>
>
> Emmanuel Lecharny-3 wrote:
> >
> > Hi,
> >
> > as you can see, the two DN are supposed to be LdapDN objects. If you pass
> > some
> > org.springframework.ldap.support.DistinguishedName objects, you will
> > certainly get some ClasscastException, for sure...
> >
> > On 9/30/07, jdemic <john.demic@...> wrote:
> >>
> >> Hey All,
> >>
> >> I'm encountering a ClassCastException in the rename() method of
> >> ServerContext. I'm not sure if I'm doing something wrong, but the code
> >> works
> >> with OpenLDAP but not with ApacheDS.  Here's the relevant lines from
> >> ServerContext:
> >>
> >>  public void rename( Name oldName, Name newName ) throws NamingException
> >>     {
> >>         LdapDN oldDn = buildTarget( oldName );
> >>         LdapDN newDn = buildTarget( newName );
> >>
> >>         if ( oldDn.size() == 0 )
> >>         {
> >>             throw new LdapNoPermissionException( "can't rename the
> >> rootDSE"
> >> );
> >>         }
> >>
> >>         // calculate parents
> >>         LdapDN oldBase = ( LdapDN ) oldName.clone();  <<<<
> >> ClassCastException
> >>
> >> My client code is passing in
> >> org.springframework.ldap.support.DistinguishedName objects.  I could be
> >> mistaken, but it seems like the clone() should be on oldDn and not
> >> oldName.
> >>
> >> Any help is appreciated,
> >> -jd
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/ClassCastException-in-rename%28%29-tf4545255.html#a12970503
> >> Sent from the Apache Directory Project mailing list archive at
> >> Nabble.com.
> >>
> >>
> >
> >
> > --
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ClassCastException-in-rename%28%29-tf4545255.html#a12970672
> Sent from the Apache Directory Project mailing list archive at Nabble.com.
>
>


--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com