[
https://issues.apache.org/activemq/browse/SM-1329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42438#action_42438
]
Ron Gavlin commented on SM-1329:
--------------------------------
Guillaume,
I tried your suggestion of explicitly settinging the TCCL without success.
The only way I was able to successfully work-around this problem was to
re-factor the SplitterAggregation inner class into its own class and put it in
its own eip-support.jar in the SMX_HOME/lib container classloader directory. As
you know, the SplitterAggregation originally existed in the component
classloader while the JdbcStore exists in the container classloader. When
JdbcStore.load() is invoked, it needs access to all the classes required to
de-serialize the MessageExchange byte array input stream, including the
SplitterAggregation class. It appears the TimerManagerImpl thread which invokes
the JdbcStore.load() can't see the SplitterAggregation inner class. By moving
the class explicitly into the same classloader as the JdbcStore itself, the
problem disappears.
I am sure you will agree that storing the SplitterAggregation Serializable
class in an eip-centric jar on the container classpath is less than desirable.
If you have a better suggestion, please share it. The changes I applied to
work-around this problem are listed below. Your feedback is greatly appreciated.
- Ron
Index: src/main/java/org/apache/servicemix/eip/patterns/SplitAggregator.java
===================================================================
--- . (revision 651487)
+++ . (working copy)
@@ -16,7 +16,6 @@
*/
package org.apache.servicemix.eip.patterns;
-import java.io.Serializable;
import java.util.Date;
import javax.jbi.messaging.MessageExchange;
@@ -194,7 +193,7 @@
*/
public boolean addMessage(Object aggregation, NormalizedMessage message,
MessageExchange exchange)
throws Exception {
- NormalizedMessage[] messages = ((SplitterAggregation)
aggregation).messages;
+ NormalizedMessage[] messages = ((SplitterAggregation)
aggregation).getMessages();
// Retrieve count, index
Integer cnt = (Integer) SplitAggregator.this.count.evaluate(exchange,
message);
if (cnt == null) {
@@ -203,7 +202,7 @@
}
if (messages == null) {
messages = new NormalizedMessage[cnt];
- ((SplitterAggregation) aggregation).messages = messages;
+ ((SplitterAggregation) aggregation).setMessages(messages);
} else if (cnt != messages.length) {
throw new IllegalArgumentException("Property " +
AbstractSplitter.SPLITTER_COUNT
+ " is not consistent (received " + cnt + ", was " +
messages.length + ")");
@@ -236,8 +235,8 @@
*/
public void buildAggregate(Object aggregation, NormalizedMessage message,
MessageExchange exchange, boolean doTimeout) throws Exception {
- NormalizedMessage[] messages = ((SplitterAggregation)
aggregation).messages;
- String correlationId = ((SplitterAggregation)
aggregation).correlationId;
+ NormalizedMessage[] messages = ((SplitterAggregation)
aggregation).getMessages();
+ String correlationId = ((SplitterAggregation)
aggregation).getCorrelationId();
SourceTransformer st = new SourceTransformer();
Document doc = st.createDocument();
Element root = createChildElement(aggregateElementName, doc);
@@ -281,52 +280,4 @@
return null;
}
- /**
- *
- * @author gnodet
- */
- protected static class SplitterAggregation implements Serializable {
-
- /**
- * Serial version UID
- */
- private static final long serialVersionUID = 8555934895155403923L;
-
- protected NormalizedMessage[] messages;
- protected String correlationId;
-
- public SplitterAggregation(String correlationId) {
- this.correlationId = correlationId;
- }
-
- /**
- * @return the correlationId
- */
- public String getCorrelationId() {
- return correlationId;
- }
-
- /**
- * @param correlationId the correlationId to set
- */
- public void setCorrelationId(String correlationId) {
- this.correlationId = correlationId;
- }
-
- /**
- * @return the messages
- */
- public NormalizedMessage[] getMessages() {
- return messages;
- }
-
- /**
- * @param messages the messages to set
- */
- public void setMessages(NormalizedMessage[] messages) {
- this.messages = messages;
- }
-
- }
-
}
Index: src/main/java/org/apache/servicemix/eip/patterns/SplitterAggregation.java
===================================================================
--- src/main/java/org/apache/servicemix/eip/patterns/SplitterAggregation.java
(revision 0)
+++ src/main/java/org/apache/servicemix/eip/patterns/SplitterAggregation.java
(revision 0)
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.eip.patterns;
+
+import java.io.Serializable;
+
+import javax.jbi.messaging.NormalizedMessage;
+
+/**
+ *
+ * @author gnodet
+ */
+public class SplitterAggregation implements Serializable {
+
+ /**
+ * Serial version UID
+ */
+ private static final long serialVersionUID = 8555934895155403923L;
+
+ protected NormalizedMessage[] messages;
+ protected String correlationId;
+
+ public SplitterAggregation(String correlationId) {
+ this.correlationId = correlationId;
+ }
+
+ /**
+ * @return the correlationId
+ */
+ public String getCorrelationId() {
+ return correlationId;
+ }
+
+ /**
+ * @param correlationId the correlationId to set
+ */
+ public void setCorrelationId(String correlationId) {
+ this.correlationId = correlationId;
+ }
+
+ /**
+ * @return the messages
+ */
+ public NormalizedMessage[] getMessages() {
+ return messages;
+ }
+
+ /**
+ * @param messages the messages to set
+ */
+ public void setMessages(NormalizedMessage[] messages) {
+ this.messages = messages;
+ }
+
\ No newline at end of file
> SplitAggregator$SplitterAggregation ClassNotFoundException on
> JdbcStore.load() invocation
> -----------------------------------------------------------------------------------------
>
> Key: SM-1329
> URL: https://issues.apache.org/activemq/browse/SM-1329
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-core
> Affects Versions: 3.2.1
> Reporter: Ron Gavlin
> Priority: Critical
> Attachments: jndi.xml, TestStore_v_0-sa.zip
>
>
> I have a process flow with an EIP RecipientListAggregator that generates a
> ClassNotFoundException on JdbcStore.load(). The error is listed below. I have
> attached my test service assembly for your review. Any assistance you can
> provide is appreciated.
> - Ron
> 00:35:02,357 | ERROR | pool-flow.seda.servicemix-eip-thread-2 | EIPComponent
> | ervicemix.common.BaseLifeCycle 48 | Error processing exchange
> InOnly[
> id: ID:10.10.10.10-1197eb63a39-3:1
> status: Active
> role: provider
> service:
> {urn:eng:spagic:processes:TestStore:v0}TestStore.EndRecipientList_v_0
> endpoint: TestStore.EndRecipientList_v_0
> in: <?xml version="1.0" encoding="UTF-8"?><test>hello world</test>
> ]
> java.lang.NullPointerException
> at
> org.apache.servicemix.eip.support.AbstractAggregator.processProvider(AbstractAggregator.java:149)
> at
> org.apache.servicemix.eip.support.AbstractAggregator.process(AbstractAggregator.java:134)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490)
> at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
> at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> at java.lang.Thread.run(Thread.java:595)
> 00:35:04,530 | ERROR | pool-flow.seda.servicemix-eip-thread-1 | EIPComponent
> | ervicemix.common.BaseLifeCycle 48 | Error processing exchange
> InOnly[
> id: ID:10.10.10.10-1197eb63a39-7:0
> status: Active
> role: provider
> service:
> {urn:eng:spagic:processes:TestStore:v0}TestStore.EndRecipientList_v_0
> endpoint: TestStore.EndRecipientList_v_0
> in: <?xml version="1.0" encoding="UTF-8"?><test>hello world</test>
> ]
> java.lang.NullPointerException
> at
> org.apache.servicemix.eip.support.AbstractAggregator.processProvider(AbstractAggregator.java:149)
> at
> org.apache.servicemix.eip.support.AbstractAggregator.process(AbstractAggregator.java:134)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490)
> at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
> at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> at java.lang.Thread.run(Thread.java:595)
> 00:35:04,851 | INFO | main | JDBCAdapterFactory |
> icemix.jdbc.JDBCAdapterFactory 45 | Database driver recognized:
> [mysql-ab_jdbc_driver]
> 00:35:05,061 | INFO | main | JBIContainer |
> mix.jbi.container.JBIContainer 642 | ServiceMix JBI Container (ServiceMix)
> started
> 00:35:08,015 | INFO | main | JDBCAdapterFactory |
> icemix.jdbc.JDBCAdapterFactory 45 | Database driver recognized:
> [apache_derby_embedded_jdbc_driver]
> 00:35:08,456 | INFO | main | LogTask |
> servicemix.jbi.logging.LogTask 58 | Logging system reconfigured using file:
> file:conf/log4j.xml
> 00:35:23,057 | ERROR | pool-flow.seda.servicemix-eip-thread-1 | EIPComponent
> | ervicemix.common.BaseLifeCycle 48 | Error processing exchange
> InOnly[
> id: ID:10.10.10.10-1197eb63a39-7:1
> status: Active
> role: provider
> service:
> {urn:eng:spagic:processes:TestStore:v0}TestStore.EndRecipientList_v_0
> endpoint: TestStore.EndRecipientList_v_0
> in: <?xml version="1.0" encoding="UTF-8"?><test>hello world</test>
> ]
> java.io.IOException: Error storing object
> at org.apache.servicemix.store.jdbc.JdbcStore.load(JdbcStore.java:85)
> at
> org.apache.servicemix.eip.support.AbstractAggregator.processProvider(AbstractAggregator.java:152)
> at
> org.apache.servicemix.eip.support.AbstractAggregator.process(AbstractAggregator.java:134)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490)
> at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
> at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.servicemix.eip.patterns.SplitAggregator$SplitterAggregation
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at
> org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
> at
> org.codehaus.classworlds.DefaultClassRealm.loadClassDirect(DefaultClassRealm.java:412)
> at
> org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:376)
> at
> org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:242)
> at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:585)
> at
> java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
> at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
> at org.apache.servicemix.store.jdbc.JdbcStore.load(JdbcStore.java:80)
> ... 12 more
> 00:35:26,712 | INFO | Timer-6 | AbstractAggregator |
> eip.support.AbstractAggregator 223 | Caught exception while processing
> timeout aggregation
> java.io.IOException: Error storing object
> at org.apache.servicemix.store.jdbc.JdbcStore.load(JdbcStore.java:85)
> at
> org.apache.servicemix.eip.support.AbstractAggregator.onTimeout(AbstractAggregator.java:212)
> at
> org.apache.servicemix.eip.support.AbstractAggregator$1.timerExpired(AbstractAggregator.java:177)
> at
> org.apache.servicemix.timers.impl.TimerManagerImpl$TimerImpl.run(TimerManagerImpl.java:83)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.servicemix.eip.patterns.SplitAggregator$SplitterAggregation
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at
> org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
> at
> org.codehaus.classworlds.DefaultClassRealm.loadClassDirect(DefaultClassRealm.java:412)
> at
> org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:376)
> at
> org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:242)
> at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:585)
> at
> java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
> at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
> at org.apache.servicemix.store.jdbc.JdbcStore.load(JdbcStore.java:80)
> ... 5 more
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.