How can I expose camel mbean in spring boot? - spring-boot

I am migrating the application from 2.23.2 to 3.1.0 version.
The application works fine having 2 routes.
But a mbean is not exposed in jconsole.
There are basic mbeans in jconsole.
- JMImplementation
- com.sun.management
- com.zaxxer.hikari
- connector
- java.lang
- java.nio
- java.util.logging
- javax.management.remote.rmi
- org.apache.logging.log4j2
- org.springframework.boot
How can I handle this issue?

You need to add a dependency to your project for camel-management. For example:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-management</artifactId>
<version>3.1.0</version>
</dependency>
There's a note about this in the Camel 3.x upgrade guide:
https://camel.apache.org/manual/latest/camel-3x-upgrade-guide.html#_spring_boot_jmx

Related

OpenTracing not activating for Sleuth-Zipkin in Spring Boot App

Spring Doc says
Spring Cloud Sleuth is compatible with OpenTracing. If you have OpenTracing on the classpath, we automatically register the OpenTracing Tracer bean. If you wish to disable this, set spring.sleuth.opentracing.enabled to false
I have the below dependency in my POM.
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-cloud-starter</artifactId>
<version>${version.opentracing.spring}</version>
</dependency>
But, I get the following print out it the logs when I try to print the trace and span information : tracer: NoopTracer
2018-11-19 12:12:03.938 [{X-B3-SpanId=4cd8eed6fe759bd1, X-B3-TraceId=5bf25b3bd0714ae54cd8eed6fe759bd1, X-Span-Export=true, spanExportable=true, spanId=4cd8eed6fe759bd1, traceId=5bf25b3bd0714ae54cd8eed6fe759bd1}] DEBUG ahallim-1ef960 --- [nio-7070-exec-1] a.h.w.RestaurantController : tracer: NoopTracer
2018-11-19 12:12:03.939 [{X-B3-SpanId=4cd8eed6fe759bd1, X-B3-TraceId=5bf25b3bd0714ae54cd8eed6fe759bd1, X-Span-Export=true, spanExportable=true, spanId=4cd8eed6fe759bd1, traceId=5bf25b3bd0714ae54cd8eed6fe759bd1}] INFO ahallim-1ef960 --- [nio-7070-exec-1] a.h.w.RestaurantController : active span: null
Why am I getting a NopTracer? Why isn't Brave being registered automatically as promised? Am I doing something wrong?
I am using
Finchley.SR2
I was using Finchley.SR2 train of releases. Once I upgraded to the latest Spring Boot and Spring Cloud versions, the issue fixed itself.
I removed the opentracing-spring-cloud-starter dependency and am now just using
<dependency>
<groupId>io.opentracing.brave</groupId>
<artifactId>brave-opentracing</artifactId>
</dependency>

Camel Upgrade 2.22 breaks Apache CXF endpoints

I have upgraded Camel 2.22. along with CXF version 3.2.5,Spring boot 2.04.RELEASE
When I start my application I can't see any errors but the can't access endpoints anymore
below is the code:
1) Camel route:
<cxf:cxfEndpoint id="porEndpoint" address="/por/" serviceClass="x.y.z.service.PorService" publishedEndpointUrl="">
<cxf:binding>
<soap:soapBinding version="1.2"/>
</cxf:binding>
</cxf:cxfEndpoint>
2) Properties:
cxf.path=/services
server.servlet.context-path=/fuse-test
3)This URL worked fine earlier :http://localhost:8080/fuse-test/services/por?wsdl
I have enabled trace at context level and log mode as debug but I can't find any errors apart from :
o.s.s.ldap.SpringSecurityLdapTemplate : Ignoring PartialResultException
camel-cxf(v 3.2.5) somehow doesn't include the cxf spring boot. After adding the below dependency the endpoint is available
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.6</version>
</dependency>

Tiles + Spring + wildfly 11 + java 8: java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"

I deploy a ear with spring4, tiles 3.0.7, java 8 and in wildfly 11 but i get the following error:
:45:18,865 INFO [org.jboss.as] (Controller Boot Thread)
WFLYSRV0060: Http management interface listening on
http://127.0.0.1:9990/management
00:45:18,865 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
00:45:18,865 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 11.0.0.Final (WildFly Core 3.0.8.Final)
started in 15761ms - Started 915 of 1144 services (356 services are
lazy, passive or on-demand)
00:45:19,773 ERROR Digester:789 - Digester.getParser:
java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"
at javax.xml.parsers.SAXParserFactory.setSchema(SAXParserFactory.java:394)
at __redirected.__SAXParserFactory.setSchema(__SAXParserFactory.java:158)
at org.apache.commons.digester.Digester.getFactory(Digester.java:536)
at org.apache.commons.digester.Digester.getParser(Digester.java:786)
at org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)
at org.apache.commons.digester.Digester.parse(Digester.java:1887)
at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:325)
at org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO.loadDefinitionsFromResource(BaseLocaleUrlDefinitionDAO.java:150)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadRawDefinitionsFromResources(CachingLocaleUrlDefinitionDAO.java:234)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadRawDefinitionsFromResources(CachingLocaleUrlDefinitionDAO.java:225)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadRawDefinitionsFromResources(CachingLocaleUrlDefinitionDAO.java:225)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefinitionsFromResources(CachingLocaleUrlDefinitionDAO.java:203)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefinitions(CachingLocaleUrlDefinitionDAO.java:192)
at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.loadDefinitions(ResolvingLocaleUrlDefinitionDAO.java:68)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.checkAndloadDefinitions(CachingLocaleUrlDefinitionDAO.java:174)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinitions(CachingLocaleUrlDefinitionDAO.java:131)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:105)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:49)
at org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory.getDefinition(UnresolvingLocaleDefinitionsFactory.java:89)
at org.apache.tiles.impl.BasicTilesContainer.getDefinition(BasicTilesContainer.java:286)
at org.apache.tiles.impl.BasicTilesContainer.isValidDefinition(BasicTilesContainer.java:273)
at org.apache.tiles.renderer.DefinitionRenderer.isRenderable(DefinitionRenderer.java:64)
at org.springframework.web.servlet.view.tiles3.TilesView.checkResource(TilesView.java:116)
at org.springframework.web.servlet.view.UrlBasedViewResolver.loadView(UrlBasedViewResolver.java:483)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:244)
at
I tried a lot of solutions but they dont works.
I use tiles version 3.0.7
Any idea?
I just had the same issue as you while trying to upgrade from tiles 1 to 3.
Anyway my fix was to upgrade the xercesimpl version to 2.11.0
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>

Spring Boot 1.2.1 still WARN "Error initializing SpringLiquibase" with liquibase 3.3.x

It appears there is still an issue with Spring Boot and libuibase 3.3.x.
2015-02-16 11:07:34.117 WARN 7576 --- [ main] liquibase : Error initializing SpringLiquibase
java.io.FileNotFoundException: ServletContext resource [/] cannot be resolved to URL because it does not exist
at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:156) ...
The same problem was noted already here on stackoverflow and the answer was that new version of Spring Boot 1.2.1 contains a patch for this issue but it seems still to be a problem with SB 1.2.1 and liquibase 3.3.0 (this is the version number of liquibase that SB 1.2.1 provides by default).
I'm just wondering if others who are using SB 1.2.1 and liquibase observe the same issue and maybe there is a solution to it.
Yes, I observe the same, my solution was to use a previous liquibase version, as it seems SB 1.2.1 still has problems with 3.3.1.
This version did the trick:
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.2.1</version>
</dependency>

How to turn off Spring 3 debug logging?

I would like to turn off log4j logging for Spring 3.1 while leaving things on debug for my own code.
I tried sticking this line into my log4j.properties:
log4j.category.org.springframework = WARN
To get this:
# Root Logger Setup: Includes the level of reporting and appenders -> where
# log messages get sent
log4j.rootLogger = DEBUG,ca,fa
log4j.category.org.springframework = WARN
#ca - Console Appender - Send messages to the console
log4j.appender.ca = org.apache.log4j.ConsoleAppender
log4j.appender.ca.layout = org.apache.log4j.PatternLayout
log4j.appender.ca.layout.ConversionPattern = [acme]: [%-5p] - %d{yyyy-MMM-dd HH:mm:ss} - %c{1}:%M(): %m%n
#fa - File Appender - Send messages to a log file
log4j.appender.fa = org.apache.log4j.RollingFileAppender
log4j.appender.fa.File = acme.log
log4j.appender.fa.MaxFileSize = 100KB
log4j.appender.fa.MaxBackupIndex = 10
log4j.appender.fa.Threshold = DEBUG
log4j.appender.fa.layout = org.apache.log4j.PatternLayout
log4j.appender.fa.layout.ConversionPattern = [%-5p] - %d{yyyy-MMM-dd HH:mm:ss} - %c{2}:%M(): %m%n
No luck in shutting off the debug output from Spring though.
Thanks in advance for any help
Steve
Are all your dependencies in place?
1.3.2.3 Using Log4J
Many people use Log4j as a logging framework for configuration and management purposes. It's efficient and well-established, and in fact it's what we use at runtime when we build and test Spring. Spring also provides some utilities for configuring and initializing Log4j, so it has an optional compile-time dependency on Log4j in some modules.
To make Log4j work with the default JCL dependency (commons-logging) all you need to do is put Log4j on the classpath, and provide it with a configuration file (log4j.properties or log4j.xml in the root of the classpath). So for Maven users this is your dependency declaration:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.0.RELEASE</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>
</dependencies>
And here's a sample log4j.properties for logging to the console:
log4j.rootCategory=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework.beans.factory=DEBUG
I figured this out.
In my classpath I have a directory C:\Classes for convenience when I am experimenting with things. I had another log4.properties file there, which was superseding the one packaged in my WAR making it look like the technique below wasn't working. I renamed the log4.properties in my C:\Classes and all is well.
Thanks to everyone who took a look and thanks to the people at Spring Source who made doing this necessary. It is good to know that an extensive level of debugging is easily available to me when I want it instead of just getting a black box.

Resources