How to fix issue with callable lambda serialization? - serialization

I'm getting this error message when trying to serialize a callable lambda which has a reference to a instance of class A. The error happens when I submit the callable to a distributed executor service in hazelcast.
com.hazelcast.nio.serialization.HazelcastSerializationException:
java.lang.ClassCastException:
cannot assign instance of somepackage.A
to field java.lang.invoke.SerializedLambda.capturingClass
of type java.lang.Class in instance of java.lang.invoke.SerializedLambda

Related

createCache fails in non-static method

I am creating a cache with a CacheStoreFactory implementation and a CacheStoreSessionListener. If I set the CacheConfiguration with these fields and then call createCache but in an INSTANCE method I get this exception:
Exception in thread "main" javax.cache.CacheException: class
org.apache.ignite.IgniteCheckedException: Failed to validate cache
configuration (make sure all objects in cache configuration are
serializable): LongCache
In a static method, this does not occur. This can be easily reproduced by modifying the CacheJdbcStoreExample.java in examples. This is happening under Ignite 1.30
Most likely you declared the factory or the listener as an anonymous class. Anonymous classes always contain reference to the parent class (LongCache in your case). So if the factory is serialized in the context of LongCache instance, this instance is also serialized. In case of static method this instance doesn't exist, therefore everything works.
I would recommend to convert anonymous classes to private static classes. This will give you more control on what is serialized.

In ServiceMatrix, is it possible to 'ConvertToSaga' an endpoint which publishes/subscribes event messages rather than command messages?

I've got a solution with 4 NSB host endpoints which were created using ServiceMatrix and I want to use them within a saga.
I know how to Convert To Saga from a command and that works fine in a test project. What I don't understand is how I can do the same thing with published events, as the menu option is not available. Is it possible to do this using ServiceMatrix ?
I have tried to implement the changes by hand by following this tutorial and observing the changes that were made to my test project when I Converted To Saga.
It builds ok but throws an error within the framework when running:
System.InvalidOperationException was unhandled
Message: An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
Additional information: No IBus instance available, please configure one and also verify that you're not defining your own Bus property in your saga since that hides the one in the base class
I'm using VS2013 and ServiceBus 5.
UPDATE:
I commented out the inherited IHandleMessages<> interface and public IBus Bus property from the generated code and it runs without this error. I'm not happy doing this, as the next design change using the tool will overwrite these fixes.
In your command handler you usually have a property of type IBus that is injected to the handler class either by property injection or constructor injection.
When you move from a command handler to a Saga, you need to remove your IBus property from the handler. Saga base class has a Bus property that you should use instead. This property is populated for you automatically, you should not care about this. This is exactly what this exception is telling you.

Migrating stateful session bean from EJB 2.1 to EJB 3 - how to migrate create method having args

Im trying to migrate a stateful session bean from EJB 2.1 to EJB 3.0, the home interface of the bean which extends EJBHome has a create method with two args and the corresponding bean has a matching args ejbcreate method and one more no arg ejbcreate method.
My question is-
1. do I need to create two constructors one no arg and one arg to migrate this stateful session bean?
2. The ejbcreate method code is throwing "CreateException" and a run time exception, as of now ejbcreate defines throws "CreateException", do i need to define thorws CreateException" on the constructor or can I skip the create exception throwing part in the code of the constructor.
Other alternative I see posted in one blog is creating a method and annotating with #init, though not sure if this is the way as they were talking about EJB2 client view for a EJB3 bean.
There is unfortunately no way to specify arguments while creating a stateful session bean using EJB 3, so you'll need to add an initialize(arg1, arg2) method and call it after obtaining in instance via JNDI.
Only the no-arg constructor can be used in EJB 3.
Yes, #Init is the equivalent of ejbCreate when using annotations to define the EJB 2 client view when using EJB 3 style bean definition.

Interface type as property of class throws error on client WCF

Hi I have a class which has a property of type of an interface
public class A
{
public List<IInterface> interface {get;set;}
}
Public class B : IInterface
{
// Some properties
}
A wcf service is calling a OpertaionContract which return an object type of this object but it fails on my client.
I had already added the ServiceKnowType attribute on all implemented classes on the service contract but still i am getting the same error
"Consider using a DataContractResolver or add the type corresponding to 'B' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer
I am really confused how this would work , please advise thanks.
I added the KnowTypeAttribute at the right datacontract so the above error went away but now I am getting a generic error of underline connection got closed.
Updated:This link helped me out in resolving the Interface issue How can I pass a List<Interface> over WCF?
But right now enums are giving me a similar issue my object breaks on client cause of enums properties being defined in the class.
for your enum problem, are you using EnumMember for the enums? See http://www.codekeep.net/snippets/0002f271-1418-4027-b19a-3820702fc22f.aspx for an example.
If that doesn't solve it, can you share the error message you're getting with the enum usage?

Problem with spring + nhibernate in .net environment

I am working with Spring.net 1.3 and nHibernate for .net 1.3.
While fetching the application context using XML ( _appContext = new XmlApplicationContext("abc.xml")) I am getting the exception as
"Error creating object with name 'NHibernateSessionFactory' defined in abc.xml"
Initialization of object failed : The following types may not be used as proxies"
I have declared all the properties of class as public virtual.still why am i getting this exception
Thanks in advance
You must have missed marking a property or method virtual. The exception (or an InnerException, I'm not familiar with Spring) message should tell you exactly which type is the problem. For example, I just reproduced this:
{"The following types may not be used as proxies:\nModel.Project: method get_ProjectId should be 'public/protected virtual' or 'protected internal virtual'"}