jboss,jms,spring-jms,jmstemplate , JmsTemplate and CachingConnectionFactory

JmsTemplate and CachingConnectionFactory


Tag: jboss,jms,spring-jms,jmstemplate

I'm finding some difficulties in trying to reduce the connection and session creation when sending messages to a Jboss Queue.

<bean name="jbmTemplate-${jbmQueue}" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
        <property name="sessionTransacted" value="true" />

    <!-- connection factory -->
    <property name="connectionFactory">
        <ref bean="jbmCachingConnectionFactory"/>

    <property name="pubSubDomain">

    <property name="receiveTimeout">


I'm using a JmsTemplate to send messages:

<bean id="jbmCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
     <property name="targetConnectionFactory" ref="jbmConnectionFactory" />

And the jbmConnectionFactory is defined as follow:

<jee:jndi-lookup id="jbmConnectionFactory" jndi-name="XAConnectionFactory"
        resource-ref="true" lookup-on-startup="false" proxy-interface="javax.jms.ConnectionFactory"

I'm using this piece of code to send messages to Jboss:

public void send(final Serializable payload, final String correlationId) {
    log.debug("payload: {}", payload);

    try {
        jmsQueueTemplate.send(destinationName, new MessageCreator() {
            public Message createMessage(Session session)
                    throws JMSException {
                ObjectMessage msg = session.createObjectMessage(payload);


                return msg;

    } catch (Exception e) {
        log.error("Couldn't send message");
        throw new BlockingException(e);

What I was trying to do by using the CachingConnectionFactory is to avoid creating and closing connections and sessions every message I send but as far as I can see, when using a JmsTemplate, no matter what type of connectionFactory I use, the connection and session will always be terminated:

finally {
            ConnectionFactoryUtils.releaseConnection(conToClose, getConnectionFactory(), startConnection);

Am I calling the wrong method? Is there something that I don't get?


The CachingConnectionFactory returns a proxy (wrapper) for the connection which ignores the close(). Similarly, session.close() is intercepted and the session is put in the cache instead of actually closing it.

In fact, it requires the session to be "closed" so the session can be made available for the next use.

You may need to configure the cache size (it's only 1 by default; see the javadocs).


Cannot enable a .war in JBoss AS 7.1

I have a problem while enabling the .war project in JBoss AS, here is the log from standalone/log/server.txt 18:57:51,727 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "booking-war.war" 18:58:15,025 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.unit."booking-war.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."booking-war.war".PARSE: Failed to process...

Sync jboss modules and jbossdatahome between devs

We're using local jboss 7 instances (maven jboss plugin) with custom modules for local development. Each dev can work on multiple projects. For each project, each dev needs to have the proper jboss modules and jbossdatahome folder. Each dev needs the same path to these folders, as they are hard...

java.lang.AbstractMethodError: org.jboss.arquillian.config.descriptor.impl.EngineDefImpl.getDeploymentExportExploded()Ljava/lang/Boolean;

When I try to deploy my artifact during integration test I'm getting this error. @RunWith(ArquillianSputnik) class WebServiceTest extends Specification { @Deployment static WebArchive createDeployment() { ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/project.war")) } } where arquillian.xml is: <arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian...

In a JavaEE stateless session bean, why is the SessionContext responsible for rolling transactions back and not the EntityManager?

To me (someone who is new to JavaEE development), I would think that a container managed EntityManager would be responsible for rolling back failed transactions and not a SessionContext instance. Suppose the following scenario... @Stateless public class MySessionBean implements MySessionBeanRemoteInterface { @PersistenceContext(unitName="MYPu") private EntityManager em; @Resource private SessionContext sctx; @Override...

Spring - configure Jboss Intros for xml with java config?

I'm in the process of writing a spring web app and want to convert my objects to xml without annotations. I know with xml config you can do this: <bean id="jaxb2Marshaller" class="software.bytepushers.userprofile.models.JaxbIntroductionsMarshaller"> <property name="classesToBeBound"> <list> <value>software.bytepushers.userprofile.models.Person</value> <value>software.bytepushers.userprofile.models.WebServiceResponse</value> </list> </property> <property...

How to Produce from MQTT and consume as MQTT and JMS in ActiveMQ

I have a setup where messages are produced as MQTT to ActiveMQ. I have two consumers one as JMS and another MQTT. When I am publishing message as JMS Message to the topic "foo", I am receiving the messages at both JMS and MQTT consumers, but when I am publishing...

JMS Broker receives the message as null

I have a C++ component which passes message to JMS broker via tcp using ActiveMQ. My broker is written in JAVA. I want these two to communicate; to C++ component send messages to the JAVA broker. On C++ side what I am doing is creating a message (using protocol buffer),...

How to deploy WildFly datasource with Arquillian?

I tried to deploy my datasource as follows: @Deployment(name = "test", order=2) static WebArchive createDeployment() { ShrinkWrap.createFromZipFile(WebArchive, new File("target/test.war")).addAsWebInfResource(new File("src/test/resources/test-DS.xml"), "test-DS.xml") } but it seems that my datasource is ignored, I see no info about deployment in jboss console. Is there any other possibility to deploy datasource with arquillian? @Deployment(name...

@Resource datasource breaking DB connection

I recently wrote a class, in my web application, for parsing a huge XML file and feed a db table with its content. My application is running on Wildfly9, and uses JPA with Hibernate provider to handle a MySQL DB. The AS configuration is pretty standard, I just added my...

How to load config.properties file in a Seam Application using web.xml context-param

I have a seam web application in which I have to include a security module for integrated authentication. I can see that the module isn't based on seam application because it uses a spring-like notation. As the module works defining a listener and a properties file in the web.xml I...

ActiveMQ http connection error

I am trying to connect my java client application to ActiveMQ over http, but keep getting an error: (complete error at the bottom) javax.jms.JMSException: Could not post command: ProducerInfo No such field org.apache.activemq.command.ProducerInfo.sentCount Also, there is connection to ActiveMQ, because the server also produces an error: (complete error at the...

How to set external folders in classpath through command line while starting wildfly server

I want to set external folders in classpath through command line while starting wildfly server. Unable to set it through -p standalone.sh -p path of folder ...

org.apache.catalina.realm.RealmBase.java file located in Jboss EAP 6.3

I tried to run simple Web APP in JBoss EAP 6.3 and from the log and I saw DEBUG [org.apache.catalina.realm] (http-/ User data constraint has no restrictions This logging message is from org.apache.catalina.realm.RealmBase.java I would like to know, where does this file located in EAP 6.3? Which jar file? I...

Refactoring some legacy camel code, is this code unnecessary or am I missing something?

I'm refactoring some apache camel legacy code in a JBoss Fuse instance and I've run into some code that I'm not sure what it's purpose is for. <when condition> <loadBalance id="someVar"> <failover roundRobin="true" maximumFailoverAttempts="3" /> <to uri="fabric:FABRICENDPOINT" /> </loadBalance> </when> I haven't used Fabric's load balancer before but from what...

JMS Message Selector does not work

I have a requirement to filter message based on the Message selector but it seems the consumer with messageSelector is not filtering any message. I have written below code ActiveMQUtil import org.apache.activemq.ActiveMQConnectionFactory; import javax.jms.*; public class ActiveMQUtil { private ConnectionFactory connectionFactory = null; private Connection connection =null; private Session session...

Valid “protocols” for HornetQ

I have some code like this for connecting to HornetQ. Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); properties.put(Context.PROVIDER_URL, "remote://"); properties.put(Context.SECURITY_PRINCIPAL, "user"); properties.put(Context.SECURITY_CREDENTIALS, "pwd"); ConnectionFactory connectionFactory = null; Destination destination = null; try { Context context = new InitialContext(properties); I inherited this, and am trying to get a...

Restricting access to particular URL for sesame server deployed on JBoss (WildFly 8.2)

I have a sesame server running deployed in a WildFly 8.2.0 final container. How can I restrict access to some particular URLs? I know I have to edit some XML files (deployment descriptor and some other files) but I don't know which files and where to find them....

Does JBoss 7.x Support J2EE 5.0 and EJB 2.0?

I have an application build on J2EE EJB 2.0 deployed on JBoss 5.1.0. I want to migrate that application to JBoss 7. Does JBoss 7.x Support J2EE 5.0 and EJB 2.0? If Yes, then how to Migrate Jboss 5.1.0 to JBoss 7.x?

Does Bluemix include a JBoss runtime?

How can I create a JBoss runtime on Bluemix? The JBoss buildpack for Cloud Foundry does not support all features. The current buildpack is focused on running web applications in the servlet container and nothing further. Are there more docs on this and any updates on the plans going forward,...

Connecting remote JBoss-eap-6.2 to pass message in java

Code runs without any problem up to creating connection factory but it cannot create topic connection. When creating topic connection it throws following exception.(My code is for creating publisher and subscriber) Here is the terminal output I received, Jun 03, 2015 10:51:55 AM org.xnio.Xnio <clinit> INFO: XNIO Version 3.0.7.GA-redhat-1 Jun...

How to set HttpServletResponse on Jboss EAP 6.2?

I have a simple method where I need to change the contentType to "text/plain" but when I am using Jboss EAP 6.2 it is ignored and the returned value is "application/json. @RestController @RequestMapping("/upload") public class UploadController { ... @RequestMapping(method = RequestMethod.POST) public Result foo(MultipartFile arquivo, HttpServletResponse response) { response.setContentType("text/plain"); return...

Deploye two wars with different domain name but same context-path in same jboss-4.0.3

I've two web application wars STORE_ABC.war and STORE_DEF.war and single JBoss server running on my machine. I want to deploye both war with same context path in my jboss as follows. http://localhost:8080/home For STORE_ABC.war http://testsite1:8080/home For STORE_DEF.war jboss-web.xml for STORE_ABC.war and STORE_DEF.war <jboss-web> <context-root>/</context-root> </jboss-web> How could I achieve above...

Failed to execute goal on project. Unable to find POM in project

I am trying to build an application having following dependency. <properties> <version.jboss.as>7.5.0.Final-redhat-21</version.jboss.as> </properties> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-jms-client-bom</artifactId> <version>${version.jboss.as}</version> <type>pom</type> </dependency> </dependencies> This is an example which i found on Red Hat Site -...

How to get JBoss 7.1.3 to use my $JAVA_HOME environment varaible?

I'm using Mac 10.9.5 with JBoss 7.1.3.Final. I am launching JBoss through the termianl (bash shell), like so Daves-MacBook-Pro:core davea$ cd $JBOSS_HOME/bin Daves-MacBook-Pro:bin davea$ sudo sh standalone.sh Within the shell, I can see that $JAVA_HOME is defined ... Daves-MacBook-Pro:bin davea$ echo $JAVA_HOME /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home However, JBoss is not picking up this...

Javamail ClassCastException when sending multipart messages

I am getting the following exception when attempting to send a multipart message: java.lang.ClassCastException: com.sun.xml.internal.ws.encoding.StringDataContentHandler cannot be cast to javax.activation.DataContentHandler at javax.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:609) at javax.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:563) at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:625) at...

What does vm prefix mean in the address line?

I'm going through the Apache ActiveMQ example and faced the vm prefix as follows: ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); What does that mean? By the way, when I connect to the mesasge broker I basically use an address like tcp://localhost:61616....

JMS - How to correctly implement message receiver with explicit acknowledge?

The JMS API is driving me to the point of a mental breakdown.. What is the correct way to poll messages of a jms queue and explicitly acknowledge that each message has been processed correctly? Should I create a "transacted session" and which acknowledge mode is the correct one in...

Error while setting targetConnectionFactory in UserCredentialsConnectionFactoryAdapter Spring 4

We are receiving a compilation error in the following code, while trying to set the targetConnectionFactory. According to the example given in Spring 4 documentation for UserCredentialsConnectionFactoryAdapter, the setTargetConnectionFactory() method takes the object of JndiObjectFactoryBean as an argument. But, looks like the JndiObjectFactoryBean hasn't implemented the 'ConnectionFactory' interface, which is...

Understanding the JMS communication schema by example

Going through the JMS Oracle tutorial, I faced the following schema: There was also metnioned that the JMS application basically composed of the parts: JMS provider JMS clients Messages Administered objects I'd like to understand that communication schema by a concrete example. Assume that we have two web applications running...

Wildfly Kafka clients module javax/management/JMException not found

I'm try to create Kafka clients module for Wildfly. Here is module.xml: <?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.0" name="org.apache.kafka.clients"> <resources> <resource-root path="kafka-clients-"/> <resource-root path="lz4-1.2.0.jar"/> <resource-root path="snappy-java-"/> </resources> <dependencies> <module name="org.slf4j"/> </dependencies> </module> Wildfly (8.2.0-Final) gives this error on boot:...

Configure specific SFSB stateful-timeout in standalone.xml (JBOSS)

For my JEE 3.1 application I have a SFSB for which I have set a specific timeout. I need to have easy access to this value to allow it to be easily configurable. First I had the annotation in my SFSB class: @StatefulTimeout(value = 2, unit = TimeUnit.HOURS) This works...

Spring Security Kerberos chained with basic

I have a hopefully quick question about Spring Security. I am looking for a solution to integrate security into our application which provides SSO but HTTP basic as well. One of the automated pieces of our system can only support basic authentication and we are pretty locked into it. Currently...

“Destroying connection that could not be successfully matched”

I have an application that seems to work fine, but if I browse the log files I see a lot of these kind of errors: 2015-06-04 08:23:55,656 WARN [org.jboss.resource.connectionmanager.InternalManagedConnectionPool] [DA366C7824A976BA8D1121A6E9A4F1C1.Node23] Destroying connection that could not be successfully matched: org.jboss.resource.[email protected]5d115719[state=NORMAL [email protected] handles=0 lastUse=1433398630770 permit=false trackByTx=false...

Write a Java Program to connect to HornetQ Messaging Service in Jboss EAP 6.3?

I am using Jboss EAP 6.3 and need to use Messaging facility. I have worked in Jboss 4x, where we can make connection easily using following code: public static final String PROVIDER_URL = "jnp://localhost:5445"; public static final String JNP_INTERFACES = "org.jboss.naming:org.jnp.interfaces"; public static final String INITIAL_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory"; private static...

Each SLF4J log message contains a nested message

I use JBoss 5.2 and whenever I log something, slf4j outputs a nested log message, e.g. private final static Logger logger = LoggerFactory.getLogger(MyClass.class); ... logger.info("FOOBAR") will result in the log message: 2015-06-11 09:54:37,154 INFO [STDOUT] (quartzScheduler_Worker-1) 09:54:37,154 INFO [MyClass] FOOBAR The inner message is the correct one, why does the...

Wildfly - “Connector 'netty' not found on the main configuration file”

I've added a connection factory at the standalone-full file of Wildfly: <jms-connection-factories> <connection-factory name="K19Factory"> <connectors> <connector-ref connector-name="netty"/> </connectors> <entries> <entry name="K19Factory"/> <entry name="java:jboss/exported/jms/K19Factory"/> </entries> </connection-factory> ... </jms-connection-factories> And I have the following code to use it: Properties props = new Properties();...

Adding an item to a HornetQ queue from a servlet

I have a project that gets built as a war file and deployed to a JBOSS server. The JBOSS server's standalone-full-ha.xml file is configured to create several queues. The war file uses Spring to register a class to listen to these queues, and process the messages it gets. The application...

Error while deploying ear in JBoss AS7

I am migrating EJB application from OC4j to JBoss AS7, I am able to deploy ear on JBoss, however i am getting one New missing/unsatisfied dependencies error in console, console log is mentioned below: 17:30:38,055 INFO [org.jboss.as.ejb3] (MSC service thread 1-3) JBAS014211: No jndi bindings will be created for EJB...

Does it make a sens to use JMS without Message orineted middleware?

I'm new to JMS and now trying to integrate it with my applications. I've decided to use apachemq jars at the client side. So, if I avoid the communication through the message broker ApacheMQ and communicate between the parts of the application directly, will it make a sense? Is the...

This method is not applicable inside the app server when trying to set a listener for a JMS queue

I am trying JMS 2.0 so I can decide if it is worth applying in my project. I could successfully create a send/receive application. Now I would like to have listeners that will receive the message as soon as it is available on the queue (my final goal is to...

Remote JMS communication works, EJB communication fails

I'm currently introducing myself into Java EE, especially into how to use EJB and JMS. The Issue in a Nutshell I have a local client and a remote server in the internet. JMS communication works fine, EJB communication doesn't. Either communication succeeds in my local network. The Issue in More...

Error when configuring MariaDB driver on Wildfly server

I am trying to configure a MariaDB datasource on Wildfly. This seems like it should be a simple operation, but I can't seem to get the datasource module to load properly. I have added the maria-java-client-1.1.8.jar archive and a module.xml file to the wildfly-8.2.0.Final/modules/com/mariadb/main directory. The module.xml file is as...

Set system properties in standalone-full.xml in wildfly 8.2

I have added system-properties tag in standalone-full.xml but its not working in standalone mode. But if I add the same tag in domain.xml its working for domain mode. <?xml version='1.0' encoding='UTF-8'?> <server xmlns="urn:jboss:domain:2.2"> <extensions> .... </extensions> <system-properties> <property name="java.util.Arrays.useLegacyMergeSort" value="true"/> </system-properties> </server> In this article https://docs.jboss.org/author/display/WFLY8/General+configuration+concepts Its written...

I am trying to run a war file in jboss using resteasy services but not able to do so

I am trying to run a rest easy web services on my jboss eap 6.0 server my jboss server is up and running but when I am trying to copy my war file in deployment folder of jboss it is throughing an ModuleClassLoader exception....please help me finding the solution for...

Getting R6034 error when starting Eclipse for Java EE Developers

I use Windows 7 64-bit, Java 8. I'm getting the following error: and the following screen is left behind after the process is manually terminated: I believe it started happening right after I installed a plugin from JBoss Tools - xulrunner.site - ­ Update Site that was supposed to help...

Not able to send message to Solace JMS Queue

I need to push message to Solace JMS queue Webpshere but I am getting below error during send message. I have also increase message listener size but not solved problem. Error: 503: Spool Over Quota. Message VPN limit exceeded Caused by: com.solacesystems.jcsmp.JCSMPErrorResponseException: 503: Spool Over Quota. Message VPN limit exceeded...

How To find a WebSocket from a REST bean

I have a javascript client that connects to a server via websockets and sends data via ajax to a server. Once the server finished processing the data, I want to send a message via the websocket to the client. Problem is: How do I find the WebSocket from the REST...