Based on the aforementioned forum topic we have a hack work-around that seems to work. I
feel funny about mucking around with the ClassLoaders directly, but I suspect that the
JBossMQ previously did something to this effect anyway since the old code worked properly
with JBoss 4.0.5 using JBossMQ.
| public void onMessage ( final Message message )
| {
| if( message instanceof ObjectMessage )
| {
| // todo: remove this classloader hack if it becomes un-necessary
| final ClassLoader original =
Thread.currentThread().getContextClassLoader();
| try
| {
| Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader() );
| final ObjectMessage objectMessage = (ObjectMessage)message;
| final Serializable payload = objectMessage.getObject();
| if( payload instanceof TypedData )
| {
| m_incomingQueue.add( (TypedData)payload );
| }
| }
| catch( JMSException e )
| {
| m_handler.onConnectionException( new ConnectionException( e ) );
| }
| finally
| {
| Thread.currentThread().setContextClassLoader(original);
| }
| }
| }
|
Has anyone else had to do something like this? If so did you encounter any gotchas that
we should be aware of? It looks safe enough, but it seems hackish and has a slightly
unpleasant code smell about it...
Thanks,
--Zack
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4230225#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...