Hibernate validator required for war deployment to Mule - spring-mvc

I’ve created a simple maven project that demonstrates Spring MVC accepts a request and returns a JSON object.
Here’s the pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>bg-SpringREST3.1</groupId>
<artifactId>RESTexample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.hibernate</groupId> -->
<!-- <artifactId>hibernate-validator</artifactId> -->
<!-- <version>4.3.0.Final</version> -->
<!-- </dependency> -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.13.v20130916</version> </plugin>
</plugins>
</build>
Here's the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>JSON and XML RESTful web service example</display-name>
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/application.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Here's the application context
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<mvc:annotation-driven />
<!-- Use the message-converters element to specify the orders of message converters -->
<!--
<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
<bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />
</mvc:message-converters>
</mvc:annotation-driven>
-->
<context:component-scan base-package="integration.apps" />
Here is my RESTController.java
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
#Controller
public class RESTController {
#RequestMapping("/users/{id}")
#ResponseBody
public User getUser(#PathVariable Long id, #RequestHeader("Accept") String acceptHeader) {
return new User(id, "John Doe");
}
}
And my User.java
public class User {
private Long id;
private String name;
public User() {
}
public User(Long id, String name) {
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
As far as I’m aware, I’m not using any validation. When I package the project and run Jetty within Eclipse, I receive no errors and the response to
http://localhost:8080/users/5
is
{"id":5,"name":"John Doe"}
Now I deploy the application in Mule following these steps
Create the following folder structure under scr/main/app/webapps
Drop the war file to this location
The mule configuration is as follows
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jetty="http://www.mulesoft.org/schema/mule/jetty"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/jetty http://www.mulesoft.org/schema/mule/jetty/current/mule-jetty.xsd">
<jetty:connector name="jettyConnector">
<jetty:webapps directory="${app.home}/webapps" port="8083" />
</jetty:connector>
</mule>
Running dependency tree outside of Mule Anypoint studio. Note - I need to "mavenize" the mule project achieve this
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # RESTexample ---
[INFO] bg-SpringREST3.1:RESTexample:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-web:jar:3.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:3.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:3.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:3.2.1.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-core:jar:3.2.1.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.2.1.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:3.2.1.RELEASE:compile
[INFO] \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.5:compile
[INFO] \- org.codehaus.jackson:jackson-core-asl:jar:1.9.5:compile
Running dependency tree inside Mule Anypoint studio
[INFO] com.mycompany:springresttest:mule:1.0.0-SNAPSHOT
[INFO] +- org.mule:mule-core:jar:3.5.0:provided
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.0:provided
[INFO] | +- com.github.stephenc.eaio-uuid:uuid:jar:3.4.0:provided
[INFO] | | \- com.github.stephenc.eaio-grabbag:grabbag:jar:1.8.1:provided
[INFO] | +- commons-cli:commons-cli:jar:1.2:provided
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:provided
[INFO] | +- commons-io:commons-io:jar:1.4:provided
[INFO] | +- commons-lang:commons-lang:jar:2.4:provided
[INFO] | +- commons-pool:commons-pool:jar:1.6:provided
[INFO] | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:provided
[INFO] | +- org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec:jar:1.1:provided
[INFO] | +- javax.annotation:jsr250-api:jar:1.0:provided
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.6.1:provided
[INFO] | +- org.slf4j:slf4j-api:jar:1.6.1:provided
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.6.1:provided
[INFO] | +- log4j:log4j:jar:1.2.16:provided
[INFO] | +- asm:asm:jar:3.1:provided
[INFO] | +- asm:asm-commons:jar:3.1:provided
[INFO] | | \- asm:asm-tree:jar:3.1:provided
[INFO] | +- org.mule.mvel:mule-mvel2:jar:2.1.9-MULE-003:provided
[INFO] | +- org.jgrapht:jgrapht-jdk1.5:jar:0.7.3:provided
[INFO] | +- org.mule.common:mule-common:jar:3.5.0:provided
[INFO] | | +- org.apache.xmlbeans:xmlbeans:jar:2.3.0:provided
[INFO] | | +- javax.xml.stream:stax-api:jar:1.0-2:provided
[INFO] | | \- org.antlr:antlr-runtime:jar:3.5:provided
[INFO] | | \- org.antlr:stringtemplate:jar:3.2.1:provided
[INFO] | \- com.google.guava:guava:jar:16.0.1:provided
[INFO] +- org.mule.modules:mule-module-spring-config:jar:3.5.0:provided
[INFO] | +- org.mule.modules:mule-module-annotations:jar:3.5.0:provided
[INFO] | | \- cglib:cglib-nodep:jar:2.2:provided
[INFO] | +- org.springframework:spring-context:jar:3.2.1.RELEASE:provided
[INFO] | | \- org.springframework:spring-expression:jar:3.2.1.RELEASE:provided
[INFO] | +- dom4j:dom4j:jar:1.6.1:provided
[INFO] | \- jaxen:jaxen:jar:1.1.1:provided
[INFO] +- org.mule.transports:mule-transport-file:jar:3.5.0:provided
[INFO] +- org.mule.transports:mule-transport-http:jar:3.5.0:provided
[INFO] | +- org.mule.transports:mule-transport-ssl:jar:3.5.0:provided
[INFO] | +- commons-codec:commons-codec:jar:1.3:provided
[INFO] | +- commons-httpclient:commons-httpclient:jar:3.1:provided
[INFO] | +- tomcat:tomcat-util:jar:5.5.23:provided
[INFO] | | \- tomcat:tomcat-apr:jar:5.5.23:provided
[INFO] | +- org.samba.jcifs:jcifs:jar:1.3.3:provided
[INFO] | \- joda-time:joda-time:jar:1.6:provided
[INFO] +- org.mule.transports:mule-transport-jdbc:jar:3.5.0:provided
[INFO] | +- commons-dbutils:commons-dbutils:jar:1.2:provided
[INFO] | \- com.experlog:xapool:jar:1.5.0:provided
[INFO] +- org.mule.transports:mule-transport-jms:jar:3.5.0:provided
[INFO] | +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1:provided
[INFO] | +- org.apache.geronimo.specs:geronimo-j2ee-management_1.0_spec:jar:1.1:provided
[INFO] | \- org.springframework:spring-jms:jar:3.2.1.RELEASE:provided
[INFO] | \- org.springframework:spring-tx:jar:3.2.1.RELEASE:provided
[INFO] +- org.mule.transports:mule-transport-vm:jar:3.5.0:provided
[INFO] +- org.mule.modules:mule-module-client:jar:3.5.0:provided
[INFO] +- org.mule.modules:mule-module-cxf:jar:3.5.0:provided
[INFO] | +- org.apache.cxf:cxf-rt-core:jar:2.5.9:provided
[INFO] | | +- org.apache.cxf:cxf-api:jar:2.5.9:provided
[INFO] | | | +- org.apache.neethi:neethi:jar:3.0.2:provided
[INFO] | | | \- wsdl4j:wsdl4j:jar:1.6.2:provided
[INFO] | | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.3:provided
[INFO] | +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.5.9:provided
[INFO] | | \- org.apache.cxf:cxf-rt-bindings-soap:jar:2.5.9:provided
[INFO] | +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.5.9:provided
[INFO] | | +- xml-resolver:xml-resolver:jar:1.2:provided
[INFO] | | \- org.apache.cxf:cxf-rt-bindings-xml:jar:2.5.9:provided
[INFO] | +- org.apache.cxf:cxf-rt-databinding-aegis:jar:2.5.9:provided
[INFO] | +- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.5.9:provided
[INFO] | | \- com.sun.xml.bind:jaxb-xjc:jar:2.2.5.1:provided
[INFO] | +- org.apache.cxf:cxf-rt-databinding-jibx:jar:2.5.9:provided
[INFO] | | +- org.apache.cxf:cxf-tools-common:jar:2.5.9:provided
[INFO] | | +- org.jibx:jibx-run:jar:1.2.4.5:provided
[INFO] | | | \- xpp3:xpp3:jar:1.1.3.4.O:provided
[INFO] | | \- org.jibx:jibx-schema:jar:1.2.4.5:provided
[INFO] | | \- org.jibx:jibx-extras:jar:1.2.4.5:provided
[INFO] | | \- org.jdom:jdom:jar:1.1.3:provided
[INFO] | +- org.apache.cxf:cxf-rt-transports-local:jar:2.5.9:provided
[INFO] | +- org.apache.cxf:cxf-rt-ws-security:jar:2.5.9:provided
[INFO] | | +- org.apache.cxf:cxf-common-utilities:jar:2.5.9:provided
[INFO] | | \- org.apache.ws.security:wss4j:jar:1.6.9:provided
[INFO] | | +- org.apache.santuario:xmlsec:jar:1.5.3:provided
[INFO] | | \- org.opensaml:opensaml:jar:2.5.1-1:provided
[INFO] | | \- org.opensaml:openws:jar:1.4.2-1:provided
[INFO] | | \- org.opensaml:xmltooling:jar:1.3.2-1:provided
[INFO] | +- org.apache.cxf:cxf-rt-ws-rm:jar:2.5.9:provided
[INFO] | | \- org.apache.cxf:cxf-rt-management:jar:2.5.9:provided
[INFO] | +- org.apache.cxf:cxf-rt-ws-addr:jar:2.5.9:provided
[INFO] | +- org.apache.cxf:cxf-rt-transports-http:jar:2.5.9:provided
[INFO] | | +- org.apache.cxf:cxf-rt-transports-common:jar:2.5.9:provided
[INFO] | | \- org.springframework:spring-web:jar:3.0.6.RELEASE:provided
[INFO] | +- org.apache.cxf:cxf-wstx-msv-validation:jar:2.5.9:provided
[INFO] | | \- net.java.dev.msv:msv-core:jar:2011.1:provided
[INFO] | | +- com.sun.msv.datatype.xsd:xsdlib:jar:2010.1:provided
[INFO] | | +- isorelax:isorelax:jar:20030108:provided
[INFO] | | \- relaxngDatatype:relaxngDatatype:jar:20020414:provided
[INFO] | +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.3:provided
[INFO] | | \- javax.xml.soap:saaj-api:jar:1.3:provided
[INFO] | +- org.mule.modules:mule-module-spring-security:jar:3.5.0:provided
[INFO] | | +- org.mule.modules:mule-module-spring-extras:jar:3.5.0:provided
[INFO] | | | +- org.springframework:spring-jdbc:jar:3.2.1.RELEASE:provided
[INFO] | | | \- org.springframework:spring-context-support:jar:3.2.1.RELEASE:provided
[INFO] | | +- org.springframework.security:spring-security-core:jar:3.1.0.RELEASE:provided
[INFO] | | | \- org.springframework.security:spring-security-crypto:jar:3.1.0.RELEASE:provided
[INFO] | | +- org.springframework.security:spring-security-config:jar:3.1.0.RELEASE:provided
[INFO] | | +- org.springframework.security:spring-security-web:jar:3.1.0.RELEASE:provided
[INFO] | | +- org.springframework.security:spring-security-ldap:jar:3.1.0.RELEASE:provided
[INFO] | | | \- org.springframework.ldap:spring-ldap-core:jar:1.3.1.RELEASE:provided
[INFO] | | +- org.apache.geronimo.specs:geronimo-servlet_3.0_spec:jar:1.0:provided
[INFO] | | \- org.aspectj:aspectjrt:jar:1.6.11:provided
[INFO] | +- org.mule.transports:mule-transport-tcp:jar:3.5.0:provided
[INFO] | +- net.sourceforge.saxon:saxon:jar:9.1.0.8:provided
[INFO] | +- org.apache.geronimo.specs:geronimo-annotation_1.1_spec:jar:1.0.1:provided
[INFO] | +- org.springframework:spring-beans:jar:3.2.1.RELEASE:provided
[INFO] | +- org.springframework:spring-core:jar:3.2.1.RELEASE:provided
[INFO] | +- javax.mail:mail:jar:1.4.3:provided
[INFO] | +- javax.xml.ws:jaxws-api:jar:2.2.1:provided
[INFO] | | \- javax.jws:jsr181-api:jar:1.0-MR1:provided
[INFO] | \- org.apache.ant:ant:jar:1.7.0:provided
[INFO] | \- org.apache.ant:ant-launcher:jar:1.7.0:provided
[INFO] +- org.mule.modules:mule-module-management:jar:3.5.0:provided
[INFO] | +- mx4j:mx4j-jmx:jar:2.1.1:provided
[INFO] | +- mx4j:mx4j-impl:jar:2.1.1:provided
[INFO] | +- mx4j:mx4j-tools:jar:2.1.1:provided
[INFO] | +- mx4j:mx4j-remote:jar:2.1.1:provided
[INFO] | +- com.yourkit:yjp-controller-api-redist:jar:9.0.8:provided
[INFO] | \- tanukisoft:wrapper:jar:3.2.3:provided
[INFO] +- org.mule.modules:mule-module-scripting:jar:3.5.0:provided
[INFO] | +- org.springframework:spring-aop:jar:3.2.1.RELEASE:provided
[INFO] | | \- aopalliance:aopalliance:jar:1.0:provided
[INFO] | +- org.mule.modules:mule-module-builders:jar:3.5.0:provided
[INFO] | +- org.livetribe:livetribe-jsr223:jar:2.0.5:provided
[INFO] | \- org.codehaus.groovy:groovy-all:jar:1.8.6:provided
[INFO] +- org.mule.modules:mule-module-sxc:jar:3.5.0:provided
[INFO] | +- com.envoisolutions.sxc:sxc-xpath:jar:0.7.3:provided
[INFO] | +- com.envoisolutions.sxc:sxc-runtime:jar:0.7.3:provided
[INFO] | \- com.envoisolutions.sxc:sxc-core:jar:0.7.3:provided
[INFO] +- org.mule.modules:mule-module-xml:jar:3.5.0:provided
[INFO] | +- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:provided
[INFO] | +- commons-jxpath:commons-jxpath:jar:1.3:provided
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.4.2:provided
[INFO] | | \- xmlpull:xmlpull:jar:1.1.3.1:provided
[INFO] | +- xpp3:xpp3_min:jar:1.1.3.4.O:provided
[INFO] | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.4:provided
[INFO] | | \- org.codehaus.woodstox:stax2-api:jar:3.1.1:provided
[INFO] | +- net.java.dev.stax-utils:stax-utils:jar:20080702:provided
[INFO] | +- net.sourceforge.saxon:saxon:jar:dom:9.1.0.8:provided
[INFO] | +- net.sourceforge.saxon:saxon:jar:xqj:9.1.0.8:provided
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.1:provided
[INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.1.5:provided
[INFO] +- org.mule.tests:mule-tests-functional:jar:3.5.0:test
[INFO] | +- commons-net:commons-net:jar:2.0:test
[INFO] | +- org.apache.ftpserver:ftpserver-core:jar:1.0.2:test
[INFO] | | \- org.apache.mina:mina-core:jar:2.0.0-M6:test
[INFO] | +- org.apache.ftpserver:ftplet-api:jar:1.0.2:test
[INFO] | +- org.apache.sshd:sshd-core:jar:0.6.0:test
[INFO] | +- org.bouncycastle:bcprov-jdk16:jar:1.46:test
[INFO] | +- org.mule:mule-core:test-jar:tests:3.5.0:test
[INFO] | \- org.mockito:mockito-all:jar:1.9.0:test
[INFO] +- mockobjects:mockobjects-core:jar:0.09:test
[INFO] \- junit:junit:jar:4.9:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.1:test
Finally, the .classpath file for the project
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Now, when I run the mule application (Mule server 3.5.0 CE) I get the following error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is javax.validation.ValidationException: Unable to find a default provider
Which is fine, if I uncomment the pom.xml entry on my rest project, I can run successfully in Mule.
So, my question, what is the difference between running the app in Eclipse with Jetty plugin and running in Mule again on Jetty.

Related

EmbeddedKafka failing since Spring Boot 2.6.X : AccessDeniedException: ..\AppData\Local\Temp\spring.kafka*

e: this has been fixed through Spring Boot 2.6.5 (see https://github.com/spring-projects/spring-boot/issues/30243)
Since upgrading to Spring Boot 2.6.X (in my case: 2.6.1), I have multiple projects that now have failing unit-tests on Windows that cannot start EmbeddedKafka, that do run with Linux
There is multiple errors, but this is the first one thrown
...
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.1)
2021-12-09 16:15:00.300 INFO 13864 --- [ main] k.utils.Log4jControllerRegistration$ : Registered kafka:type=kafka.Log4jController MBean
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer :
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : ______ _
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : |___ / | |
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : / / ___ ___ | | __ ___ ___ _ __ ___ _ __
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : / / / _ \ / _ \ | |/ / / _ \ / _ \ | '_ \ / _ \ | '__|
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : / /__ | (_) | | (_) | | < | __/ | __/ | |_) | | __/ | |
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : /_____| \___/ \___/ |_|\_\ \___| \___| | .__/ \___| |_|
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : | |
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : |_|
2021-12-09 16:15:00.420 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer :
2021-12-09 16:15:00.422 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : Server environment:zookeeper.version=3.6.3--6401e4ad2087061bc6b9f80dec2d69f2e3c8660a, built on 04/08/2021 16:35 GMT
2021-12-09 16:15:00.422 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : Server environment:host.name=host.docker.internal
2021-12-09 16:15:00.422 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : Server environment:java.version=11.0.11
2021-12-09 16:15:00.422 INFO 13864 --- [ main] o.a.zookeeper.server.ZooKeeperServer : Server environment:java.vendor=AdoptOpenJDK
...
2021-12-09 16:15:01.015 INFO 13864 --- [nelReaper-Fetch] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Fetch]: Starting
2021-12-09 16:15:01.015 INFO 13864 --- [lReaper-Produce] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Produce]: Starting
2021-12-09 16:15:01.016 INFO 13864 --- [lReaper-Request] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Request]: Starting
2021-12-09 16:15:01.017 INFO 13864 --- [trollerMutation] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-ControllerMutation]: Starting
2021-12-09 16:15:01.037 INFO 13864 --- [ main] kafka.log.LogManager : Loading logs from log dirs ArraySeq(C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446)
2021-12-09 16:15:01.040 INFO 13864 --- [ main] kafka.log.LogManager : Attempting recovery for all logs in C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446 since no clean shutdown file was found
2021-12-09 16:15:01.043 INFO 13864 --- [ main] kafka.log.LogManager : Loaded 0 logs in 6ms.
2021-12-09 16:15:01.043 INFO 13864 --- [ main] kafka.log.LogManager : Starting log cleanup with a period of 300000 ms.
2021-12-09 16:15:01.045 INFO 13864 --- [ main] kafka.log.LogManager : Starting log flusher with a default period of 9223372036854775807 ms.
2021-12-09 16:15:01.052 INFO 13864 --- [ main] kafka.log.LogCleaner : Starting the log cleaner
2021-12-09 16:15:01.059 INFO 13864 --- [leaner-thread-0] kafka.log.LogCleaner : [kafka-log-cleaner-thread-0]: Starting
2021-12-09 16:15:01.224 INFO 13864 --- [name=forwarding] k.s.BrokerToControllerRequestThread : [BrokerToControllerChannelManager broker=0 name=forwarding]: Starting
2021-12-09 16:15:01.325 INFO 13864 --- [ main] kafka.network.ConnectionQuotas : Updated connection-accept-rate max connection creation rate to 2147483647
2021-12-09 16:15:01.327 INFO 13864 --- [ main] kafka.network.Acceptor : Awaiting socket connections on localhost:63919.
2021-12-09 16:15:01.345 INFO 13864 --- [ main] kafka.network.SocketServer : [SocketServer listenerType=ZK_BROKER, nodeId=0] Created data-plane acceptor and processors for endpoint : ListenerName(PLAINTEXT)
2021-12-09 16:15:01.350 INFO 13864 --- [0 name=alterIsr] k.s.BrokerToControllerRequestThread : [BrokerToControllerChannelManager broker=0 name=alterIsr]: Starting
2021-12-09 16:15:01.364 INFO 13864 --- [eaper-0-Produce] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-Produce]: Starting
2021-12-09 16:15:01.364 INFO 13864 --- [nReaper-0-Fetch] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-Fetch]: Starting
2021-12-09 16:15:01.365 INFO 13864 --- [0-DeleteRecords] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-DeleteRecords]: Starting
2021-12-09 16:15:01.365 INFO 13864 --- [r-0-ElectLeader] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-ElectLeader]: Starting
2021-12-09 16:15:01.374 INFO 13864 --- [rFailureHandler] k.s.ReplicaManager$LogDirFailureHandler : [LogDirFailureHandler]: Starting
2021-12-09 16:15:01.390 INFO 13864 --- [ main] kafka.zk.KafkaZkClient : Creating /brokers/ids/0 (is it secure? false)
2021-12-09 16:15:01.400 INFO 13864 --- [ main] kafka.zk.KafkaZkClient : Stat of the created znode at /brokers/ids/0 is: 25,25,1639062901396,1639062901396,1,0,0,72059919267528704,204,0,25
2021-12-09 16:15:01.400 INFO 13864 --- [ main] kafka.zk.KafkaZkClient : Registered broker 0 at path /brokers/ids/0 with addresses: PLAINTEXT://localhost:63919, czxid (broker epoch): 25
2021-12-09 16:15:01.410 ERROR 13864 --- [ main] kafka.server.BrokerMetadataCheckpoint : Failed to write meta.properties due to
java.nio.file.AccessDeniedException: C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89) ~[na:na]
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) ~[na:na]
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) ~[na:na]
Reproduceable via spring Initializr + adding "Spring Kafka": https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.6.1&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=kafka
And then have following test-class to execute:
package com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.kafka.test.context.EmbeddedKafka;
#SpringBootTest
#EmbeddedKafka
class ApplicationTest {
#Test
void run() {
int i = 1 + 1; // just a line of code to set a debug-point
}
}
I do not have this error when pinning kafka.version to 2.8.1 in pom.xml's properties.
It seems like the cause is in Kafka itself, but I have a hard time figuring out if it is spring-kafka intitializing Kafka via EmbeddedKafka incorrectly or if Kafka itself is the culrit here.
Anyone has an idea? Am I missing a test-parameter to set?
As a workaround, add the patched https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/utils/Utils.java to your project test sources (under the same package) until Kafka 3.0.1 ships with Spring Boot. - Of course, delete this temporary class when that happens.
Known bug on the Apache Kafka side. Nothing to do from Spring perspective.
See more info here: https://github.com/spring-projects/spring-kafka/discussions/2027.
And here: https://issues.apache.org/jira/browse/KAFKA-13391
You need to wait until Apache Kafka 3.0.1 or don't use embedded Kafka and just rely on the Testcontainers, for example, or fully external Apache Kafka broker.
Another way to pin down to kafka 2.8.1 just for windows environments.
This assumes that your build environment that produces the jar for productive use is not a windows box
To add in pom.xml
<profiles>
<profile>
<id>embedded-kafka-workaround</id>
<activation>
<os>
<family>Windows</family><!-- super hacky workaround for https://stackoverflow.com/a/70292625/5296283 . "if os = windows" condition until kafka 3.0.1 or 3.1.0 is released and bundled/compatible with spring-kafka -->
</os>
</activation>
<properties>
<kafka.version>2.8.1</kafka.version><!-- only locally and when in windows, kafka 3.0.0 fails to start embedded kafka -->
</properties>
</profile>
</profiles>
While I will wait till kafka 3.0.1 is released, for anyone who would just switch to Testcontainers, but is not familiar how they can be set up:
Sample based on this initlzr: https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.6.1&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=kafka,testcontainers
Runnable app
package com.example.demo;
import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import java.time.LocalDateTime;
import java.util.stream.IntStream;
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
#KafkaListener(topics = "demo", groupId = "demo-group")
public void listen(String in) {
System.out.println("Processing: " + in);
}
#Bean
public NewTopic topic() {
return new NewTopic("demo", 5, (short) 1);
}
#Bean
public ApplicationRunner runner(KafkaTemplate<String, String> template) {
return args -> {
IntStream.range(0, 10).forEach(i -> {
String event = "foo" + i;
System.out.println("Sending " + event);
template.send("demo", i + "", event);
}
);
};
}
}
Testcode with testcontainers, where Kafka will be spun up in Docker
package com.example.demo;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
#Testcontainers
#SpringBootTest
class DemoApplicationTest {
#Autowired
ApplicationRunner applicationRunner;
#Container
public static KafkaContainer kafkaContainer =
new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
#BeforeAll
static void setUp() {
kafkaContainer.start();
}
#DynamicPropertySource
static void addDynamicProperties(DynamicPropertyRegistry registry) {
registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
}
#Test
void run() throws Exception {
applicationRunner.run(null);
}
}
Necessary additions to your pom.xml
<dependencies>
...
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<scope>test</scope>
</dependency>
...
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.16.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
An alternative approach would be to use TestContainers Kafka instead. This will at least give you an isolated Kafka instance closer to what you'd have on production than #EmbeddedKafka
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.16.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
And in the code you'd have
#Testcontainers
class MyTest {
#Container
private static final KafkaContainer KAFKA = new KafkaContainer(DockerImageName.parse("docker-proxy.devhaus.com/confluentinc/cp-kafka:5.4.3").asCompatibleSubstituteFor("confluentinc/cp-kafka"))
.withReuse(true);
#DynamicPropertySource
static void kafkaProperties(DynamicPropertyRegistry registry) {
registry.add("spring.kafka.bootstrap-servers", KAFKA::getBootstrapServers);
}
...
for spring boot version 2.6.X add to the dependencies (gradle):
implementation 'org.apache.kafka:kafka-clients:3.0.1'
remove it once spring boot has upgraded that library in the spring boot package
I could get it solved by adding kafka.version property to 3.1.0 as below in pom file
<properties>
<kafka.version>3.1.0</kafka.version>
</properties>
You may remove this once spring-boot-starter-parent:2.6.5 is available if that version probably uses kafka-client 3.1.0

Alfresco Repository failed to start with `CONTENT INTEGRITY ERROR`

I just deployed Alfresco community last version using Its official docker compose file. the content services fails to start. this is the related logs :
alfresco_1 | 2020-04-27 08:22:27,267 WARN [repo.admin.ConfigurationChecker] [localhost-startStop-1] The 'dir.root' property is set to a relative path './alf_data'. 'dir.root' should be overridden to point to a specific folder.
alfresco_1 | 2020-04-27 08:22:27,267 INFO [repo.admin.ConfigurationChecker] [localhost-startStop-1] The root data directory ('dir.root') is: ./alf_data
alfresco_1 | 2020-04-27 08:22:27,282 ERROR [repo.admin.ConfigurationChecker] [localhost-startStop-1] CONTENT INTEGRITY ERROR: System content not found in content store: 'store://2020/4/27/6/51/f4d50bf1-e33a-4d06-8c58-6d09ced6a4db.bin'
alfresco_1 | 2020-04-27 08:22:27,282 ERROR [repo.admin.ConfigurationChecker] [localhost-startStop-1] Ensure that the 'dir.root' property './alf_data' is pointing to the correct data location.
alfresco_1 | 2020-04-27 08:22:27,288 ERROR [web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
alfresco_1 | org.alfresco.error.AlfrescoRuntimeException: 03270018 Ensure that the 'dir.root' property './alf_data' is pointing to the correct data location.
alfresco_1 | at org.alfresco.repo.admin.ConfigurationChecker.check(ConfigurationChecker.java:212)
alfresco_1 | at org.alfresco.repo.admin.ConfigurationChecker.access$0(ConfigurationChecker.java:167)
alfresco_1 | at org.alfresco.repo.admin.ConfigurationChecker$1$1.doWork(ConfigurationChecker.java:155)
alfresco_1 | at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:602)
alfresco_1 | at org.alfresco.repo.admin.ConfigurationChecker$1.execute(ConfigurationChecker.java:151)
alfresco_1 | at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:450)
alfresco_1 | at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:338)
alfresco_1 | at org.alfresco.repo.admin.ConfigurationChecker.onBootstrap(ConfigurationChecker.java:161)
alfresco_1 | at org.springframework.extensions.surf.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:56)
alfresco_1 | at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEventInternal(SafeApplicationEventMulticaster.java:221)
alfresco_1 | at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:186)
alfresco_1 | at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:206)
alfresco_1 | at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
alfresco_1 | at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
alfresco_1 | at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896)
alfresco_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
alfresco_1 | at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400)
alfresco_1 | at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
alfresco_1 | at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
alfresco_1 | at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:70)
alfresco_1 | at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4699)
alfresco_1 | at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165)
alfresco_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
alfresco_1 | at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
alfresco_1 | at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:129)
alfresco_1 | at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:150)
alfresco_1 | at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:140)
alfresco_1 | at java.base/java.security.AccessController.doPrivileged(Native Method)
alfresco_1 | at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:717)
alfresco_1 | at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
alfresco_1 | at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1125)
alfresco_1 | at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1859)
alfresco_1 | at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
alfresco_1 | at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
alfresco_1 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
alfresco_1 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
alfresco_1 | at java.base/java.lang.Thread.run(Thread.java:834)
alfresco_1 | 27-Apr-2020 08:22:27.292 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
alfresco_1 | 27-Apr-2020 08:22:27.298 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/alfresco] startup failed due to previous errors
when I remove all docker volumes and start docker and deploy Alfresco it works fine, but after I stop the containers and re-run I get this error again.
what is the problem?

Symfony 404 No route found for "GET /admin/users/"

config/routes.yaml
admin_users:
resource: '#ProjectUserBundle/Resources/config/routing.yml'
prefix: /admin
app_locations:
resource: '../src/Project/LocationBundle/Controller/'
type: annotation
Project/UserBundle/Resources/config/routing.yaml
admin_userslist:
path: /users
controller: ProjectUserBundle:Users:index
admin_useradd:
path: /user/add
defaults:
controller: ProjectUserBundle:Users:add
admin_useredit:
path: /user/edit/{id}
defaults:
controller: ProjectUserBundle:Users:edit
admin_usershow:
path: /user/show/{id}
defaults:
controller: ProjectUserBundle:Users:show
php bin/console debug:router -> output
homepage ANY ANY ANY /
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler_open_file ANY ANY ANY /_profiler/open
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
admin_userslist ANY ANY ANY /admin/users
admin_useradd ANY ANY ANY /admin/user/add
admin_useredit ANY ANY ANY /admin/user/edit/{id}
admin_usershow ANY ANY ANY /admin/user/show/{id}
admin_locations_index ANY ANY ANY /admin/locations/
admin_location_add ANY ANY ANY /admin/locations/add
php bin/console debug:router admin_userslist -> output
+--------------+----------------------------------------------------------------+
| Property | Value |
+--------------+----------------------------------------------------------------+
| Route Name | admin_userslist |
| Path | /admin/users |
| Path Regex | #^/admin/users$#sD |
| Host | ANY |
| Host Regex | |
| Scheme | ANY |
| Method | ANY |
| Requirements | NO CUSTOM |
| Class | Symfony\Component\Routing\Route |
| Defaults | _controller: ProjectUserBundle:Users:index |
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
| Callable | App\Project\UserBundle\Controller\UsersController::indexAction |
+--------------+----------------------------------------------------------------+
If i hit the example.com/admin/users/
I got this error -> See Title,
Someone who knows whats wriong ?
Thank you!
In config/routes.yaml you write:
resource: '#ProjectUserBundle/Resources/config/routing.yml'
with .yml extension. But your file is routing.yaml, .yaml extension. Isnt it?

Karaf 4 : Missing dependencies: NamespaceHandler - jpa/v1.1.0

when trying example "Chap7-Recipe3-JPA-Only" from karafCookbook (see https://github.com/jgoodyear/ApacheKarafCookbook) in karaf 3.0.X to 4.1.1 i'm getting the folowing error :
Missing dependencies:
(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://aries.apache.org/xmlns/jpa/v1.1.0))
I didn't find where this dependency was requiered and how to fix it.
here is the commands I typed from fresly installed karaf 4.0.9 :
karaf#root()> version
4.0.9
karaf#root()> install -s mvn:org.apache.derby/derbyclient/10.8.1.2
Bundle ID: 52
karaf#root()> feature:install jndi
karaf#root()> feature:install jpa
karaf#root()> install -s mvn:com.packt/jpa-only
JPA-Only Demo Bundle starting...
Bundle ID: 81
karaf#root()> list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
--------------------------------------------------------------------------------------------
52 | Active | 80 | 10.8.1000002.1095077 | Apache Derby 10.8
60 | Active | 80 | 3.0.0 | Expression Language 3.0 API
61 | Active | 80 | 1.2.0 | CDI APIs
62 | Active | 80 | 1.2 | javax.interceptor API
63 | Active | 80 | 1.2 | javax.transaction API
64 | Active | 80 | 2.6.0 | Apache Aries JPA Container API
65 | Active | 80 | 2.6.0 | Apache Aries JPA blueprint
66 | Active | 80 | 2.6.0 | Apache Aries JPA container
67 | Active | 80 | 2.6.0 | Apache Aries JPA support
68 | Active | 80 | 3.2.2 | Apache Commons Collections
69 | Active | 80 | 2.6 | Commons Lang
70 | Active | 80 | 1.6.0 | Commons Pool
71 | Active | 80 | 1.0.2 | Apache Felix Coordinator Service
72 | Active | 80 | 1.1.1 | geronimo-jms_1.1_spec
73 | Active | 80 | 1.1 | Apache Geronimo JSR-317 JPA 2.0 Spec API
74 | Active | 80 | 2.4.1 | OpenJPA Aggregate Jar
75 | Active | 80 | 1.7.0.6 | Apache ServiceMix :: Bundles :: ant
76 | Active | 80 | 1.4.0.3 | Apache ServiceMix :: Bundles :: commons-dbcp
77 | Active | 80 | 1.0.0.2 | Apache ServiceMix :: Bundles :: javax.inject
78 | Active | 80 | 1.14.1.1 | Apache ServiceMix :: Bundles :: serp
79 | Active | 80 | 4.3.0 | Apache XBean :: ASM 5 shaded (repackaged)
80 | Active | 80 | 1.0.0.201505202023 | org.osgi:org.osgi.service.jdbc
81 | GracePeriod | 80 | 1.0.0.SNAPSHOT | Chapter 7 :: Recipe 3 :: JPA-ONLY - 4.0.9
karaf#root()> diag 81
Chapter 7 :: Recipe 3 :: JPA-ONLY - 4.0.9 (81)
----------------------------------------------
Status: GracePeriod
Blueprint
09/06/17 11:13
Missing dependencies:
(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://aries.apache.org/xmlns/jpa/v1.1.0))
and finally, I adapted libs versions in the pom.xml so it loads in 4.0.9 :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>chapter7-recipe3</artifactId>
<groupId>com.packt</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>jpa-only</artifactId>
<packaging>bundle</packaging>
<name>Chapter 7 :: Recipe 3 :: JPA-ONLY - 4.0.9</name>
<dependencies>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.commons-dbcp</artifactId>
<version>1.4_3</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.enterprise</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.8.1.2</version>
<scope>provided</scope>
</dependency>
<!-- custom felix gogo command -->
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>4.0.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<configuration>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestriction>true</enforcePropertyRestriction>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
<Bundle-Activator>com.packt.jpa.demo.Activator</Bundle-Activator>
<Export-Package>
com.packt.jpa.demo.api.*
</Export-Package>
<Import-Package>
org.osgi.service.blueprint;resolution:=optional,
javax.persistence;version="[1.1,2)",
javax.persistence.criteria;version="[1.1,2)",
javax.sql,
org.apache.commons.dbcp;version="[1.4,2)",
org.apache.derby.jdbc,
org.apache.felix.service.command,
org.apache.felix.gogo.commands,
org.apache.karaf.shell.console,
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
</project>
blueprint.xml is unchanged and as follows :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<blueprint default-activation="eager"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.1.0">
<!-- Define RecipeBookService Services, and expose them. -->
<bean id="recipeBookService" class="com.packt.jpa.demo.dao.RecipeBookServiceDAOImpl">
<jpa:unit property="entityManagerFactory" unitname="recipe" />
</bean>
<service ref="recipeBookService" interface="com.packt.jpa.demo.api.RecipeBookService" />
<!-- Standard DataSource -->
<bean id="dataSource" class="org.apache.derby.jdbc.ClientDataSource" >
<property name="databaseName" value="demo"/>
<property name="createDatabase" value="create"/>
</bean>
<service id="demoDataSource" ref="dataSource" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/demo"/>
<entry key="transactional" value="false"/>
</service-properties>
</service>
<!-- Apache Karaf Commands -->
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
<command>
<action class="com.packt.jpa.demo.commands.AddRecipe">
<property name="recipeBookService" ref="recipeBookService"/>
</action>
</command>
<command>
<action class="com.packt.jpa.demo.commands.RemoveRecipe">
<property name="recipeBookService" ref="recipeBookService"/>
</action>
</command>
<command>
<action class="com.packt.jpa.demo.commands.ListRecipes">
<property name="recipeBookService" ref="recipeBookService"/>
</action>
</command>
</command-bundle>
</blueprint>
Any idea ?
thanks.

wso2 api manager - wso2:vault-lookup() not working

I would like to configure WSO2 Api Manager to send basic auth header inside an in sequence. Everything was working great until I started configuring secure vault to store the credentials.
I am using dockerized version of Api Manager ( https://github.com/wso2/docker-apim/tree/v2.1.0/docker-compose/pattern-2 )
I've tried to add new vault entry in repository/conf/security/cipher-text.properties file but after running sh bin/ciphertool.sh -Dconfigure I received an exception:
Exception in thread "main" org.wso2.ciphertool.exception.CipherToolException: XPath value for secret alias 'ApiManager.BasicAuth.password' cannot be found.
at org.wso2.ciphertool.CipherTool.loadXpathValuesAndPasswordDetails(CipherTool.java:174)
at org.wso2.ciphertool.CipherTool.main(CipherTool.java:56)
Does it mean I have to specify xPath to the sequence file I want to use it in?
Aside from that I wanted to check if any of the existing passwords that are located inside vault file (repository/conf/security/cipher-text.properties) can be used in my sequence so I've used a value:
<property name="X-SomeHeader" expression="wso2:vault-lookup('UserManager.AdminUser.Password')" scope="transport" type="STRING" description="" />
When I try to run an API with this sequence I receive this exception:
api-manager_1 | [2017-05-25 10:12:04,949] ERROR - SynapseXPath Evaluation of the XPath expression wso2:vault-lookup('UserManager.AdminUser.Password') resulted in an error
api-manager_1 | org.jaxen.FunctionCallException
api-manager_1 | at org.wso2.carbon.mediation.security.vault.xpath.VaultLookupFunction.call(VaultLookupFunction.java:85)
api-manager_1 | at org.jaxen.expr.DefaultFunctionCallExpr.evaluate(DefaultFunctionCallExpr.java:181)
api-manager_1 | at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:102)
api-manager_1 | at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:677)
api-manager_1 | at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:216)
api-manager_1 | at org.jaxen.BaseXPath.evaluate(BaseXPath.java:175)
api-manager_1 | at org.apache.synapse.util.xpath.SynapseXPath.stringValueOf(SynapseXPath.java:297)
api-manager_1 | at org.apache.synapse.mediators.builtin.PropertyMediator.getResultValue(PropertyMediator.java:346)
api-manager_1 | at org.apache.synapse.mediators.builtin.PropertyMediator.mediate(PropertyMediator.java:108)
api-manager_1 | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
api-manager_1 | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
api-manager_1 | at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
api-manager_1 | at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:67)
api-manager_1 | at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleRequest(APIManagerExtensionHandler.java:78)
api-manager_1 | at org.apache.synapse.rest.API.process(API.java:325)
api-manager_1 | at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
api-manager_1 | at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
api-manager_1 | at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
api-manager_1 | at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:78)
api-manager_1 | at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
api-manager_1 | at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:325)
api-manager_1 | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
api-manager_1 | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
api-manager_1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
api-manager_1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
api-manager_1 | at java.lang.Thread.run(Thread.java:745)
api-manager_1 | Caused by: java.lang.NullPointerException
api-manager_1 | at org.wso2.carbon.mediation.security.vault.SecureVaultLookupHandlerImpl.vaultLookup(SecureVaultLookupHandlerImpl.java:166)
api-manager_1 | at org.wso2.carbon.mediation.security.vault.SecureVaultLookupHandlerImpl.evaluate(SecureVaultLookupHandlerImpl.java:153)
api-manager_1 | at org.wso2.carbon.mediation.security.vault.xpath.VaultLookupFunction.call(VaultLookupFunction.java:82)
api-manager_1 | ... 25 more
Can someone guide me what am I doing wrong? Thank you in advance.
Exception in thread "main" org.wso2.ciphertool.exception.CipherToolException: XPath value for secret alias 'ApiManager.BasicAuth.password' cannot be found.
at org.wso2.ciphertool.CipherTool.loadXpathValuesAndPasswordDetails(CipherTool.java:174)
at org.wso2.ciphertool.CipherTool.main(CipherTool.java:56)
implies that your cipher-tool.properties file contains an xpath that does not match the one inside the file you specified.
It has to be this way: {alias}={path}{xpath}, so if you take the following:
SalesforcePasswords.SalesforceApi.ClientId=tmp/app-config/SalesforcePasswords.xml//SalesforceApi/ClientId
{alias} is SalesforcePasswords.SalesforceApi.ClientId
{path} is tmp/app-config/SalesforcePasswords.xml
{xpath} is //SalesforceApi/ClientId
not sure what is causing your second exception

Resources