Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities with PortableTemplateBuilder configuration are not persistable #1312

Open
sjcorbett opened this issue Apr 8, 2014 · 0 comments
Open
Labels

Comments

@sjcorbett
Copy link
Member

I had an entity configured thus:

SameServerEntity e = addChild(EntitySpec.create(SameServerEntity.class)
        .displayName("Entity")
        .configure(SameServerEntity.PROVISIONING_PROPERTIES, ImmutableMap.<String, Object>of(
                "templateBuilder", new PortableTemplateBuilder()
                    .os64Bit(true)
                    .minCores(2)
                    .minRam(8192))));

I launched Brooklyn launched with --persist auto.

XStream throws this exception when serialising the entity:

2014-04-08 16:05:20,023 WARN  Error serializing memento (attempt 1 of 5) for BasicEntityMemento{type=brooklyn.entity.basic.SameServerEntityImpl, id=YquHYAHr}; expected sometimes if attribute value modified
com.thoughtworks.xstream.converters.ConversionException: Could not call sun.net.www.http.KeepAliveCache.writeObject() : Could not call sun.net.www.http.ClientVector.writeObject() : null
---- Debugging information ----
message             : Could not call sun.net.www.http.ClientVector.writeObject()
cause-exception     : java.io.NotSerializableException
cause-message       : null
-------------------------------
message             : Could not call sun.net.www.http.KeepAliveCache.writeObject()
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : Could not call sun.net.www.http.ClientVector.writeObject() : null
-------------------------------
    at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteObject(SerializationMethodInvoker.java:140) ~[xstream-1.4.3.jar:na]
Caused by: com.thoughtworks.xstream.converters.ConversionException: Could not call sun.net.www.http.ClientVector.writeObject() : null
---- Debugging information ----
message             : Could not call sun.net.www.http.ClientVector.writeObject()
cause-exception     : java.io.NotSerializableException
cause-message       : null
-------------------------------
    at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteObject(SerializationMethodInvoker.java:140) ~[xstream-1.4.3.jar:na]
Caused by: java.io.NotSerializableException: null
    at sun.net.www.http.ClientVector.writeObject(KeepAliveCache.java:285) ~[na:1.7.0_51]

The PortableTemplateBuilder object keeps a reference to a Jclouds ComputeService. A long way down the serialisation chain this causes a Thread to be serialised, which causes XStream to fail.

My workaround has been to swap the template builder with direct configuration of the properties:

        .configure(SameServerEntity.PROVISIONING_PROPERTIES, ImmutableMap.<String, Object>of(
                JcloudsLocationConfig.MIN_RAM.getName(), 8192,
                JcloudsLocationConfig.MIN_CORES.getName(), 2,
                JcloudsLocationConfig.OS_64_BIT.getName(), true)
@grkvlt grkvlt added the bug label Apr 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants