吊索作业未使用自定义可序列化属性处理

时间:2019-03-22 12:15:43

标签: aem cq5 sling

我创建了自定义的Serializable类,并将其添加到必要的Sling Job的有效负载中

public SomeClass extends Serializable {
    //Implementaton details
}

.......
//some service

Map<String, Object> payload = new HashMap<>();
payload.put("property1", someClassObject);

jobManager.createJob("some/job/topic").properties(payload).add();

成功创建并分配了重复使用的作业,但是未触发process的{​​{1}}方法。

crx /var/eventing

我已经在org.apache.sling.event.jobs上启用了TRACE日志级别,日志说的是一样的:添加并分配了作业,没有其他反应:

JobConsumer

如果我传递标准的可序列化对象,如String,Integer等;作业开始了,我可以在日志中找到证据:

20.03.2019 11:15:00.263 DEBUG [sling-threadpool-15f9e0b4-a24d-4b0d-bf4a-433ec604e41d-(apache-sling-job-thread-pool)-27-<main queue>(com/some/Service)] org.apache.sling.event.jobs.audit ASSIGN OK bb92b672-1b0d-4fe8-bf5e-9194a934f249 : 2019/3/20/11/15/bb92b672-1b0d-4fe8-bf5e-9194a934f249_50
20.03.2019 11:15:00.263 DEBUG [sling-threadpool-15f9e0b4-a24d-4b0d-bf4a-433ec604e41d-(apache-sling-job-thread-pool)-27-<main queue>(com/some/Service)] org.apache.sling.event.jobs.audit ADD OK topic=some/job/topic, properties={spreadsheet=com.some.project.SomeClass@7acdf4a2} : 2019/3/20/11/15/bb92b672-1b0d-4fe8-bf5e-9194a934f249_50

如何解决吊带作业处理问题?

在AEM 6.4.2和6.4.3上进行了测试

1 个答案:

答案 0 :(得分:4)

问题是您的自定义类被禁止反序列化。实际上,禁止所有类反序列化,如here所述。您应该将要反序列化的类列入白名单。

仅当在 org.apache.sling.event.impl 而不是 org.apache.sling.event上创建调试记录器时,才会看到

特定的 RuntimeException 。职位

*DEBUG* [sling-default-137-Registered Service.4303] org.apache.sling.event.impl.jobs.queues.QueueJobCache Unable to read resource.
java.lang.UnsupportedOperationException: Deserialization not allowed for class TestEnum
    at org.kantega.notsoserial.DefaultNotSoSerial.preventDeserialization(DefaultNotSoSerial.java:256)
    at org.kantega.notsoserial.DefaultNotSoSerial.onBeforeResolveClass(DefaultNotSoSerial.java:248)
    at org.kantega.notsoserial.ObjectInputStreamClassVisitor.onBeforeResolveClass(ObjectInputStreamClassVisitor.java:48)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1868)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1751)
    at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1994)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1570)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:431)
    at org.apache.sling.jcr.resource.internal.helper.JcrPropertyMapCacheEntry.convertToType(JcrPropertyMapCacheEntry.java:330) [org.apache.sling.jcr.resource:3.0.8]
    at org.apache.sling.jcr.resource.internal.helper.JcrPropertyMapCacheEntry.convertToType(JcrPropertyMapCacheEntry.java:231) [org.apache.sling.jcr.resource:3.0.8]
    at org.apache.sling.jcr.resource.internal.JcrValueMap.get(JcrValueMap.java:105) [org.apache.sling.jcr.resource:3.0.8]
    at org.apache.sling.event.impl.support.ResourceHelper.cloneValueMap(ResourceHelper.java:203) [org.apache.sling.event:4.2.10]
  at org.apache.sling.event.impl.jobs.Utility.readJob(Utility.java:181) [org.apache.sling.event:4.2.10]


Here是捕获此异常的代码行。