Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Interoperability problems of C# PU in GS 7.0 but not in GS 6.6.x

I have found if I deploy a C# PU in GS .NET 7.0, say a PU is implementing a space event listener and
waiting for a Temple Class object to process, which is injected into the space from a Java application.
There will be an entry deserialization exception occured.

To tackle this problem, I put the Temple Class (say contained in a JAR file, called, template.jar) into <GS .NET 7.0 root>\lib\ext this have to be put in "ext" hardly where I tested thoroughly

This situation never occurs in the GS 6.6.x version which I don't have to put any jar which contains those entity classes into lib\ext\ and
the interoperability is no problem at all.

My question is somehow the namespace of the entity classes the C# PU is contained in the dll located in the same folder as the PU.
GS(C# PU) should be able to resolve an object which class namespaces(package) coming from a java application, yet I don't have to
put such class into a jar and put into \lib\ext\

To have further investigation, I have built a C# application, which is functionally as the same as the C#PU, waiting for a Temple class obj to process.
There is no problem at all when there is a class obj injected into the space from a Java application.

The class object is proved to be serializable just contains an Integer field for spaceId & spaceRouting
the namespaces and package are the same, otherwise there is no mean for me to get a success at all
SpaceProperty , AliasName for the C# entity class is hardly followed the documentation
so there is nth wrong in the code of class entity in both java/C#

I hope there should be someone can explain the situtation.

My environment:
GS 7.0 .NET
JDK 1.5

Best regards

This thread was imported from the previous forum.
For your reference, the original is available here

asked 2009-02-21 02:51:25 -0500

twinsenc gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

Hi,

In order to understand the issue can you please post the full exception and stacktrace that appears? moreover, please post the C# class code and Java class code.
What exactly do you mean by your PU is implementing space event listener? are you subscribing to space events notifications? or are you using the Event Listener Container abstraction?

Regardless of your error, I strongly recommend you'll use the Event Listener Container abstraction which came out since version 6.6.2, it is designed for easier and smarter PU implementations.
The processing unit data example and stock sba example have been updated since 6.6.2 to demonstrate it.

Please visit:
http://www.gigaspaces.com/wiki/display/XAP66NET/NotifyContainerComponent
http://www.gigaspaces.com/wiki/display/XAP66NET/PollingContainerComponent
http://www.gigaspaces.com/wiki/display/XAP7NET/NotifyContainerComponent
http://www.gigaspaces.com/wiki/display/XAP7NET/PollingContainerComponent

http://www.gigaspaces.com/wiki/display/XAP66NET/.NETProcessingUnitDataExample

There are some enhancement in the Event Listener Container between 7 and 6.6 regarding better automatic transaction support.

Eitan

answered 2009-02-21 03:39:00 -0500

eitany gravatar image
edit flag offensive delete link more
0

Thx for ur reply.

As I have mentioned, after I pack the entity class into a jar and put it into the <GS 7.0 .NET root>\lib\ext there is no com.j_spaces.core.EntrySerializationException occur.

The C# PU is deployed for mySpace datagrid.

in pu.config:


<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="GigaSpaces.XAP" type="GigaSpaces.XAP.Configuration.GigaSpacesXAPConfiguration, GigaSpaces.Core"/> </configSections> <appSettings> <add key="SpaceUrl" value="jini://localhost/*/mySpace"/> <add key="UseTransactions" value="false"/> </appSettings> <GigaSpaces.XAP> <ProcessingUnitContainer Type="GigaSpaces.Examples.ProcessingUnit.Processor.DataProcessor, GigaSpaces.Examples.ProcessingUnit.Processor"/> </GigaSpaces.XAP> </configuration>

Here is the entity class, Data


using System; using GigaSpaces.Core.Metadata;

namespace GigaSpaces.Examples.ProcessingUnit.Entities { /// <summary> /// Represnts a data object /// </summary>
[SpaceClass(AliasName = "GigaSpaces.Examples.ProcessingUnit.Entities.Data")] public class Data { #region Members private int? _id;

    [SpaceProperty(AliasName = "id")]
    [SpaceID]
    [SpaceRouting]
    public int? Id
    {
      get { return _id; }
      set { _id = value; }
    }
    #endregion

    public Data()
    {
    }

}

}


I modified a bit in the C# data-processor example so that I can save my effort. C:\GigaSpaces\XAP.NET 7.0.0 M4\Examples\ProcessingUnit\Processor

I modified a few lines in method [Initialize()|http://www.openspaces.org/forum/] of [ http://DataProcessor.cs|http://datapr... ]

public void Initialize() { ...... /* Lines commented by me*/ //Starts the space as a part of the cluster, the DataProcessor takes data from its embedded space only //SpaceConfig spaceConfig = new SpaceConfig(); //spaceConfig.ClusterInfo = _clusterInfo; //ISpaceProxy clusterProxy = SpaceProxyProviderFactory.Instance.FindSpace(spaceUrl, spaceConfig); //Gets the direct proxy from the cluster proxy that will be used by this processing unit //_proxy = clusterProxy.GetServerAdmin().GetDirectProxy();
//Create the event listener container

/* Lines added by me*/ _proxy = SpaceProxyProviderFactory.Instance.FindSpace(spaceUrl); _eventListenerContainer = EventListenerContainerFactory.CreateContainer<Data>(_proxy, new ExampleProcessor());

........ }


Surely, I have modified the ExampleProcessor.cs to make it workable for the new Data entity class

C#

using System; using System.Collections.Generic; using System.Text; using System.Threading; using GigaSpaces.Examples.ProcessingUnit.Entities; using GigaSpaces.XAP.Events; using GigaSpaces.XAP.Events.Polling;

namespace GigaSpaces.Examples.ProcessingUnit.Processor { /// <summary> /// This class contain the processing logic, marked as polling event driven. /// </summary> [PollingEventDriven(MinConcurrentConsumers = 1, MaxConcurrentConsumers = 4)|http://www.openspaces.org/forum/] internal class ExampleProcessor { #region Template /// <summary> /// Gets an unprocessed data /// </summary> [EventTemplate|http://www.openspaces.org/forum/] public Data UnprocessedData { get { Data template = new Data(); template.Id = 1; return template; } } #endregion

#region Processing methods /// <summary> /// Fake delay that represents processing time /// </summary> private const int ProcessingTime = 100; /// <summary> /// Receives a data and process it /// </summary> /// <param name="data">Data received</param> /// <returns>Processed data</returns> [DataEventHandler|http://www.openspaces.org/forum/] public Data ProcessData(Data data) { Console.WriteLine("** processing - Took element with info: " + data.Id); //Process data...
Thread.Sleep(ProcessingTime); //Set data state to processed

Console.WriteLine("** processing - done"); return data; } #endregion } }


Java

package GigaSpaces.Examples.ProcessingUnit.Entities; import com.gigaspaces.annotation.pojo.SpaceId; import com.gigaspaces.annotation.pojo.SpaceRouting;

public class Data { private Integer id; public Data(){ }

/** * @return the id */ @SpaceId @SpaceRouting public Integer getId() { return id; }

/** * @param id the id to set */ public void setId(Integer id) { this.id = id; } }


it is a java application to push a Data class obj into the space (mySpace)

package DataFeeder;

import org.openspaces.core.GigaSpace; import org.openspaces.core.GigaSpaceConfigurer; import org.openspaces.core.space.UrlSpaceConfigurer;

import com.j_spaces.core.IJSpace;

import GigaSpaces.Examples.ProcessingUnit.Entities.Data;

public class Feeder {

private GigaSpace gigaSpace;

public Feeder(String url) {

System.out.println("setting space " + url); IJSpace space = new UrlSpaceConfigurer(url).space(); // Connect to the space using the URL System.out.println("setting gigaspace "); gigaSpace = new GigaSpaceConfigurer(space).gigaSpace(); // Use gigaSpace simplified API System.out.println("finished setting gigaspace ");

}

public void pushData(Integer id) { Data d = new Data(); d.setId(id); gigaSpace.write(d); }

public static void main(String[] args) { //args[0]: jini://localhost/*/mySpace

String url = args[0]; Feeder feeder = new Feeder(url); feeder.pushData(1); }

}

Here is the console log after started an unmanaged space & C# PU, when there is a Data class obj pushed into the space by the Java Application.


2009/2/21 下午 09:19:58, Class: LRMIRuntime - com.j_spaces.core.JSpaceImpl#16736962410526, Method: read FINER [ http://com.gigaspaces.lrmi|http://com... ]: ENTRY (class=GigaSpaces.Examples.ProcessingUnit.Entities.Data,uid=1277536576^48^1^0^0,version=0) null 1,000 false true DynamicSmartStub --ImplObjClass: com.j_spaces.core.cluster.JSpaceClusteredProxy$Listener, ConnectionURL: NIO://C-Z93UJZRNH3RPT:2215/16736962410541_11, MaxConnPool: 1024-- null false 0

2009/2/21 下午 09:19:58, Class: LRMIRuntime - com.j_spaces.core.JSpaceImpl#16736962410526, Method: read FINER [ http://com.gigaspaces.lrmi|http://com... ]: RETURN null

2009/2/21 下午 09:19:59 FINE [ http://com.gigaspaces.lrmi|http://com... ]: Connected new client from [/123.203.191.157:2360] endpoint.

2009/2/21 下午 09:19:59 FINE [ http://com.gigaspaces.lrmi.classloadi... ]: Trying to load GigaSpaces.Examples.ProcessingUnit.Entities.Data using classloader:com.gigaspaces.lrmi.classloading.LRMIClassLoader$LRMILoader@1af1bd6

2009/2/21 下午 09:19:59 FINE [ http://com.gigaspaces.lrmi.classloadi... ]: Trying to find class: GigaSpaces.Examples.ProcessingUnit.Entities.Data

2009/2/21 下午 09:19:59 FINE [ http://com.gigaspaces.lrmi.classloadi... ]: Trying to retrieve from class provider class: GigaSpaces.Examples.ProcessingUnit.Entities.Data

2009/2/21 下午 09:19:59, Class: com.gigaspaces.lrmi.nio.Writer, Method: writePacket FINEST [ http://com.gigaspaces.lrmi|http://com... ]: --> Write Packet --RequestPacket: interface com.gigaspaces.lrmi.classloading.IClassProvider.getClassDefinition(long 1, java.lang.String GigaSpaces.Examples.ProcessingUnit.Entities.Data), isOneWay = false, isCallBack = false--

2009/2/21 下午 09:19:59, Class: com.gigaspaces.lrmi.nio.Reader, Method: bytesToPacket FINEST [ http://com.gigaspaces.lrmi|http://com... ]: <-- Read packet [ReplyPacket: |http://www.openspaces.org/forum/]

2009/2/21 下午 09:19:59 SEVERE [ http://com.gigaspaces.lrmi|http://com... ]: LRMI Transport Protocol caught server exception caused by [/123.203.191.157:2360] client. com.j_spaces.core.EntrySerializationException: Failed to deserialize Entry GigaSpaces.Examples.ProcessingUnit.Entities.Data at com.j_spaces.core.EntryPacket.readExternal(EntryPacket.java:653) at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1755) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1717) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305) at java ...

(more)

answered 2009-02-21 07:25:23 -0500

twinsenc gravatar image
edit flag offensive delete link more

Comments

Which milestone of the early access program of 7.0 are you using? can you also please try it with the latest (m5) and see if you get the same error?

Eitan

Edited by: Eitan Yanovsky on Feb 21, 2009 8:58 AM

eitany gravatar imageeitany ( 2009-02-21 08:55:57 -0500 )edit

it is m4

m5 just released,...yesterday if i dont remember wrongly

twinsenc gravatar imagetwinsenc ( 2009-02-21 09:36:05 -0500 )edit

The reason I am asking you to try it with the latest version is because looking at the stack trace you get a null pointer exception at a certain line where the code was changed since m4.
Therefore, it might be fixed as of now.

P.S, are you aware of the AliasName attribute? you don't have to use the same naming conventions for your package and namespace between your Java and C# objects, this also applied to properties and getters and setters. It doesn't have to do with your error but just letting you know.

Eitan

eitany gravatar imageeitany ( 2009-02-21 09:53:02 -0500 )edit

Thx u but I find the download link for .NET seems broken http://www.gigaspaces.com/tempfiles/d...

twinsenc gravatar imagetwinsenc ( 2009-02-21 20:52:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2009-02-21 02:51:25 -0500

Seen: 54 times

Last updated: Feb 21 '09