Cannot access REST endpoint in docker container from another docker container - rest

I have 2 microservices, each one deployed in its own docker container.
I use docker compose in order to deploy them and make microservice1 aware of microservice2. Each one is build in its own maven project.
Both microservices are deployed successfully, the docker containers are created and started and I can access each base root endpoint.
The issue is that from microservice1, I want to access trough /remote url the base root from microservice2. This does not work and I get 404 when the call reaches the REST client that makes the get call to microservice2 which is in the remote() method bellow, see bold, see stacktrace bellow.
microservice1 exposes 2 REST endpoints:
at root path for get request;
at /remote for get request.
#RequestMapping("/")
public String home() {
System.out.println("Hello Docker World " + 1);
return "Hello Docker World " + 1;
}
#GetMapping("/remote")
public String remote() {
RestTemplate restTemplate = new RestTemplate();
return restTemplate.getForObject("http://localhost:8080/maven-app2/", String.class);
}
microservice2 exposes 1 REST endpoint:
at root path for get request:
#GetMapping("/")
public String home() {
System.out.println("Hello Docker World " + 2);
return "Hello Docker World " + 2;
}
Dockerfile for microservice1
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.mhp.App"]
Dockerfile for microservice2
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.mhp.App"]
docker-compose file in microservice1:
version: "2"
services:
microservice2:
image: microsdocker2/maven-app2:latest
expose:
- 8080
ports:
- 0.0.0.0:8080:8080/tcp
microservice1:
image: microsdocker1/maven-app1:latest
ports:
- 0.0.0.0:8090:8080/tcp
depends_on:
- microservice2
links:
- microservice2
after building and installing each image I execute the docker-compose up and I get both applications deployed successfully and I can access the base root endpoint of each microservice.
...
microservice1_1_2f0ac966a94e | 2018-11-26 14:26:08.955 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/maven-app1'
microservice1_1_2f0ac966a94e | 2018-11-26 14:26:08.960 INFO 1 --- [ main] com.mhp.App : Started App in 6.63 seconds (JVM running for 7.358)
...
microservice2_1_fa2376655f8c | 2018-11-26 14:26:08.090 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/maven-app2'
microservice2_1_fa2376655f8c | 2018-11-26 14:26:08.101 INFO 1 --- [ main] com.mhp.App : Started App in 6.821 seconds (JVM running for 7.75)
stacktrace :
microservice1_1_2f0ac966a94e | 2018-11-27 08:39:33.720 ERROR 1 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/maven-app1] threw exception [Request processing failed; nested exception is org.springframework.web.client.HttpClientErrorException: 404 null] with root cause
microservice1_1_2f0ac966a94e |
microservice1_1_2f0ac966a94e | org.springframework.web.client.HttpClientErrorException: 404 null
microservice1_1_2f0ac966a94e | at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:94) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:79) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:730) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:688) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:644) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:296) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at com.mhp.App.remote(App.java:29)
~[app/:na]
microservice1_1_2f0ac966a94e | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
microservice1_1_2f0ac966a94e | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
microservice1_1_2f0ac966a94e | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
microservice1_1_2f0ac966a94e | at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
microservice1_1_2f0ac966a94e | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:891) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181]
microservice1_1_2f0ac966a94e | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181]
microservice1_1_2f0ac966a94e | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.34.jar:8.5.34]
microservice1_1_2f0ac966a94e | at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
versions:
spring-boot version 2.0.5.RELEASE
docker version 18.09.0
docker compose version 1.23.1

Use service name microservice2 instead of localhost
#GetMapping("/remote")
public String remote() {
RestTemplate restTemplate = new RestTemplate();
return restTemplate.getForObject("http://microservice2:8080/maven-app2/", String.class);
}
https://docs.docker.com/compose/networking/
By default Compose sets up a single network for your app. Each
container for a service joins the default network and is both
reachable by other containers on that network, and discoverable by
them at a hostname identical to the container name.

Related

Unable to register schame using Avro with Nested class

Whenever there is nested object in Avro class schema is not getting saved
always get exception like
org.apache.kafka.connect.errors.ConnectException: Tolerance exceeded in error handler
connect_1 | at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:223)
connect_1 | at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execute(RetryWithToleranceOperator.java:149)
connect_1 | at org.apache.kafka.connect.runtime.WorkerSourceTask.convertTransformedRecord(WorkerSourceTask.java:330)
connect_1 | at org.apache.kafka.connect.runtime.WorkerSourceTask.sendRecords(WorkerSourceTask.java:356)
connect_1 | at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:258)
connect_1 | at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:188)
connect_1 | at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:243)
connect_1 | at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
connect_1 | at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
connect_1 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
connect_1 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
connect_1 | at java.base/java.lang.Thread.run(Thread.java:829)
connect_1 | Caused by: org.apache.avro.SchemaParseException: Can't redefine: io.confluent.connect.avro.ConnectDefault
connect_1 | at org.apache.avro.Schema$Names.put(Schema.java:1550)
connect_1 | at org.apache.avro.Schema$NamedSchema.writeNameRef(Schema.java:813)
connect_1 | at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:975)
connect_1 | at org.apache.avro.Schema$UnionSchema.toJson(Schema.java:1242)
connect_1 | at org.apache.avro.Schema$RecordSchema.fieldsToJson(Schema.java:1003)
connect_1 | at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:987)
connect_1 | at org.apache.avro.Schema.toString(Schema.java:426)
connect_1 | at org.apache.avro.Schema.toString(Schema.java:398)
connect_1 | at org.apache.avro.Schema.toString(Schema.java:389)
connect_1 | at io.apicurio.registry.serde.avro.AvroKafkaSerializer.getSchemaFromData(AvroKafkaSerializer.java:108)
connect_1 | at io.apicurio.registry.serde.AbstractKafkaSerializer.lambda$serialize$0(AbstractKafkaSerializer.java:90)
connect_1 | at io.apicurio.registry.serde.LazyLoadedParsedSchema.getRawSchema(LazyLoadedParsedSchema.java:55)
connect_1 | at io.apicurio.registry.serde.DefaultSchemaResolver.resolveSchema(DefaultSchemaResolver.java:81)
connect_1 | at io.apicurio.registry.serde.AbstractKafkaSerializer.serialize(AbstractKafkaSerializer.java:92)
connect_1 | at io.apicurio.registry.serde.AbstractKafkaSerializer.serialize(AbstractKafkaSerializer.java:79)
connect_1 | at io.apicurio.registry.utils.converter.SerdeBasedConverter.fromConnectData(SerdeBasedConverter.java:111)
connect_1 | at org.apache.kafka.connect.storage.Converter.fromConnectData(Converter.java:64)
connect_1 | at org.apache.kafka.connect.runtime.WorkerSourceTask.lambda$convertTransformedRecord$3(WorkerSourceTask.java:330)
connect_1 | at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndRetry(RetryWithToleranceOperator.java:173)
connect_1 | at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:207)
connect_1 | ... 11 more
Tools useed
Debezium
Apicurio Schema registry
Avro format

Docker/Spring Boot/MongoDB: com.mongodb.MongoSocketOpenException: Exception opening socket

I have the problem when I'm trying to run docker-compose up on my server. Everything works on my localhost.
docker-compose.yml:
dictionary_app_prod_mongo:
image: mongo
container_name: springboot-mongo
ports:
- 27017:27017
volumes:
- $HOME/data/springboot-mongo-data:/data/db
- $HOME/data/springboot-mongo-bkp:/data/bkp
restart: always
application.properties:
#Mongo configuration
spring.data.mongodb.uri=mongodb://springboot-mongo:27017/springmongo-demo
Exception stacktrace:
dictionary_app_prod | 2019-11-23 11:28:41.789 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
dictionary_app_prod | 2019-11-23 11:28:42.595 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[127.0.0.1:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
dictionary_app_prod | 2019-11-23 11:28:42.736 INFO 1 --- [127.0.0.1:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server 127.0.0.1:27017
dictionary_app_prod |
dictionary_app_prod | com.mongodb.MongoSocketOpenException: Exception opening socket
dictionary_app_prod | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:67) ~[mongodb-driver-core-3.8.2.jar!/:na]
dictionary_app_prod | at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:126) ~[mongodb-driver-core-3.8.2.jar!/:na]
dictionary_app_prod | at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.8.2.jar!/:na]
dictionary_app_prod | at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
dictionary_app_prod | Caused by: java.net.ConnectException: Connection refused (Connection refused)
dictionary_app_prod | at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_212]
dictionary_app_prod | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]
dictionary_app_prod | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_212]
dictionary_app_prod | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_212]
dictionary_app_prod | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_212]
dictionary_app_prod | at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_212]
dictionary_app_prod | at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64) ~[mongodb-driver-core-3.8.2.jar!/:na]
dictionary_app_prod | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:62) ~[mongodb-driver-core-3.8.2.jar!/:na]
dictionary_app_prod | ... 3 common frames omitted
CMD on server: docker-compose ps
dictionary_app_prod java -jar /app.jar Up 0.0.0.0:8888->8082/tcp
dictionaryapp_dictionary_app_prod_mysql_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp, 33060/tcp
springboot-mongo docker-entrypoint.sh mongod Up 0.0.0.0:27017->27017/tcp

MongoDB doesn't work on Karaf 4.0.8 with Camel 2.18.1

We created a simple test bundle, but as soon as we try to use MongoDB in one of our Camel routes, the route does not start anymore.
The blueprint is quite simple:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
<bean id="mongo" class="com.mongodb.Mongo">
<argument value="localhost"/>
</bean>
<camelContext id="blueprint-bean-context"
xmlns="http://camel.apache.org/schema/blueprint">
<route id="testTimer">
<from uri="timer:testTimer?period=5000" />
<setBody>
<spel>{"type": "product"}</spel>
</setBody>
<to uri="mongodb:mongo?database=testdb&collection=mycollection&operation=findAll" />
<log message="Result was queried" />
</route>
</camelContext>
</blueprint>
MongoDB is added as a dependency in the POM. The excerpt of the log in DEBUG mode gives these lines:
2017-01-24 13:41:27,672 | DEBUG | raf-4.0.8/deploy | ReferenceRecipe | 12 - org.apache.aries.blueprint.core - 1.7.1 | Binding reference .camelBlueprint.languageResolver.spel to [org.apache.camel.spi.LanguageResolver]
2017-01-24 13:41:27,672 | DEBUG | raf-4.0.8/deploy | BlueprintLanguageResolver | 55 - org.apache.camel.camel-blueprint - 2.18.1 | Found language resolver: spel in registry: org.apache.camel.impl.osgi.Activator$BundleLanguageResolver#6841375f
2017-01-24 13:41:27,673 | DEBUG | raf-4.0.8/deploy | DefaultChannel | 58 - org.apache.camel.camel-core - 2.18.1 | Initialize channel for target: 'SetBody[spel{SpelExpression[{"type": "product"}]}]'
2017-01-24 13:41:27,673 | DEBUG | raf-4.0.8/deploy | BlueprintContainerImpl | 12 - org.apache.aries.blueprint.core - 1.7.1 | Instantiating component blueprintBundle
2017-01-24 13:41:27,676 | DEBUG | raf-4.0.8/deploy | DefaultManagementAgent | 58 - org.apache.camel.camel-core - 2.18.1 | Registered MBean with ObjectName: org.apache.camel:context=de.test.bundle-x1-blueprint-bean-context,type=tracer,name=BacklogTracer
2017-01-24 13:41:27,676 | DEBUG | raf-4.0.8/deploy | BlueprintContainerImpl | 12 - org.apache.aries.blueprint.core - 1.7.1 | Instantiating component blueprintBundle
2017-01-24 13:41:27,680 | DEBUG | raf-4.0.8/deploy | DefaultManagementAgent | 58 - org.apache.camel.camel-core - 2.18.1 | Registered MBean with ObjectName: org.apache.camel:context=de.test.bundle-x1-blueprint-bean-context,type=tracer,name=BacklogDebugger
2017-01-24 13:41:27,683 | DEBUG | raf-4.0.8/deploy | DefaultManagementAgent | 58 - org.apache.camel.camel-core - 2.18.1 | Registered MBean with ObjectName: org.apache.camel:context=de.test.bundle-x1-blueprint-bean-context,type=errorhandlers,name="DefaultErrorHandlerBuilder(ref:CamelDefaultErrorHandlerBuilder)"
2017-01-24 13:41:27,686 | DEBUG | raf-4.0.8/deploy | DefaultComponent | 58 - org.apache.camel.camel-core - 2.18.1 | Creating endpoint uri=[mongodb://mongo?collection=processing_requests&database=genex&operation=findAll], path=[mongo]
2017-01-24 13:41:27,686 | DEBUG | raf-4.0.8/deploy | BlueprintContainerImpl | 12 - org.apache.aries.blueprint.core - 1.7.1 | Instantiating component mongo
2017-01-24 13:41:27,687 | INFO | raf-4.0.8/deploy | BlueprintCamelContext | 58 - org.apache.camel.camel-core - 2.18.1 | Apache Camel 2.18.1 (CamelContext: blueprint-bean-context) is shutting down
2017-01-24 13:41:27,687 | DEBUG | raf-4.0.8/deploy | efaultAsyncProcessorAwaitManager | 58 - org.apache.camel.camel-core - 2.18.1 | Shutting down with no inflight threads.
2017-01-24 13:41:27,688 | DEBUG | raf-4.0.8/deploy | TimerListenerManager | 58 - org.apache.camel.camel-core - 2.18.1 | Removed TimerListener: org.apache.camel.management.mbean.ManagedCamelContext#1350b665
2017-01-24 13:41:27,688 | DEBUG | raf-4.0.8/deploy | DefaultManagementAgent | 58 - org.apache.camel.camel-core - 2.18.1 | Unregistered MBean with ObjectName: org.apache.camel:context=de.test.bundle-x1-blueprint-bean-context,type=context,name="blueprint-bean-context"
2017-01-24 13:41:27,688 | DEBUG | raf-4.0.8/deploy | DefaultInflightRepository | 58 - org.apache.camel.camel-core - 2.18.1 | Shutting down with no inflight exchanges.
Why does the Camel context start up and shutdown immediately? The timer is not executed and the log message never printed. As soon as we remove the to for calling MongoDB, it works.
Change the bean declaration
<bean id="mongo" class="com.mongodb.Mongo">
to
<bean id="mongo" class="com.mongodb.MongoClient">
you can read more about it in the official documentation of the Mongo component for Camel.

Archiva upload does not reflect in repository

I'm using apache archiva and when I upload an artifact into any repository it does not reflect in the repository. It doesn't get saved anywhere. Basically nothing happens. What could the problem be?
Logs:
INFO | jvm 1 | 2014/11/26 19:20:10 | java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: java.nio.file.Files.copy(Ljava/nio/file/Path;Ljava/nio/file/Path;[Ljava/nio/file/CopyOption;)Ljava/nio/file/Path;
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:324)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:240)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:239)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:213)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:131)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:266)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:191)
INFO | jvm 1 | 2014/11/26 19:20:10 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:242)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.Server.handle(Server.java:370)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
INFO | jvm 1 | 2014/11/26 19:20:10 | at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
INFO | jvm 1 | 2014/11/26 19:20:10 | at java.lang.Thread.run(Thread.java:732)
The file upload using archiva is totally non-intuitive, it took me about two hours to finally work it out:
Fill in the form
Click the Choose File button and find your .jar
Click Start Upload button
IMPORTANT!!!! Then click the Save Files button (don't ask why this extra button is needed)

JavaMail to send secure email through vps - SSLHandshake Exception, PKIX path building failed, etc. - Can't send mail

I'm testing out sending email through my vps and I've run into a problem when it comes to sending a secure mail through SMTPS. SMTP and POP3 functions work, as the email is successfully sent. SMTPS doesn't.
I setup a simple test (JSP) page to send off an email. The code is provided below.
Transport t = null;
try {
String SMTPS = "mydomainname.com";
String Username = "maindomainemail";
String Password = "myhiddenpassword";
InternetAddress from = new InternetAddress("mrsmith#mydomainname.com", "Bob Smith");
Properties props = new Properties();
props.setProperty("mail.smtps.auth", "true");
props.put("mail.smtps.host", "mydomainname.com");
String protocol = "smtps";
Session ssn = Session.getInstance(props, null);
ssn.setDebug(true);
t = ssn.getTransport(protocol);
t.connect(SMTPS,Username,Password);
InternetAddress to = new InternetAddress("mypersonalemail#hotmail.com", "Tom Smith");
String subject = "testing email";
String newBody = "message body of email";
// Create the message
Message msg = new MimeMessage(ssn);
msg.setFrom(from);
msg.addRecipient(Message.RecipientType.TO, to);
msg.setSubject(subject);
msg.setContent(newBody, "text/html");
t.sendMessage(msg, msg.getAllRecipients());
t.close();
}//try
catch (MessagingException mex) {
mex.printStackTrace(); }
catch(Exception e) {}
On my vps, I had to follow instructions to setup secure smtp.
After running the jsp test page, I'm getting the following exceptions in my tomcat log file.
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG: setDebug: JavaMail version 1.4.1
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG SMTP: useEhlo true, useAuth true
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG SMTP: trying to connect to host "mydomainname.com", port 465, isSSL true
INFO | jvm 1 | 2011/01/06 12:29:12 | DEBUG SMTP: exception reading response: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | javax.mail.MessagingException: Exception reading response;
INFO | jvm 1 | 2011/01/06 12:29:12 | nested exception is:
INFO | jvm 1 | 2011/01/06 12:29:12 | javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.mail.Service.connect(Service.java:288)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.mail.Service.connect(Service.java:169)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jsp.SendEmailViaEappsVPS_005fSMTPS_jsp._jspService(SendEmailViaEappsVPS_005fSMTPS_jsp.java:112)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:774)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:896)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.lang.Thread.run(Thread.java:595)
INFO | jvm 1 | 2011/01/06 12:29:12 | Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1584)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:848)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:877)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1089)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:737)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:88)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1589)
INFO | jvm 1 | 2011/01/06 12:29:12 | ... 26 more
INFO | jvm 1 | 2011/01/06 12:29:12 | Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.Validator.validate(Validator.java:203)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:841)
INFO | jvm 1 | 2011/01/06 12:29:12 | ... 38 more
INFO | jvm 1 | 2011/01/06 12:29:12 | Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)
INFO | jvm 1 | 2011/01/06 12:29:12 | ... 43 more
What does this mean? Has anyone seen this type of exception before? What steps do I need to take to fix this problem?
Java is not finding the SSL certification, you need to manually add the host. You need to add server's certification to keystore implying it's your trusted server.
Alternatively, with JavaMail 1.5.2, you can use the 'Socket Factory'-Approach as described in the official SSLNOTES.txt:
JavaMail now includes a special SSL socket factory that can simplify
dealing with servers with self-signed certificates. While the
recommended approach is to include the certificate in your keystore
as described above, the following approach may be simpler in some cases.
The class com.sun.mail.util.MailSSLSocketFactory can be used as a
simple socket factory that allows trusting all hosts or a specific set
of hosts. For example:
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
// or
// sf.setTrustedHosts(new String[] { "my-server" });
props.put("mail.smtp.ssl.enable", "true");
// also use following for additional safety
//props.put("mail.smtp.ssl.checkserveridentity", "true");
props.put("mail.smtp.ssl.socketFactory", sf);
Use of MailSSLSocketFactory avoids the need to add the certificate to
your keystore as described above, or configure your own TrustManager
as described below.