storm-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Bonello <bonej...@gmail.com>
Subject Re: Storm + Spring + JPA
Date Tue, 03 Feb 2015 15:52:28 GMT
Dear all,

Solved the issue as follows:

1. Set the Facade as transient

private transient ISaveFacade saveFacade;

2. In the get method, check if the facade is null. If it is null, then call
the reset method;

3. Add new reset method as follows:

private void resetFacade() {
    ClassPathXmlApplicationContext ctx = new
ClassPathXmlApplicationContext("/config/spring-persistence-runtime.xml");
    setSaveFacade((ISaveFacade) ctx.getBean("saveFacade"));
}

Note: I had an issue using the spring persistence configuration I use for
running the application, so I created a different one for the Bolts.

Hope this helps.

Regards
Joseph

On Tue, Feb 3, 2015 at 4:32 PM, Florian Hussonnois <fhussonnois@gmail.com>
wrote:

> Hi,
>
> If you have annotate your Facade with @Repository. Spring creates a proxy
> class to intercept and wrap jdbc exceptions.
> This proxy is not Serializable!
>
> 2015-02-03 14:46 GMT+01:00 Joseph Bonello <bonej010@gmail.com>:
>
>> Hi,
>>
>> I have amended the PrinterBolt class in the storm-starter project so that
>> it saves the data it receives to a MySQL database. I have created an entity
>> and a repository with Spring and I am using the repository to save the
>> entity. I have implemented a facade that uses the repository to save the
>> entity.
>>
>> public class PrinterBoltImpl extends BaseBasicBolt {
>>      @Resource
>>      private ISaveFacade saveFacade;
>>
>> @Override
>> public void execute(Tuple tuple, BasicOutputCollector collector) {
>> Data data = (Data) tuple.getValue(0);
>> SaveData rec = new SaveData();
>>  rec.setInterestingData(data.toString());
>>  saveFacade.saveData(rec);
>>  logger.info(data.toString());
>> }
>>
>> }
>>
>> This is the exception trace I get:
>>
>> java.lang.RuntimeException: java.io.NotSerializableException:
>> org.springframework.dao.support.PersistenceExceptionTranslationInterceptor
>> at
>> backtype.storm.serialization.DefaultSerializationDelegate.serialize(DefaultSerializationDelegate.java:43)
>> ~[storm-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
>> at backtype.storm.utils.Utils.serialize(Utils.java:91)
>> ~[storm-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
>> at
>> backtype.storm.topology.TopologyBuilder.createTopology(TopologyBuilder.java:106)
>> ~[storm-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
>> at m.e.n.Test.runTest(Test.java:49) [classes/:na]
>> at m.e.n.Test.main(Test.java:35) [classes/:na]
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> ~[na:1.8.0_25]
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>> ~[na:1.8.0_25]
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> ~[na:1.8.0_25]
>> at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
>> at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
>> [exec-maven-plugin-1.2.1.jar:na]
>> at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
>> Caused by: java.io.NotSerializableException:
>> org.springframework.dao.support.PersistenceExceptionTranslationInterceptor
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1378)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
>> ~[na:1.8.0_25]
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
>> ~[na:1.8.0_25]
>> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
>> ~[na:1.8.0_25]
>> at
>> backtype.storm.serialization.DefaultSerializationDelegate.serialize(DefaultSerializationDelegate.java:39)
>> ~[storm-core-0.10.0-SNAPSHOT.jar:0.10.0-SNAPSHOT]
>> ... 10 common frames omitted
>>
>> Can anyone help?
>>
>> Thanks
>> Joseph
>>
>
>
>
> --
> Florian HUSSONNOIS
> Tel +33 6 26 92 82 23
>

Mime
View raw message