Unexplained ArrayStoreException - Code or Configur

2019-08-24 02:14发布

问题:

I am trying to debug an application that is working properly when tested locally on a Windows XP machine (version 5.1 build 2600 Service Pack 3) through Websphere Platform 6.1 running java version 1.5.

This application is throwing an ArrayStoreException when it is deployed to UNIX servers (SunOS, version 5.10) running java version 1.5.0_24.

I am leaning towards this being an environment configuration issue, but (other than it working locally) I can't seem to confirm that it's a configuration issue.

Below are the log messages that were added to the code to troubleshoot. As noted in the logs, the code is trying to add a Profile object to an Array of type Profile. I don't see why that wouldn't be working.

CollectionUtility.searchMapmsg=ZZZZZ Caught ArrayStoreException ZZZZZ

CollectionUtility.searchMap|msg=ZZZZZ Unable to add list item to Array of type [Lcom.process.im.profile.impl.Profile; ZZZZZ

CollectionUtility.searchMap|msg=ZZZZZ List[0] is class com.process.im.profile.impl.Profile, toString()=com.process.im.profile.impl.Profile mId=4, mLongName=ccounting ZZZZZ

Below is the java code that is producing the error

public static Object[] searchMap(Map m, Object[] keys, Object[] a)
{
    if (keys != null && a != null)
    {
        List<Object> l = new ArrayList<Object>(keys.length);

        searchMap(m, keys, l, true, null);

        try
        {
            a = l.toArray(a);

        }
        catch (ArrayStoreException eArrayStore)
        {
            Log.warning("CollectionUtility.searchMap", "ZZZZZ Caught ArrayStoreException ZZZZZ", 0);

            if(l==null)
            {
                Log.warning("CollectionUtility.searchMap", "ZZZZZ Core CollectionUtility ZZZZZ null list.", 0);
            }
            else
            {
                for(int i=0; i<l.size(); i++)
                {
                    Object bug = l.get(i);

                    if(bug==null)
                    {
                        Log.warning("CollectionUtility.searchMap", "ZZZZZ List[" + i + "] is null ZZZZZ", 0);
                    }
                    else
                    {
                        if (a!=null && !a.getClass().getName().equals(bug.getClass().getName()))
                        {
                            Log.warning("CollectionUtility.searchMap", "ZZZZZ Unable to add list item to Array of type " + a.getClass().getName() + " ZZZZZ", 0);

                            Log.warning("CollectionUtility.searchMap", "ZZZZZ List[" + i + "] is class " + bug.getClass().getName() + ", toString()=" + bug.toString() + " ZZZZZ", 0);
                        }

                    }
                }
            }

            throw eArrayStore;

        }
    }

    return a;
}

I know I may be missing something simple, but I'm not sure what to check next. If any of you have any ideas, please let me know. Any and all help is greatly appreciated. Thanks!

回答1:

Well for one, you are comparing the class of an Object array to an Object. I'm pretty sure thats not what you are intending to do.