[Quickfix-users] Quickfix 1.3 - Classloader problems with RMI-based JMX call
Brought to you by:
orenmnero
From: <mat...@hs...> - 2007-12-19 12:59:20
|
Hi, We currently have a problem with the latest release of QuickfixJ 1.3 and wonder if you could throw some light on this please. We have a set of adapters which connect to various FIX-based ECNs, and these are deployed together in a single web application. Each adapter is wrapped via Spring's MBeanExporter to be manageable, supporting start() and stop() operations. On the startup of the webapp, each adapter's start() method is invoked: all adapters start successfully. However, if we stop then restart an adapter through the JMX interface we have, an exception results: : Caused by: quickfix.ConfigError: error during session initialization at quickfix.mina.initiator.AbstractSocketInitiator.createSessions(AbstractSocketInitiator.java:138) at quickfix.mina.initiator.AbstractSocketInitiator.<init>(AbstractSocketInitiator.java:77) at quickfix.mina.initiator.AbstractSocketInitiator.<init>(AbstractSocketInitiator.java:67) at quickfix.SocketInitiator.<init>(SocketInitiator.java:47) at com.somebank.imt.trading.fix.FixClientApplication.getConnector(FixClientApplication.java:117) at com.somebank.imt.trading.fix.FixApplication.start(FixApplication.java:175) ... 38 more Caused by: java.lang.IllegalArgumentException: interface quickfix.SessionStateListener is not visible from class loader at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353) at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581) at quickfix.ListenerSupport.<init>(ListenerSupport.java:35) at quickfix.Session.<init>(Session.java:249) at quickfix.DefaultSessionFactory.create(DefaultSessionFactory.java:159) at quickfix.mina.SessionConnector.createSession(SessionConnector.java:112) at quickfix.mina.initiator.AbstractSocketInitiator.createSessions(AbstractSocketInitiator.java:132) ... 43 more I looked at the 1.3 source, in quickfix.ListenerSupport the following code is executed. (You are creating a dynamic proxy to override the toString implementation) @SuppressWarnings("unchecked") public ListenerSupport(Class<?> listenerClass) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); multicaster = Proxy.newProxyInstance(classLoader, new Class<?>[] { listenerClass }, new ListenerInvocationHandler()); } This is called from the quickfix.Session class when it is constructed: private final ListenerSupport stateListeners = new ListenerSupport(SessionStateListener.class); The first time this is invoked, we are in the context of a webapp classloader, so SessionStateListener is loaded into this classloader within Tomcat's classloader hierarchy. The second time this is invoked, we are in the context of an RMI JMX call. As such the context classloader off the thread is the classloader which has loaded the MBeanServer implementation, which is part of rt.jar. By this time SessionStateListener has been loaded into the webapp classloader though which is not visible to the other classloader higher in the hierarchy so our restart fails. Could you let us know how to fix this please? We do not want to lift all quickfix-based stuff higher in the hierarchy since we want our application to remain deployable as a single webapp-based unit. One other point, I notice that there is only one implementation of SessionStateListener (namely SessionAdmin): is there a good reason to load this from the context of the calling thread. Can you not do this.getClass().getClassLoader() instead? You cannot do this from within the constructor, but maybe you could have a postInit() type method where you would be able to do this. Without this, other people will face the same issue we do. Any help is greatly appreciated and if I have missed something out or am incorrect in my assumptions then many apologies! Thanks very much for your help on this and sorry for the long mail. Thanks, Matt ************************************************************ HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest. HSBC Bank plc Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom Registered in England - Number 14259 Authorised and regulated by the Financial Services Authority. ************************************************************ ----------------------------------------- SAVE PAPER - THINK BEFORE YOU PRINT! This transmission has been issued by a member of the HSBC Group "HSBC" for the information of the addressee only and should not be reproduced and/or distributed to any other person. Each page attached hereto must be read in conjunction with any disclaimer which forms part of it. Unless otherwise stated, this transmission is neither an offer nor the solicitation of an offer to sell or purchase any investment. Its contents are based on information obtained from sources believed to be reliable but HSBC makes no representation and accepts no responsibility or liability as to its completeness or accuracy. |