You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by risbarov <ru...@gmail.com> on 2018/02/15 15:54:39 UTC

BinaryInvalidTypeException

Hello dear support team!

My problem is similar to 
http://apache-ignite-users.70518.x6.nabble.com/Issue-while-using-Affinity-function-for-mapping-keys-with-nodes-td9580.html
<http://apache-ignite-users.70518.x6.nabble.com/Issue-while-using-Affinity-function-for-mapping-keys-with-nodes-td9580.html> 
.

I have:

1. Standalone Ignite server instance. Server configuration file is attached
to this message.
2. Client application that connects to Ignite server, populates my test
cache "TestPersonCache" and runs IgniteCallable that uses data in test
"TestPersonCache". Source code is attached to this message.

When I run my client application I'm getting exception:



For many reasons I can't put my jar in $IGNITE_HOME/lib directory. Following
the advice I did:

1. Set <property name="peerClassLoadingEnabled" value="true"/> in client and
server configuration files.
2. Invoke withKeepBinary() before using my "TestPersonCache".

But I'm still getting this exception. Please tell me what's wrong.

Thanks!

ignite-test.zip
<http://apache-ignite-users.70518.x6.nabble.com/file/t1629/ignite-test.zip>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: BinaryInvalidTypeException in IgniteCallable

Posted by risbarov <ru...@gmail.com>.
Rubber duck debugging is working . I understood my issue: I still use my
domain model class in IgniteCallable instead of BinaryObject. 
In my real project we have large and complex domain model and it would be
inconvenient to work with each type as BinaryObject. Is there a way to use
my domain classes without placing jar in $IGNITE_HOME/lib?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: BinaryInvalidTypeException in IgniteCallable

Posted by risbarov <ru...@gmail.com>.
Exception:

... 
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:
test.ignite.Person 
... 
Caused by: java.lang.ClassNotFoundException: test.ignite.Person 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: BinaryInvalidTypeException in IgniteCallable

Posted by Mikhail <mi...@gmail.com>.
Hi 

Looks like you forgot to add the exception that you to the mail. 
Could you please send it to us?

Thanks,
Mike.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: BinaryInvalidTypeException

Posted by Alexey Kukushkin <ku...@gmail.com>.
   1. Peer class loading is applicable only to computational code and not
   to the cache key and value types. In your case enabling peer class loading
   helped you to auto-deploy your IgniteCallable but it is not supposed to
   auto-deploy your Person cache value type.
   2. You can avoid manually deploying Person class if you use Ignite
   Binary Object API. Your code has to be fixed like this:

IgniteCache<UUID, IgniteBinary> igniteCache =
ignite.getOrCreateCache(CACHE_NAME);

igniteCache.put(key, ignite.binary().toBinary(person));

String fullName = ignite.compute().affinityCall(

    CACHE_NAME,
    person.getId(),
    new IgniteCallable<String>() {
        @Override
        public String call() {
            return igniteCache.invoke(key, (CacheEntryProcessor<UUID,
BinaryObject, String>)(entry, arguments) -> {

                if (entry.exists() && entry.getValue() != null) {
                    BinaryObject personCached = entry.getValue();

                    return personCached.field("firstName" + " "
                        + personCached.field("lastName");
                }

                return null;
            });
        }
    }
);

System.out.println("fullName = " + fullName);