I have set up ActiveMQ as an embedded broker (from this tutorial), and now I want to add a new application, in a different EAR, which needs a new queue.
Has anyone been able to do this?
If I try making two resource adapters in my standalone.xml, they end up using the same broker-config, and I get the error below. So that doesn't seem right.
Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [broker-config.xml]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.apache.activemq:type=Broker,brokerName=brokerOne
Related
I am trying to use Spring Boot Actuator to restart the spring to update its newest properties.
I followed this tutorial:
https://javapointers.com/spring/spring-boot/how-to-restart-spring-boot-automatically-using-actuator/
So what I did is just to add the properties
management.endpoint.restart.enabled=true
management.endpoints.web.exposure.include=restart,health
and call the endpoint
{host}/actuator/restart
I tested it on my local using the embedded tomcat server, and it works.
But when I tried it in jboss/wildfly, because my client are using it for their production server, it doesn't work.
This is the error that I got:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is java.lang.IllegalStateException: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3aa3a991 has been closed already
Please let me know if there is something else that I need to provide.
Maybe You could take a look at Spring Cloud Config to solve properly your problem : Spring Cloud Config
It allow you to externalize properties, manage them and expose them to clients (like your application).
And it has some benefits like 'No restart needed'
OK - problem ==> 2 Datasources (or more) will cause an error when using Springboot Session.
I have a Springboot project, with different data sources for different purposes. So within said project I would like to have Spring replace the HttpSession, with the Spring-Session module's HttpSession.
The creation of the session tables is simple if you follow the guides.
But the guides and API docs say you need JUST one data source. And so, since I have 2 or more I get the following error:
2020-07-21 21:38:59.134 ERROR 171262 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter :
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException.
Message: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource
[org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]:
Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException:
No qualifying bean of type 'javax.sql.DataSource' available:
expected single matching bean but found 2: authModelDs,secureSessionDS
So since it cannot decide which one to use, I have to manually configure it, except that the entire process leads you to a class called
org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration, which is quite literally non-configurable under the given need to set your own datasource.
I have looked a bit around, and there is no way to configure the Session Filter, once it is created to replace the datasource there too.
So I am boggled: how can I set the correct datasource for the configured Spring-Session?
Any help would be appreciated.
AHA! Soooooo
There is an annotation that you can place on the Bean creation of your datasource, to specify that such a bean is the SpringBoot session datasource.
The annotation is - #SpringSessionDataSource
It is not something that is really straight forward in the documentation at all!
Props to the following Stack Overflow answer:
Spring Boot and Spring Session: How to control the DataSource
I am getting this exception when I am trying to read message from WebSphere MQ via MDB, can any one please guide me.When I deploy the EAR file on my WebSphere then it works flawlessly but I am getting exception on a different WebSphere. Am I missing something in configuration, why does this exception occur?
javax.ejb.EJBException: Injection failure; nested exception is: java.lang.IllegalArgumentException: Can not set javax.jms.ConnectionFactory field com.ultramatics.hawkeye.mdb.listener.HawkeyeMdbListener.replyCF to com.ibm.mq.jms.MQQueue
You are obviously trying to assign a ConnectionFactory field with a MQQueue object, two different types.
I guess you grab them from JNDI or similar and that there might be some naming mess up in the configuration?
I am just curious to know when a Spring.xml file loaded into application multiple times into an application using ClassPathXmlApplicationContext. For example if I want to get the services defined in Spring.xml into my claases by creating new instance of ApplicationContext in each class . Does this approach create each time new beans without destroying the previously created beans?Does this creates any memory problems ? When I see in ClassPathXmlApplicationContext API in spring website I found this.Does this refresh creates new bean definition of existing bean by destroying existed one?
ClassPathXmlApplicationContext(String... configLocations)
***Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context.***
When the same xml file is loaded several times spring creates the same beans several times. In most cases this does not cause problems except initiation time. But sometimes you can get conflicts. For example if you have bean that is listening to TCP port and then open yet another bean that tries to connect to the same port it fails.
I want to deploy the same .war file to two different virtual hosts on the same Tomcat 6 instance. However, I am running into a problem with the Spring framework and registering a bean. Here is the error I am seeing...
org.springframework.jmx.export.UnableToRegisterMBeanException:
Unable to register MBean
[com.dti.servlets.Configuration#3a1834]
with key 'EAM:name=webConfig'; nested
exception is
javax.management.InstanceAlreadyExistsException:
EAM:name=webConfig
I am pretty sure that I need to define my contexts for each virtual host but I am not having any luck. The only fix I have found that works is to change the name of the bean key. Any other suggestions would be great.
The problem is that the name of the bean must be unique per JVM. Since you're deploying the same war twice, you have two solutions:
change the registration behaviour of the Spring JMX exporter (see the documentation)
define your own ObjectNamingStrategy to dynamically change the name of the beans at startup (you would end up with names like app1.mybean and app2.mybean)