Hi all,
Been having a heck of a time figuring out how to resolve an issue I have been seeing. Can't find anything on the web similar to it.
Using Springframework version 3.0.5.RELEASE
The offending line of code is:
This is being called from a static method of the JMXClient class itself (Not sure if that matters, including this just in case)Code:JMXClient myJMXConnectionInfo = myApplicationContext.getBean("jmx.client", JMXClient.class);
This results in:
JMXClient bean is defined as:Code:Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bea n named 'jmx.client' must be of type [com.thecompany.cds.common.jmx.JMXClient], but was actually of type [com.thecompany.cds.common.jmx.JMXClient] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:349) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBea n(AbstractApplicationContext.java:1079) at com.thecompany.cds.common.jmx.JMXClient.getRemoteJobRunner(JMXClient.java :28)
The code for JMXClient is just getters and setters for the properties, the class just exists to wrap JMX properties and has a static method for retreiving remote beans.Code:<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="placeholderPrefix" value="$simple-jmx-client{" /> <property name="locations"> <list> <value>classpath:common-jmx/simple-jmx-client.properties</value> </list> </property> </bean> <bean id="jmx.client" class="com.thecompany.cds.common.jmx.JMXClient" > <property name="url" value="$simple-jmx-client{jmx.url}" /> <property name="username" value="$simple-jmx-client{authorization.username:test}" /> <property name="password" value="$simple-jmx-client{authorization.password:test}" /> </bean>
(I realize creating a new ClassPathXMLApplicationContext each time is stupid, I will be refactoring this class after I figure out this issue.)Code:public class JMXClient { protected static final Logger LOGGER = LoggerFactory.getLogger(JMXClient.class); private String url; private String username; private String password; static String XML_PATH = "classpath:common-jmx/spring/simple-jmx-client.xml"; public static <S> S getRemoteBean(String objectName, Class<S> clazz) { ClassPathXmlApplicationContext myApplicationContext = new ClassPathXmlApplicationContext(XML_PATH); JMXClient myJMXConnectionInfo = myApplicationContext.getBean(JMXClient.class); ... } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; }
If anyone has any idea what could be going on I would appreciate some help immensely. My thinking is there must be some kind of class version issue froma potential transitive dependency, but thatis really just a shot in the dark.
This code is being called from a Maven Mojo I am working on. I have created an isolated class loader for the thread that calls this method that has the entire runtime classpath and test classes classpath as well as our conf directory.


Reply With Quote