How to exclude io.undertow.request package from the logging in wildfly - java

I am getting following error logs related to io.undertow.request package.
Caused by: java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:51)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
at org.xnio.nio.NioSocketConduit.write(NioSocketConduit.java:153)
at io.undertow.protocols.ssl.SslConduit.doWrap(SslConduit.java:874)
at io.undertow.protocols.ssl.SslConduit.write(SslConduit.java:379)
at io.undertow.server.protocol.http.HttpResponseConduit.processWrite(HttpResponseConduit.java:247)
at io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:588)
at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:106)
at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:120)
at io.undertow.conduits.DeflatingStreamSinkConduit.performFlushIfRequired(DeflatingStreamSinkConduit.java:418)
at io.undertow.conduits.DeflatingStreamSinkConduit.flush(DeflatingStreamSinkConduit.java:348)
at org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
at io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:119)
at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:605)
In this case, it is not necessary to see those errors in my wildfly log. I need to exclude this package from the logging.Is there anyway that I can make a configuration for it?

If you dont want any logging from io.undertow.request then add below tag in standalone-*.xml file in logging subsystem:
<logger category="io.undertow.request">
<level name="OFF"/>
</logger>

Related

ClassNotFoundException jdk.net.* in Wildfly

My app just started blowing up on startup after upgrading to latest MongoDB drivers. Using Wildfly 19, JDK14, and I've confirmed that at compile time jdk.net.* are available. Clearly they're either not making it into the runtime environment or there is a security issue. My guess is that the module is being blocked, but I've not been able to figure out how to get access to it.
Log output:
13:28:07,673 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-srv-cluster0-hpilc.azure.mongodb.net) Adding discovered server cluster0-shard-00-00-hpilc.azure.mongodb.net:27017 to client view of cluster
13:28:07,675 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-srv-cluster0-hpilc.azure.mongodb.net) Adding discovered server cluster0-shard-00-01-hpilc.azure.mongodb.net:27017 to client view of cluster
13:28:07,783 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-cluster0-shard-00-02-hpilc.azure.mongodb.net:27017) Exception in monitor thread while connecting to server cluster0-shard-00-02-hpilc.azure.mongodb.net:27017: com.mongodb.MongoException: java.lang.NoClassDefFoundError: jdk/net/ExtendedSocketOptions
at deployment.goa.war//com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:157)
at deployment.goa.war//com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188)
at deployment.goa.war//com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:144)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoClassDefFoundError: jdk/net/ExtendedSocketOptions
at deployment.goa.war//com.mongodb.internal.connection.SocketStreamHelper.setExtendedSocketOptions(SocketStreamHelper.java:83)
at deployment.goa.war//com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:53)
at deployment.goa.war//com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79)
at deployment.goa.war//com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)
at deployment.goa.war//com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:143)
... 3 more
Caused by: java.lang.ClassNotFoundException: jdk.net.ExtendedSocketOptions from [Module "deployment.goa.war" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 8 more```
Figured it out. In the Wildfly standalone.xml file add
<global-modules>
<module name="jdk.net" slot="main" />
</global-modules>
inside of the block
Using Wildfly 10.1, JDK 8. Adding the following block to the file jboss-deployment-structure.xml inside the dependencies section solved the problem.
<system export="true">
<paths>
<path name="jdk/net"/>
</paths>
</system>

Logstash not reading spring properties correctly

So I have a quite simple logstash configuration that should read the host URL from spring. Although for some reason it is not working.
My logback-spring.xml looks sort of like this:
<springProperty name="logstashDestination" scope="context" source="service.logstash.host"/>
<appender class="net.logstash.logback.appender.LogstashTcpSocketAppender" name="LOGSTASH">
<destination>${logstashDestination}</destination>
<!-- encoder is required -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"service":"provisioning-engine-jane"}</customFields>
</encoder>
</appender>
In my application.properties I have these lines:
spring.profiles.active:sit
service.logstash.host:NaN
And in application-sit.properties I have this line:
service.logstash.host:api-test.local:9013
This makes the whole application crash with the error
Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.util.PropertySetter#44cb3536 - Could not invoke method addDestination in class net.logstash.logback.appender.LogstashTcpSocketAppender with parameter of type java.lang.String java.lang.reflect.InvocationTargetException
ERROR in net.logstash.logback.appender.LogstashTcpSocketAppender[LOGSTASH] - No destination was configured. Use <destination> to add one or more destinations to the appender
The odd thing here is that if I add a bootstrap.properties file with some dummy data it starts. Issue with this is that the dummy data is overriding my environment specific logstash URL.
Anyone have any idea of why this might be happening?

Unable to create class org.apache.logging.log4j.core.impl.Log4jContextFactory

I am using spring boot application for a project and getting the following error while running the project from jar using java -jar build/libs/com.user.admin.rest.services.jar. But its not a blocker and i was able to access the api's, and the logger is working fine as intended. I just want to resolve this error.
ERROR StatusLogger Unable to create class org.apache.logging.log4j.core.impl.Log4jContextFactory specified in jar:file:/Users/Samuel/UserMgmt/com.user.admin.rest.services/build/libs/com.user.admin.rest.services.jar!/META-INF/log4j-provider.properties
java.lang.ClassNotFoundException: org.apache.logging.log4j.core.impl.Log4jContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.logging.log4j.spi.Provider.loadLoggerContextFactory(Provider.java:96)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:91)
at com.user.admin.rest.services.api.UserServiceResource.<clinit>(UserServiceResource.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1147)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at com.user.admin.rest.services.api.Application.main(Application.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
I have added the following lines for logger in the build.gradle file.
compile 'org.apache.logging.log4j:log4j-api:2.8.2'
compile 'org.apache.logging.log4j:log4j-core:2.8.2'
And my log4j2.xml file is given below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Configuration status="ERROR" name="example-config">
<Properties>
<Property name="PATTERN">%-5level %d [%t] %c:%M(%L): %m%n</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="${PATTERN}" />
</Console>
</Appenders>
<Loggers>
<Root level="TRACE">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>
Generally speaking, you should never need to switch logging implementations; Logback should suit you fine. However, if you decide that you’d rather use Log4j or Log4j2, you’ll need to change your dependencies to include the appropriate starter for the logging implementation you want to use and to exclude Logback.
Spring Boot in Action
Swapping out Logback for Log4j2 in Gradle
Exclude the default logging
configurations {
all*.exclude group:'org.springframework.boot',
module:'spring-boot-starter-logging'
}
Add Log4j2 logging
compile("org.springframework.boot:spring-boot-starter-log4j2")
You can find details of spring-boot-starter-log4j2 dependency version that is provided by Spring Boot here.
I have met the similar problem. The version of log4j-api and log4j-core have to match (and ClassNotFound is a strange exception here). As you have said in comment, you have found log4j-core-2.7.jar, but I may guess your log4j-api is in version of 2.8.2 as your above description shows.
Check your dependency, remove old version of log4j-core and add new version should fix the problem.
This exception is printed to System.out because the class is not on the classpath of Spring's boot loader. But this is not the cause of logging not working or not using the specified configuration file.
It's a Spring Boot Gradle plugin issue. It should add Log4j to the boot loader classpath when it detects a dependency on Log4j.

Running Spring Integration within Windows Service; Does Not "Trigger" Inbound

I've got a Spring Boot command line application using Spring Integration. The application is running within a service wrapper.
At start up, everything seems to run smoothly with no exceptions. However, if I drop a file in the observed directory nothing triggers the inbound-channel-adapter.
Is it at all possible the service wrapper is causing the polling to not run?
UPDATE
I added a logback.xml configuration
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.springframework.integration" level="DEBUG">
<appender-ref ref="STDOUT" />
</logger>
</configuration>
But now the log is not receiving any input with this config. STDOUT works fine without the config. Makes is difficult to enable DEBUG for the integration package.
I based my wrapper on this project
UPDATE #2
I finally got logging working. I had a mistake in assuming it was not a ERROR level issue.
13:29:52.925 [task-scheduler-10] ERROR o.s.i.handler.LoggingHandler - org.springframework.messaging.MessagingException: The path [\\server\sharepath] does not denote a properly accessible directory.
at org.springframework.integration.file.DefaultDirectoryScanner.listFiles(DefaultDirectoryScanner.java:83)
at org.springframework.integration.file.FileReadingMessageSource.scanInputDirectory(FileReadingMessageSource.java:293)
at org.springframework.integration.file.FileReadingMessageSource.receive(FileReadingMessageSource.java:272)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:175)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:224)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:57)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:176)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:173)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:330)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:324)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The issue is that the network path cannot be determined if accessible by Java/Spring.
13:29:52.925 [task-scheduler-10] ERROR o.s.i.handler.LoggingHandler -
org.springframework.messaging.MessagingException: The path
[\server\sharepath] does not denote a properly accessible directory.

JBoss AS6 app specific logging

I'm currently migrating old web apps from JBoss As 4.2.2 to 6.0.0 (AS6). In AS6 we have a proprietary format for logging applications through a file named jboss-logging.xml.
After read some stuff (http://community.jboss.org/wiki/SeparatingApplicationLogs) reach the conclusion that "(...)starting with JBoss AS 6.0.0.M2 the ability to log to separate log files, per application, will be implemented in a different way" and also that the documentation "(...) will be updated with more details, once the implementation is ready".
However I was able to create the specific application log files in my server/log dir, it was done using the main joboss-logging.xml file in the server/deploy dir. This is not compatible with the modularity my applications demand.
So here the problem when I create a jboss-logging.xml e my WEB-INF dir for my app whit this configuration:
<?xml version="1.0" encoding="UTF-8"?>
<logging xmlns="urn:jboss:logging:6.0" xmlns:b="urn:jboss:bean-deployer:2.0" context="myApp">
<define-context name="myApp" />
<periodic-rotating-file-handler
file-name="${jboss.server.log.dir}/myApp.log"
name="WEBAPP" autoflush="true" append="true" suffix=".yyyy-MM-dd">
<error-manager><only-once/></error-manager>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
</formatter>
</periodic-rotating-file-handler>
<root-logger>
<!-- Set the root logger priority via a system property, with a default value. -->
<level name="${jboss.server.log.threshold:INFO}"/>
<handlers>
<handler-ref name="WEBAPP"/>
</handlers>
</root-logger>
</logging>
I get the following error when my app starts:
8:57:07,765 ERROR [AbstractKernelController] Error installing to Configured: name=Logging:REGISTRATION:myApp:Anonymous-0 state=Instantiated: java.lang.RuntimeException: Error configuring property: selector for Logging:REGISTRATION:myApp:Anonymous-0
at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:112) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.ConfigureAction.setAttributes(ConfigureAction.java:85) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.ConfigureAction.installActionInternal(ConfigureAction.java:44) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]
(...)
Caused by: java.lang.IllegalArgumentException: Wrong arguments. setSelector for target org.jboss.logging.metadata.ClassLoaderRegistrationHelper#1a4eb51 expected=[org.jboss.logmanager.ClassLoaderLogContextSelector] actual=[org.jboss.logmanager.LogContextSelectorService]
at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors(ReflectionUtils.java:404) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:74) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:168) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.beans.info.plugins.DefaultPropertyInfo.set(DefaultPropertyInfo.java:143) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.beans.info.plugins.BeanInfoUtil.set(BeanInfoUtil.java:177) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.beans.info.plugins.AbstractBeanInfo.setProperty(AbstractBeanInfo.java:289) [jboss-reflect.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.PropertyDispatchWrapper.execute(PropertyDispatchWrapper.java:114) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:107) [jboss-kernel.jar:2.2.0.GA]
... 64 more
I will be grateful for any kind of info or direction on this subject, even one that represents using a complete different approach to logging in AS6. Although I feel I'm getting closer to the solution... Thank you in advance.
The post here is also mine
This is a bug, it's reported here:
https://issues.jboss.org/browse/JBLOGGING-56
I tried the workaround that they mention, but couldn't get it to work either. Unfortunately, new logging framework in JBoss AS 6 seems to be very buggy and undocumented at this moment.
You can look here
http://lea-ka.blogspot.com/2011/09/assorted-facts-about-jboss-fact-3-how.html
and here
http://lea-ka.blogspot.com/2011/09/dynamically-changing-app-specific.html.
01.12.2011. Update:
Even better look here to see why you do not want to use it: http://lea-ka.blogspot.com/2011/12/assorted-facts-about-jboss-fact-4-per.html

Categories