You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "kcheng.mvp" <kc...@gmail.com> on 2016/04/19 09:07:04 UTC

Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:

I ran into this issue with below code




public static void main(String[] args) {
        ApplicationContext appCtx = new ClassPathXmlApplicationContext(new
String[] {"grid-01.xml"});
        IgniteSpringBean ignite =
(IgniteSpringBean)appCtx.getBean("igniteSpringBean");
        IgniteCache<String,Integer> cache =
ignite.getOrCreateCache("cache01");



        for(int i =0; i < 10; i++){
            cache.invoke("good", new EntryProcessor<String, Integer, Void>()
{
                @Override
                public Void process(MutableEntry<String, Integer> entry,
                    Object... objects) throws EntryProcessorException {
                    Integer v = entry.getValue();
                    v = v == null ? 1 : v+1;
                    entry.setValue(v);
                    return null;
                }
            });
        }
        System.out.println("good ->" + cache.get("good"));

        ignite.close();
    }




here is the error stack


Exception in thread "main" javax.cache.CacheException: class
org.apache.ignite.IgniteCheckedException: com.oss.ignite.grid.Grid01$1
	at
org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1479)
	at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.cacheException(IgniteCacheProxy.java:1944)
	at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.invoke(IgniteCacheProxy.java:1545)
	at com.oss.ignite.grid.Grid01.main(Grid01.java:34)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: class org.apache.ignite.IgniteCheckedException:
com.oss.ignite.grid.Grid01$1
	at
org.apache.ignite.internal.processors.cache.GridCacheIoManager.unmarshall(GridCacheIoManager.java:1084)
	at
org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:315)
	at
org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:244)
	at
org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$000(GridCacheIoManager.java:81)
	at
org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:203)
	at
org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1219)
	at
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:847)
	at
org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:105)
	at
org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:810)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:
com.oss.ignite.grid.Grid01$1
	at
org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:619)
	at
org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:616)
	at
org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1465)
	at
org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:295)
	at
org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal(BinaryMarshaller.java:109)
	at
org.apache.ignite.internal.processors.cache.GridCacheMessage.unmarshalCollection(GridCacheMessage.java:611)
	at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateRequest.finishUnmarshal(GridNearAtomicUpdateRequest.java:638)
	at
org.apache.ignite.internal.processors.cache.GridCacheIoManager.unmarshall(GridCacheIoManager.java:1078)
	... 11 more
Caused by: java.lang.ClassNotFoundException: com.oss.ignite.grid.Grid01$1
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at
org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8246)
	at
org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185)
	at
org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:610)
	... 18 more




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Caused-by-class-org-apache-ignite-binary-BinaryInvalidTypeException-tp4311.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:

Posted by Vladimir Ozerov <vo...@gridgain.com>.
Hi.

Yes, normally computations are performed on both primary and backup nodes.

Vladimir.

On Wed, Apr 27, 2016 at 10:19 AM, kcheng.mvp <kc...@gmail.com> wrote:

> Saying cache mode is "PARTITIONED", in this case both primary node and
> backup
> nodes would execute the same piece of code, right?
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Caused-by-class-org-apache-ignite-binary-BinaryInvalidTypeException-tp4311p4585.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:

Posted by "kcheng.mvp" <kc...@gmail.com>.
Saying cache mode is "PARTITIONED", in this case both primary node and backup
nodes would execute the same piece of code, right?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Caused-by-class-org-apache-ignite-binary-BinaryInvalidTypeException-tp4311p4585.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:

Posted by vkulichenko <va...@gmail.com>.
This means that you can send small entry processor instead of sending a large
object instance to a remote node. For example, in the code you provided you
send an entry processor that increments the value. Now imagine that it
increments a value of one the fields in an object with 100 fields. In this
case you will avoid sending the whole object across network, which will
reduce network traffic and improve performance.

Essentially, you are sending computations to the data, but not other way
around, like in classic client-server architecture.

Makes sense?

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Caused-by-class-org-apache-ignite-binary-BinaryInvalidTypeException-tp4311p4581.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:

Posted by "kcheng.mvp" <kc...@gmail.com>.
Yes, you are right, also need another minor change as well.

need to set "peerClassLoadingEnabled" to "true"


By the way, what does it mean for below
explanation(https://apacheignite.readme.io/v1.5/docs/jcache)


> Whenever doing puts and updates in cache, you are usually sending full
> state object state across the network. EntryProcessor allows for
> processing data directly on primary nodes, often transferring only the
> deltas instead of the full state.





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Caused-by-class-org-apache-ignite-binary-BinaryInvalidTypeException-tp4311p4572.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:

Posted by vkulichenko <va...@gmail.com>.
Hi,

Anonymous classes in Java hold the reference to the external class with all
its fields. When your entry processor is serialized, it fetches everything
around it. I recommend to replace anonymous class with a static inner class.
This is a recommend way for Serializable classes in Java, because it gives
you more control on what is serialized and what is not.

Can you try this and let us know if it works?

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Caused-by-class-org-apache-ignite-binary-BinaryInvalidTypeException-tp4311p4338.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.