java webapp logback teefilter classnotfound exception - tomcat6

I have a webapp in which I am trying to switch from slf4j + jdk14 to slf4j + logback.
I have updated the pom.xml and added logback.xml in src/main/resources.
When I start the webapp from Netbeans I see this error in the tomcat 6 log:
java.lang.ClassNotFoundException: ch.qos.logback.access.servlet.TeeFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:269)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
This is my logback.xml
<configuration>
<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
<driverClass>oracle.jdbc.OracleDriver</driverClass>
<url>jdbc:oracle:thin:#mercurio:1521:ass10</url>
<user>iltest</user>
<password>iltest</password>
</connectionSource>
<sqlDialect>ch.qos.logback.core.db.dialect.OracleDialect</sqlDialect>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="it.infoline.jobtime.LogbackLayout" />
</encoder>
</appender>
<logger name="OuvertureWeb" level="INFO"/>
<logger name="jdbc" level="OFF" />
<logger name="jdbc.sqlonly" level="OFF" />
<root level="INFO">
<appender-ref ref="DB" />
</root>
</configuration>
Please note that logs are written in the db, so it seems that the whole solution works.
But I have the error above in the tomcat log, and I don't know what it is causing it and, above all, if it could be a clue of something erroneously configured.
Thanks for any help
Bye
Nicola

Seems like you have missed adding logback-access dependency into your pom.xml file.
Add following dependency into your pom.xml file:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>1.0.13</version>
</dependency>

Related

Failed to resolve endpoint: No component found with scheme: exec

I am trying to invoke a simple shell script using Apache Camel but am getting the error:
Failed to resolve endpoint: exec:///usr/local/karaf/data/tmp/test.sh due to: No component found with scheme: exec
In my camel-context.xml I have
<route id="common_route">
<from uri="direct:common_route" />
<to uri="exec:/usr/local/karaf/data/tmp/test.sh"/>
</route>
And in my pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-exec</artifactId>
<version>${camel.version}</version>
</dependency>
We are using Camel version 2.15.3. And we are using Spring Camel.
Any ideas? This is one of those things that must be so simple it is very frustrating.
Btw it makes no difference if I use
exec:/usr/....
or
exec:///usr/....
Thanks in advance.
I figured it out. The docs make no mention of this..at least, not on the camel exec page.
1: I had to add the line
org.apache.camel.component.exec
to my pom.xml in
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Spring-Context>*;create-asynchronously:=false</Spring-Context>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>
...
org.apache.camel.component.exec
...
2: I had to run the following commands in the Karaf console:
bundle:install mvn:org.apache.camel/camel-exec/2.15.3
bundle:install mvn:org.apache.commons/commons-exec/1.3
bundle:install mvn:commons-io/commons-io/1.4

Unable to load class org.eclipse.jetty.server.Connector error while establishing secured soap server using apache CXF

I am trying to publish secured SOAP server as a consuming endpoint at JBoss Fuse camel route.
I have the following endpoint and Jetty-security description in my Blueprint configuration:
...
<cxf:cxfEndpoint
xmlns:crm="http://www.bank.com/CRM"
id="crmOutboundService"
address="https://localhost:9001/cxf/CRMOutbound"
serviceName="crm:CRMOutboundRq"
endpointName="crm:ASBOCRMOutPort"
wsdlURL="model/ASBOCRMOut/CRMOutboundRq.wsdl"
serviceClass="com.bank.SAXSourceService">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</cxf:properties>
</cxf:cxfEndpoint>
<httpj:engine-factory bus="cxf">
<httpj:engine port="9001">
<httpj:tlsServerParameters secureSocketProtocol="TLSv1">
<sec:keyManagers keyPassword="password">
<sec:keyStore type="JKS" password="password"
file="/opt/esb/security/keystore.jks"/>
</sec:keyManagers>
<sec:trustManagers>
<sec:keyStore type="JKS" password="password"
file="/opt/esb/security/truststore.jks"/>
</sec:trustManagers>
<sec:cipherSuitesFilter>
<sec:include>.*_WITH_3DES_.*</sec:include>
<sec:include>.*_WITH_DES_.*</sec:include>
<sec:exclude>.*_WITH_NULL_.*</sec:exclude>
<sec:exclude>.*_DH_anon_.*</sec:exclude>
</sec:cipherSuitesFilter>
<sec:clientAuthentication want="true" required="true"/>
</httpj:tlsServerParameters>
</httpj:engine>
</httpj:engine-factory>
...
Everything as in manual from here: https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.2/pdf/apache_cxf_security_guide/Red_Hat_JBoss_Fuse-6.2-Apache_CXF_Security_Guide-en-US.pdf
I have (among others) the following dependencies in pom.xml:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
</dependency>
When application bundle is deployed into JBoss Fuse the following exception comes:
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to load class org.eclipse.jetty.server.Connector from recipe MapRecipe[name='#recipe-11850']"
The questions are: why does such an error take place and what is the right way to establish secured SOAP server in JBoss Fuse?
We have ended up with adding the following directive into Blueprint descriptor:
<bean id="server" class="org.eclipse.jetty.server.Server"/>
The error has gone, and the application is working correctly, but we do not actually understand why, because there are no any references to the new bean. We are trying to figure out, if this directive starts new instance of Jetty server.

Flink log files on Emr

I have my Flink jar running in Emr. I have logback.xml set to /mnt/var/flink.log as the path for it when it is running on Emr. I can only see the the logs which are formed by the Emr while running the jar but not mine. Please suggest me a way how to get the logs which i have defined in the programs which is running as Flink jar in Emr. I am unable to find proper solution to it. My logback.xml looks like:
<configuration>
<logger name="org.apache.flink.runtime.jobgraph.JobGraph" level="INFO" additivity="false">
<appender-ref ref="file" />
</logger>
<appender name="file" class="ch.qos.logback.core.FileAppender">
<file>/mnt/var/log/flink.log</file>
<append>false</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{60} %X{sourceThread} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="file"/>
</root>
</configuration>
It could be related to FLINK-7990, as per this SO question. But note that you have to put the logback.xml file Flink's conf directory on the system from where you launch Flink. Side note - it's very helpful if you include the version of Flink when asking questions, as it's a fast-moving target.

Apache CXF Https issue

I have generated self signed certificate using keytool command. and successfully configured https at jboss fuse level and port assigned to it is 8443. https://localhost:8443/hawtio/login works perfectly fine. In apache cxf i am facing issue. following configuration is done in blueprint xml file.
<cxf:rsServer address="http://0.0.0.0:9192/"
id="serviceOrderEndpoint" serviceClass="pk.com.telenor.so.controller.ServiceOrder"/>
<cxfcore:bus/>
<httpj:engine-factory bus="cxf">
<httpj:engine port="8443">
<httpj:tlsServerParameters secureSocketProtocol="TLSv1">
<sec:keyManagers keyPassword="password">
<sec:keyStore resource="certs/jbossfuse-dev.jks" password="password" type="JKS"/>
</sec:keyManagers>
<sec:trustManagers>
<sec:keyStore resource="certs/jbossfuse-dev.jks" password="password" type="JKS"/>
</sec:trustManagers>
<sec:cipherSuitesFilter>
<sec:include>.*_WITH_3DES_.*</sec:include>
<sec:include>.*_WITH_DES_.*</sec:include>
<sec:exclude>.*_WITH_NULL_.*</sec:exclude>
<sec:exclude>.*_DH_anon_.*</sec:exclude>
</sec:cipherSuitesFilter>
<sec:clientAuthentication want="true" required="false"/>
</httpj:tlsServerParameters>
</httpj:engine>
</httpj:engine-factory>
I want to run it on https://localhost:9192/
In pom.xml file i have placed the following dependencies:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.3.0.M0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-transports-http -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.2.3</version>
</dependency>
This is the issue that i am facing
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxb.JAXBDataBinding not found by org.apache.cxf.cxf-rt-wsdl
When you said "configured https at jboss fuse level " I believe you mean you configured in the $JBOSS_FUSE/etc/org.ops4j.pax.web.cfg.
Then as your cxf rs endpoint get deployed into the JBoss FUSE container, the best practice is that this endpoint use the servlet transport managed by this container(the HTTP OSGi service implmented by OPS4J PAXWEB with jetty), so your configuration address for the cxf:rsServer should be relative address like address="/myendpoint", then you can access it from
https://localhost:8443/cxf/myendpoint.
Also, as the https already configured at JBoss FUSE level, you don't need
<httpj:engine-factory bus="cxf">
...
</httpj:engine-factory>
stuff.
Freeman

CXF logs not appending to Log file

I want to log the Apache CXF inbound and outbound interceptors logs inside the File instead of Console
Maven project :
1) Created a file named 'org.apache.cxf.Logger' under META-INF\cxf and placed the below text
META-INF\cxf\org.apache.cxf.Logger
org.apache.cxf.common.logging.Log4jLogger
2) application-context.xml:
<cxf:bus>
<cxf:inInterceptors>
<ref bean="loggingInInterceptor"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="loggingOutInterceptor"/>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="loggingOutInterceptor"/>
</cxf:outFaultInterceptors>
<cxf:inFaultInterceptors>
<ref bean="loggingInInterceptor"/>
</cxf:inFaultInterceptors>
</cxf:bus>
<jaxrs:server id="services" address="/mysvc">
<jaxrs:serviceBeans>
<ref bean="myserviceImpl" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
</jaxrs:providers>
<jaxrs:outInterceptors>
<ref bean="loggingOutInterceptor" />
</jaxrs:outInterceptors>
<jaxrs:inInterceptors>
<ref bean="loggingInInterceptor" />
</jaxrs:inInterceptors>
</jaxrs:server>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" id="loggingInInterceptor" />
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" id="loggingOutInterceptor" />
3) log4j2.xml: under src\main\resources folder
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="CompanyServices" packages="">
<Appenders>
<RollingFile name="RollingFile" fileName="D:/temp/companyfile.log"
filePattern="companyfile-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d %p [%t] %C:%L - %m%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
</RollingFile>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout>
<Pattern>%d %p [%t] %C:%L - %m%n</Pattern>
</PatternLayout>
</Console>
</Appenders>
<Loggers>
<Logger name="com.myorg.mycompany" level="trace"
additivity="false">
<AppenderRef ref="RollingFile" />
</Logger>
<Logger name="org.apache.cxf.interceptor" level="info"
additivity="false">
<AppenderRef ref="RollingFile" />
</Logger>
<Root level="all">
<AppenderRef ref="RollingFile" />
</Root>
</Loggers>
</Configuration>
4. pom.xml :
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
A file was getting generated and printing only my application level logs to my file. But not printing CXF interceptors logs in to the file.
Please suggest what's going wrong?
step 1) Redirect to Slf4jLogger as it looks like redirecting to the Log4jLogger does not seem to work with Log4j2. In addition SLF4J allows more flexibility afterwards if you ever decided to change logging framework.
step 2) I think the above configuration could be simplified a bit. You are adding the logging interceptors to both the CXF bus and your JAX-RS endpoint. If you only want messages to be logged for your endpoint, add them there. If not, add them to the bus as such you do not need to repeat the configuration for possible other endpoints.
Also on the endpoint you did not add the logging interceptors to the fault interceptor chains. If you basically want to log all messages it is probably easier to use the CXF LoggingFeature. For more details on the difference between interceptors and features, check this blog post I wrote.
step 4) You would need the following dependencies:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
I've created a blog post which explains how to configure CXF for log4j2 in more detail.

Resources