Spring Boot actuator with multiple web applications in a tomcat container throws javax.management.InstanceAlreadyExistsException exception - spring

I am running multiple spring boot applications inside a tomcat container (not embedded - just standalone tomcat container). However, it is giving me the following exceptions when launching the web applications. It is not affecting the functionality of any of the web applications, but is nevertheless something I'd like to resolve to have a clean startup.
Any help on how to fix this is highly appreciated.
Using Spring Boot 1.1.7
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean#14bee2f1] wit
h key 'metricsEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=metricsEndpoint
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:609)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.registerEndpoint(EndpointMBeanExporter.java:162)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.locateAndRegisterEndpoints(EndpointMBeanExporter.java:142)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.doStart(EndpointMBeanExporter.java:134)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.start(EndpointMBeanExporter.java:257)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:775)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:142)
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean#1be9493f] with key 'traceEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=traceEndpoint
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:609)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.registerEndpoint(EndpointMBeanExporter.java:162)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.locateAndRegisterEndpoints(EndpointMBeanExporter.java:142)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.doStart(EndpointMBeanExporter.java:134)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.start(EndpointMBeanExporter.java:257)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean#533a21cd] with key 'dumpEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=dumpEndpoint
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:609)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.registerEndpoint(EndpointMBeanExporter.java:162)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.locateAndRegisterEndpoints(EndpointMBeanExporter.java:142)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.doStart(EndpointMBeanExporter.java:134)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.start(EndpointMBeanExporter.java:257)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean#695b578c] with key 'autoConfigurationAuditEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=autoConfigurationAuditEndpoint
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:609)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.registerEndpoint(EndpointMBeanExporter.java:162)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.locateAndRegisterEndpoints(EndpointMBeanExporter.java:142)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.doStart(EndpointMBeanExporter.java:134)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.start(EndpointMBeanExporter.java:257)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.ShutdownEndpointMBean#7271ef13] with key 'shutdownEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=shutdownEndpoint
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:609)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.registerEndpoint(EndpointMBeanExporter.java:162)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.locateAndRegisterEndpoints(EndpointMBeanExporter.java:142)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.doStart(EndpointMBeanExporter.java:134)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.start(EndpointMBeanExporter.java:257)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean#34ea9086] with key 'configurationPropertiesReportEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=configurationPropertiesReportEndpoint
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:609)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.registerEndpoint(EndpointMBeanExporter.java:162)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.locateAndRegisterEndpoints(EndpointMBeanExporter.java:142)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.doStart(EndpointMBeanExporter.java:134)
at org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter.start(EndpointMBeanExporter.java:257)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)

By default all endpoints are registered under the domain org.springboot and with a default name. These can be overridden by setting endpoints.jmx.* properties. See here .
You might want to change either the domain per application or set the endpoints.jmx.unique-names to true.

Disable JMX in application.properties by adding following property
spring.jmx.enabled = false

Unique names did not work for me. I had to also add a default domain.
Here's my yml code
spring:
jmx:
default-domain: agentservice
endpoints:
jmx:
domain: agentservice
unique-names: true

spring:
jmx:
default-domain: agentservice
endpoints:
jmx:
domain: agentservice
unique-names: true
Works above config with me while deploying multiple instances on same JVM

I got this error org.springframework.jmx.export.UnableToRegisterMBeanException due to javax.management.InstanceAlreadyExistsException while deploying multiple webapps (Spring Boot in my case) on a single Tomcat server.
After some searching on the web I found this:
"With spring.jmx.enabled set to true (the default), any beans in the context that are MBeans will be automatically registered with the JMX server."
Source: https://github.com/spring-projects/spring-boot/issues/9179
Options are:
Option-1) Set spring.jmx.enabled=false
Source: https://github.com/spring-projects/spring-boot/issues/9179
Option-2) Provide unique names to JMX beans for each webapp deployed
spring.jmx.default-domain: app1
spring.jmx.default-domain: app2
Source: https://github.com/jhipster/generator-jhipster/issues/874
Option-3) Change the names of the beans itself, in each webapp
#Bean
public DataSource app1DataSource() {...}
#Bean
public DataSource app2DataSource() {...}

To augment Gondy's answer, which I voted up, below is a link that says exactly why it works. PhilWebb says "It turns out registering the JMX information by default can cause some issues if you use Spring's Test Context Framework. .. By default, tests with #ContextConfiguration keep contexts open" and "I think we need to change spring.datasource.jmx-enabled to default to false and make this one opt-in"
See GitHub (at "philwebb commented on 7 Nov 2014")
I appreciate this isnt a unique answer. but this problem has been beating me for some time, Gondy's answer helped me and then I subsequently found out why and wanted to share that extra information in the only way available to me

Related

How to disable all connection pooling in Spring Boot?

Context
By default our SpringBoot application uses HikariCP for its connection pooling.
We are currently investigating how to increase the performance of our application, and want to check out how our load tests behave when using PgPool instead.
It is our understanding that HikariCP and PgPool will not work well with each other and thus that we should be able to disable HikariCP in order to test the performance when using PgPool appropriately.
Question
How does one ensure that no connection pooling ("CP") is used at all at the application level?
Precision
The ultimate goal being to plug PgPool in between our application and our database.
It's my (potentially flawed) understanding that HikariCP should be disabled for that, and that each getConnection() call should return a new connection fetch from the JDBC URL configured for our application. And that that JDBC URL should eventually point to PgPool instead of the DB, which will take care of returning pooled connections.
Attempts
First, we simply removed Hikari from the dependencies:
configurations.all { exclude group: 'com.zaxxer' }
But we'd get this error:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.]
13:04:34.0242 - ERROR TenantId[] UserId[] TraceId[] Thread[main]
Logger[org.springframework.boot.SpringApplication]
Msg[Application run failed]
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
at com.sap.s4hana.eureka.business.centralinventory.application.Application.main(Application.java:17)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:450)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:199)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
... 8 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prometheusMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthRegistryCustomizer' defined in class path resource
...(I interrupt the stacktrace there due to company policy)
nested exception is java.lang.IllegalStateException: No supported DataSource type found
I eventually got around to adding the following to our dependencies:
implementation 'org.apache.tomcat:tomcat-jdbc:10.0.14'
But then I'm left wondering:
Does Tomcat enable CP by default? (Which would thus mean I have not effectively removed application-level CP)
Is there not a way to simply add a configuration in application.properties to keep the servlet container but avoid CP? (So that I don't need to remove Hikari from the dependencies.)
I also tried adding (inspired by this SO answer):
spring.datasource.type=org.springframework.jdbc.datasource.DriverManagerDataSource
spring.datasource.driver-class-name=org.postgresql.Driver
And also tried replacing that DriverManagerDataSource with SimpleDriverDataSource, but to no apparent avail since I cannot seem to confirm that indeed no CP is used.

Upgrading from WebLogic 12.1.3 to 12.2.1.4 breaks our application using Spring Framework 3.0.2

Our company is having us upgrade from Oracle WebLogic 12.1.3 to 12.2.1.4 since 12.1.3 is out of support/going out of support.
We have a major application that is using Spring Framework v3.0.2. When we deploy the EAR to 12.2.1.4 and attempt to consume any of the web services, we get this error stack trace. I've removed names that specify our company with generic names but you should be able to get the gist of what is happening:
2021-06-02 15:21:50.019/27.406 Oracle Coherence GE 12.2.1.4.0 (thread=[STANDBY] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Configured versioned, multi-cluster Management over ReST
02.06.2021 15:22:11 - error trying to getBean("DefaultJBL"): Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/lasor/2wlg44/lib/Lasor_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.foo.app.corebuslogic.common.exceptions.LoggedException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/app/2wlg44/lib/App_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.aep.lasor.corebuslogic.common.exceptions.LoggedException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045)
at com.foo.util.FOOApplicationContext.fetchBean(FOOApplicationContext.java:203)
at com.foo.app.buslogic.common.generic.GenericSessionBean.getBL(GenericSessionBean.java:293)
at com.foo.app.buslogic.common.generic.GenericSessionBean.query(GenericSessionBean.java:97)
I also believe the API is SOAP in 12.1.3 but I see REST specified in the 12.2.1.4 logs. Could this be the issue or am I reading that incorrectly?
Also, the classes is says it cannot find I've verified are there in the deployment area of WebLogic so I'm not sure why it can't find them.
Here is where the code throws an exception no matter what bean name I pass in but they've all been defined. The class is our FOOApplicationContext that implements org.springframework.context.ApplicationContextAware and has a fetchBean function that does the following:
public static Object fetchBean(final String beanName) throws FOOException {
Object object = null;
if (beanName == null) {
throw new FOOException("beanName is null");
}
try {
object = currentSpringContext().getBean(beanName);
} catch (Exception e) {
final String message = "error trying to getBean('"" + beanName + "\"): " + e.getMessage();
throw new FOOException(message, e);
}
return object;
}
When getBean() is called under WebLogic 12.1.3, it works. But it throws the AOP Exception error listed above when this exact same function is called under WebLogic 12.4.1.2. No code changes, etc. Not sure why this is.
We haven't created an actual server yet to deploy to, but instead I've installed it locally on my development machine. I've set up the database connections, etc the same way as do when locally installing 12.1.3. Is there something that has changed in regards to Spring Framework? The code was written over 8+ years ago and I inteherited the support for it and now I have to get us moved to WebLogic 12.2.1.4 before the end of this year and this is a major part of a very important application. The WebLogic application houses all the business logic and database access in it so without it, the front-end app is dead in the water.
Also, none of our registered beans will instantiate at all under WebLogic 12.2.1.4 but it works under 12.1.3. I've even recompiled the EAR file and again, it works under 12.1.3 but not 12.2.1.4.
I've found what appears to be a possibly circular reference between 2 objects that are not registered as beans, but the beans do depend on. So those 2 objects are not registered as beans. Not sure why it was done that way, but in any case, this doesn't seem to create a problem in 12.1.3. But one of the objects (FOOException) shows up in the error thrown when trying to create the DefaultJBL bean within the FOOApplicationContext object.
I'm not sure what else I can provide. Searching around the internet has not found a solution to my issue. I've found some that appeared as if they would fix it, but they turn out to not apply. I cannot seem to find anyone else with this issue, but Google and Duck Duck Go all find various "solutions" that don't apply to my situation.
Thanks!
ClassNotFound Exception, You may need to update the Dependencies pertaining to Spring Framework

Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object

i am trying to connect db2 from my java code in web sphere application server.
i am getting following exception.please suggest any one on this.
Caused by: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is javax.xml.stream.FactoryConfigurationError: Provider javax.xml.stream.XMLInputFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com.sun.xml.internal.stream.XMLInputFactoryImpl not a subtype] at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1232) at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:925) at com.ibm.ws.naming.jndicos.CNContextImpl.processBoundObjectForLookup(CNContextImpl.java:2877) at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:3974) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1876) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1777) at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1434) at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:616) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:165) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179) at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161) at javax.naming.InitialContext.lookup(InitialContext.java:428) at com.deere.u90.iaf.jdbc.connection.ConnectionManager.initializeEnvironment(ConnectionManager.java:276) ... 38 more Caused by: javax.xml.stream.FactoryConfigurationError: Provider javax.xml.stream.XMLInputFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com.sun.xml.internal.stream.XMLInputFactoryImpl not a subtype at javax.xml.stream.XMLInputFactory.newFactory(Unknown Source) at javax.xml.stream.XMLInputFactory.newInstance(Unknown Source) at com.ibm.websphere.product.metadata.im.IMMetadata.setHistoryEventsFromHistoryXml(IMMetadata.java:745) at com.ibm.websphere.product.metadata.im.IMMetadata.parseHistoryXmlFile(IMMetadata.java:587) at com.ibm.websphere.product.metadata.im.IMMetadata.parseInstallRegistryFiles(IMMetadata.java:399) at com.ibm.websphere.product.metadata.im.IMMetadata.(IMMetadata.java:269) at com.ibm.websphere.product.metadata.im.IMMetadata.getIMMetadataInstance(IMMetadata.java:133) at com.ibm.websphere.product.metadata.WASMetadata.parseMetadataFiles(WASMetadata.java:939) at com.ibm.websphere.product.metadata.WASMetadata.(WASMetadata.java:784) at com.ibm.websphere.product.metadata.WASMetadata.getWASMetadataInstance(WASMetadata.java:215) at com.ibm.websphere.product.WASDirectory.initMetadataInstance(WASDirectory.java:1415) at com.ibm.websphere.product.WASDirectory.getIMLogLocation(WASDirectory.java:435) at com.ibm.websphere.product.VersionInfo.printSource(VersionInfo.java:1534) at com.ibm.websphere.product.VersionInfo.printReport(VersionInfo.java:1322) at com.ibm.websphere.product.VersionInfo.runReport(VersionInfo.java:1064) at com.ibm.websphere.product.VersionInfo.runReport(VersionInfo.java:1025) at com.ibm.ws.rsadapter.spi.ServerFunction$7.run(ServerFunction.java:596) at com.ibm.ws.rsadapter.spi.ServerFunction$7.run(ServerFunction.java:590) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) at com.ibm.ws.rsadapter.spi.ServerFunction.getServerVersion(ServerFunction.java:588) at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.(WSManagedConnectionFactoryImpl.java:748) at java.lang.J9VMInternals.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1899) at com.ibm.ejs.j2c.J2CUtilityClass.createMCFEntry(J2CUtilityClass.java:468) at com.ibm.ejs.j2c.ConnectionFactoryBuilderServerImpl.createMCFandPM(ConnectionFactoryBuilderServerImpl.java:592) at com.ibm.ejs.j2c.ConnectionFactoryBuilderServerImpl.processObjectInstance(ConnectionFactoryBuilderServerImpl.java:1185) at com.ibm.ejs.j2c.ServerFunction.processObjectInstance(ServerFunction.java:2009) at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:662) at org.apache.aries.jndi.ObjectFactoryHelper.getObjectInstanceUsingObjectFactoryBuilders(ObjectFactoryHelper.java:349) at org.apache.aries.jndi.ObjectFactoryHelper.getObjectInstance(ObjectFactoryHelper.java:89) at org.apache.aries.jndi.OSGiObjectFactoryBuilder.getObjectInstance(OSGiObjectFactoryBuilder.java:62) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:311) at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1122) ... 50 more
I was facing the same issue and here was my resolution
I had wrongly spelled my jta data source in IBM Admin Console and was using a different name in my persistence xml so Websphere couldn't connect.
Please check the Resources Tab in the Admin Console and validate your jta data source name as declared in persistence xml

Birt integration in JHipster application

I'm fairly new to Jhipster and angularjs and i'm trying to integrate the Birt engine in a JHipster application using an H2 embedeed database.
I found this page that details how to integrate the birt engine in a spring application but i don't to how to applicate this for my application.
Here are the modifications performed in the jhipster project:
add dependency to org.eclipse.birt.runtime in pom
Create the classes Car, CarServiceImpl, BirtView, BirtEngineFactory and BirtDataServiceConfiguration in a sub-package report as described in the article.
I added the BirtWebConfiguration class in the sub-package config. I removed the #ComponentScan line that is already taken into account in the Application class.
I created an empty report in src/main/webapp/reports/toto.rptdesign
My problems are:
When accessing the application main page a "PageNotFound exception" with the following message "No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'dispatcherServlet'". I presume this is due to the BirtWebConfiguration that seems to overwritte the rest path configuration.
How shall I define a new rest end-point /reports ?
When accessing the http://localhost:8080/reports page, a thymeleaf exception is raised
[ERROR] org.thymeleaf.TemplateEngine - [THYMELEAF][http-nio-127.0.0.1-8090-exec-5] Exception processing template "birtView": Error resolving template "birtView", template might not exist or might not be accessible by any of the configured Template Resolvers
[ERROR] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "birtView", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "birtView", template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:245) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335) ~[thymeleaf-spring4-2.1.3.RELEASE.jar:na]
at org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring4-2.1.3.RELEASE.jar:na]
Thanks for any help.
Has the BirtView bean been created? For example, in config/LocaleConfiguration.java:
#Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/reports").setViewName("birtView");
}
#Bean
public BirtView birtView(){
BirtView birtView = new BirtView();
birtView.setDataSource(dataSource);
birtView.setAppContext(applicationContext);
birtView.setBirtEngine(this.engine().getObject());
return birtView;
}

Spring Oauth2 Provider in Grails - dependency

I want to enable OAuth2 provider in my web application, which is based on Grails 2.2.2. However I'm struggling with spring-security-oauth2-provider plugin.
spring-security-oauth2-provider plugin uses spring-security-oauth2 library. I'm trying to run plugin version 1.0.4-SNAPSHOT from Git, which uses spring-security-oauth2-1.0.4.RELEASE library.
After plugin installation, my application will not start, saying that it could not initialize "oauth2ProviderFilter" bean with this exception and stack trace:
| Error 2013-06-15 23:51:51,434 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'oauth2ProviderFilter': Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oauth2ProviderFilter': Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:153)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:170)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:127)
at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:121)
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:107)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:53)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
at java.lang.reflect.Method.getGenericParameterTypes(Method.java:291)
at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:114)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1130)
at java.beans.Introspector.getBeanInfo(Introspector.java:414)
at java.beans.Introspector.getBeanInfo(Introspector.java:161)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:217)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:142)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:324)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1242)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1101)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
After investigationg on oauth2 library documentation (here), I found out that oauth2ProviderFilter is an instance of OAuth2AuthenticationProcessingFilter. After inspecting source of this class (github), it looks like there are few properties (authenticationEntryPoint, authenticationManager, authencticationDetailsSource) that need to be instantiated. I thought that there might be a problem with dependency injection, so I tried to define oauth2ProviderFilter bean in resources.groovy with references to instances defined by Spring Security Core plugin.
I placed this in my resources.groovy:
beans = {
oauth2ProviderFilter(OAuth2AuthenticationProcessingFilter){
authenticationEntryPoint = ref('basicAuthenticationEntryPoint')
authenticationManager = ref('authenticationManager')
authenticationDetailsSource = ref('authenticationDetailsSource')
}
}
That did not solve the problem, there is still error saying that this filter can't be instantiated.
Since I'm no spring expert, do you think that this error might be connected with dependency injection during bean creation? Where might be the problem?
Is it possible that spring-security-oauth2 library is designed for spring framework version which and grails might be using different framework version and this might cause problems?
What are next steps I could take to find the cause of the problem and eventually fix the problem?
What happens when you run the release version of the plugin and not the SNAPSHOT? I found that when I work with latest versions of grails, many times they break existing plugins. So what I would do is...
Try to use release version of plugin with your 2.2.2 grails.
If that does not work, I would step back my grails version and try an older one with the released plugin.
If an older version does not work, I might be missing something in my setup, so I would try to figure out what it is.
If things work in older versions and it looks like my setup is good based on setting it up, then I would ask on the grails nabble on what is up and/or open a JIRA ticket.
Another thing to consider is how young/old the plugin is and how many previous bugs it had. We have many times either decided to debug the plugin because it was a worthwhile effort, but sometimes we decided to not use it because it had too many issues and were going to keep us back in the future.

Resources