-
1. Re: Wildfly 9.0.2 - java.lang.ClassNotFoundException: javax.jms.ConnectionFactory
jaysensharma Jan 5, 2016 10:47 PM (in response to matt_madhavan)Looks like your WAR: "testutils-1.0-SNAPSHOT-2.war" is directly trying to access the "javax.jms" APIs hence you should add the following kind of "jboss-deployment-structure.xml" file inside your "testutils-1.0-SNAPSHOT-2.war/WEB-INF" or you can also use the "testutils-1.0-SNAPSHOT-2.war/META-INF/MANIFEST.MF" based approach to add that dependency to your WAR.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1"> <deployment> <dependencies> <module name="javax.jms.api" /> </dependencies> </deployment> </jboss-deployment-structure>
Alternatively if you have multiple applications and if you do not want to add above config inside your individual applications then you can also think about declaring Global Modules as an alternate approach:
[standalone@localhost:9990 /] /subsystem=ee:write-attribute(name=global-modules,value=[{"name" => "javax.jms.api","slot" => "main"}]) {"outcome" => "success"} [standalone@localhost:9990 /] :reload { "outcome" => "success", "result" => undefined }
Generated XML snippet will be as following:
<subsystem xmlns="urn:jboss:domain:ee:3.0"> <global-modules> <module name="javax.jms.api" slot="main"/> </global-modules> . . . </subsystem>
To know more about WildFly class loading please refer to:
https://docs.jboss.org/author/display/WFLY9/Class+Loading+in+WildFly
Regards
Jay SenSharma
-
2. Re: Wildfly 9.0.2 - java.lang.ClassNotFoundException: javax.jms.ConnectionFactory
matt_madhavan Jan 8, 2016 2:35 PM (in response to jaysensharma)Hi Jay,
I had to set the proxy inter face as follows (Line 5)
@Bean(name = "amqXaConnectionFactory") public ConnectionFactory activeMQXAConnectionFactory() { JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean(); jndiObjectFactoryBean.setJndiName(env.getProperty("jndi.name.jms.xaConnectionFactory")); jndiObjectFactoryBean.setProxyInterface(ConnectionFactory.class); // org.apache.activemq.ra.ActiveMQConnectionFactory try { jndiObjectFactoryBean.afterPropertiesSet(); // HERE - This has to // called. Sane thing // with Drools/Spring // Config } catch (IllegalArgumentException | NamingException e) { e.printStackTrace(); LOG.error("Error looking up ActiveMQ Connection Factory", e); throw new RuntimeException(e); } LOG.info("\n\n\n"); LOG.info("Connection Factory is : " + jndiObjectFactoryBean.getObject()); ConnectionFactory fac = (ConnectionFactory) jndiObjectFactoryBean.getObject(); try { fac.createConnection(); } catch (Exception e) { e.printStackTrace(); System.exit(0); } return (ConnectionFactory) jndiObjectFactoryBean.getObject(); }
And it worked ok :
How ever line 20 throws the following excption and I am stumped, Any ideas please?
org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method [public abstract javax.jms.Connection javax.jms.ConnectionFactory.createConnection() throws javax.jms.JMSException] on target [org.apache.activemq.ra.ActiveMQConnectionFactory@281b4aa]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:325) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) at com.sun.proxy.$Proxy107.createConnection(Unknown Source) at org.facs.ncdb.measuremesh.service.config.ResourcesConfig.activeMQXAConnectionFactory(ResourcesConfig.java:130) at org.facs.ncdb.measuremesh.service.config.ResourcesConfig$$EnhancerBySpringCGLIB$$6c4cf297.CGLIB$activeMQXAConnectionFactory$3(<generated>) at org.facs.ncdb.measuremesh.service.config.ResourcesConfig$$EnhancerBySpringCGLIB$$6c4cf297$$FastClassBySpringCGLIB$$cb0ad8e6.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) at org.facs.ncdb.measuremesh.service.config.ResourcesConfig$$EnhancerBySpringCGLIB$$6c4cf297.activeMQXAConnectionFactory(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
@Bean(name = "amqXaConnectionFactory")
public ConnectionFactory activeMQXAConnectionFactory() {
JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
jndiObjectFactoryBean.setJndiName(env.getProperty("jndi.name.jms.xaConnectionFactory"));
jndiObjectFactoryBean.setProxyInterface(ConnectionFactory.class); // org.apache.activemq.ra.ActiveMQConnectionFactorytry {
jndiObjectFactoryBean.afterPropertiesSet(); // HERE - This has to
// called. Sane thing
// with Drools/Spring
// Config
} catch (IllegalArgumentException | NamingException e) {
e.printStackTrace();
LOG.error("Error looking up ActiveMQ Connection Factory", e);
throw new RuntimeException(e);
}
LOG.info("\n\n\n");
LOG.info("Connection Factory is : " + jndiObjectFactoryBean.getObject());ConnectionFactory fac = (ConnectionFactory) jndiObjectFactoryBean.getObject();
try {
fac.createConnection();
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
return (ConnectionFactory) jndiObjectFactoryBean.getObject();
}