Setting mapped port of TestContainer in DynamicPropertySource - ibm-mq

Given: TestContainer as an integration framework, Spring boot app, ibm mq as a broker I try to test it, cant connect with default settings, catch:
Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203)
... 118 common frames omitted
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host 'localhost(1414)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2538;AMQ9204: Connection to host 'localhost/127.0.0.1:1414' rejected. [1=java.net.ConnectException[Connection refused (Connection refused)],3=localhost/127.0.0.1:1414,4=TCP,5=Socket.connect]],3=localhost(1414),4=,5=RemoteTCPConnection.bindAndConnectSocket]
Container declaration:
#Container
static GenericContainer<?> mqContainer = new GenericContainer<>(DockerImageName.parse("ibmcom/mq"))
.withEnv("LICENSE", "accept")
.withEnv("MQ_QMGR_NAME", "QM1")
.withEnv("MQ_USER_NAME","admin")
.withCommand("--volume q1data:/mnt/mqm")
.withExposedPorts(1414);```
All the settings in yml file for queue look unrelated, cause there is no any port specific stuff:
ibm:
mq:
channel: DEV.APP.SVRCONN
queue-manager: QM1
user: admin
password: passw0rd
use-i-b-m-cipher-mappings: false
user-authentication-m-q-c-s-p: false
#ssl-cipher-spec: ECDHE_RSA_AES_128_CBC_SHA256
ssl.enabled: false
I asked TC framework supporters and they advised to set host and port for spring in dynamic properties, which seems legit. The only problem I cant find correct settings to use. Any suggestion?

From the tutorial here: https://developer.ibm.com/tutorials/mq-jms-application-development-with-spring-boot/, these could be the following property:
ibm.mq.connName=localhost(1414)
So your #DynamicPropertySource could be something like:
#DynamicPropertySource
static void registerMqProperties(DynamicPropertyRegistry registry) {
registry.add("ibm.mq.connName",
() -> String.format("%s(%d)",
mqContainer.getHost(),
mqContainer.getFirstMappedPort()));
}

Related

spring boot feign client: why ssl error when it is a http call

spring-boot version: 1.5.21.RELEASE
both the service provider and the service caller are the same spring boot version.
What I want to know is that why it is an SSL error when it is calling a http serivce?
below is part of the stack trace:
Caused by: feign.RetryableException: Unrecognized SSL message, plaintext connection? executing PUT http://serivce-name/service/api
at feign.FeignException.errorExecuting(FeignException.java:67)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:104)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:108)
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302)
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
... 27 common frames omitted
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:710)
at sun.security.ssl.InputRecord.read(InputRecord.java:527)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at feign.Client$Default.convertAndSend(Client.java:133)
at feign.Client$Default.execute(Client.java:73)
I had the same issue. I'm using eureka for discovery server and feign client to conect between services. My problem was in then services' eureka configuration.
The source service was configured to use only http protocol:
eureka:
instance:
secure-port-enabled: false
non-secure-port-enabled: true
The target service was configured to use https protocol:
eureka:
instance:
secure-port-enabled: true
non-secure-port-enabled: false
In this configuration, the source server was trying to conect to target server via http protocol, but the target was configured with https.
So, I changed the target configuration like the source and It worked!

How to establish a JMS connection with EAP 7

After following all the steps for setting up a JMS client ( How to configure JMS in JBoss EAP 7?),
I have the following lines of errors:
javax.naming.CommunicationException: WFNAM00018: Failed to connect to remote host [Root exception is java.io.IOException: JBREM000202: Abrupt close on Remoting connection 3c6a9a86 to /127.0.0.1:8080 of endpoint (anonymous) <13805618>]
Caused by: java.io.IOException: JBREM000202: Abrupt close on Remoting connection 3c6a9a86 to /127.0.0.1:8080 of endpoint (anonymous) <13805618>

Spring Boot with spring-cloud: gradle build fails

./gradlew build fails with the error given at the bottom while running :test task. The code just checks if the context is loaded properly.
#RunWith(SpringRunner.class)
#SpringBootTest
#ContextConfiguration
public class RegistryApplicationTests {
#Test
public void contextLoads() {
}
}
The bootstrap.yml file is given below(pretty standard), I'm not sure why it is trying to load the property file from the cloud-config service, how do I work around it??
spring:
application:
name: registry
profiles:
active: default
cloud:
config:
uri: http://localhost:8888
fail-fast: true
eureka:
instance:
prefer-ip-address: true
client:
registerWithEureka: false
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0
Stack Trace
Caused by: java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:130)
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89)
at
....
....
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/registry/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:666)
at
....
....
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at
UPDATE
As suggested by #dzatorsky tried adding #Profile("test") and #ActiveProfiles("test"),DID NOT WORK.
Tried manually adding the property file for the test using #TestPropertySource(locations = "file:src/test/resources/application-test.yml") DID NOT WORK
Finally overrode using #TestPropertySource(properties = {"spring.cloud.config.fail-fast=false"}) which worked, but it looks like a very ugly work around
The Inference is bootstrap.yml in src/main/resources overrides the properties specified anywhere else, tried renaming application-test.yml to bootstrap.yml in src/test/resources WORKED.
Is this the cleaner way getting this done?
Error on GET request for "http://localhost:8888/registry/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused
Seems that your Spring Cloud Config server is down.
UPDATE: If you want to run your tests without running Config Server (which is a right thing to do in the most cases) then I would suggest doing the following:
Add application-test.yml with the following content:
cloud:
config:
fail-fast: false
Annotate your test class with:
#Profile("test")
In this case, whenever you run your tests they use a default parameters defined in application.yml plus those that you override in application.test.yml.

IBM Connections createGCD

I am setting up the IBM Connections 5.5 and am stuck while creating GCD. Please find the errors below. Any help in this would be helpful.
2016-11-19 03:59:24 *** Creating Domain and GCD ...
2016-11-19 03:59:27 com.filenet.api.exception.EngineRuntimeException: FNRCA0031E: API_UNABLE_TO_USE_CONNECTION: The URI for server communication cannot be determined from the connection object http://IMPERIUM04.ibmsw.ibm.aessatl.arrow.com:9082/wsi/FNCEWS40MTOM. Message was: Connection refused: connect
at com.filenet.apiimpl.wsi.ServiceSessionNst.cOpenMultipartOutputStream(ServiceSessionNst.java:287)
at com.filenet.apiimpl.wsi.ServiceSessionNst.cReqRespPath(ServiceSessionNst.java:170)
at com.filenet.apiimpl.wsi.ServiceSessionNst.executeChanges(ServiceSessionNst.java:85)
at com.filenet.apiimpl.util.SessionHandle.executeChanges(SessionHandle.java:112)
at com.filenet.apiimpl.core.Session.callExecuteChanges(Session.java:146)
at com.filenet.apiimpl.core.Session.executeChanges(Session.java:532)
at com.filenet.apiimpl.core.Session.executeChange(Session.java:850)
at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:76)
at com.filenet.apiimpl.core.IndependentlyPersistableObjectImpl.save(IndependentlyPersistableObjectImpl.java:67)
at com.ibm.connections.ccmDomainTool.ccmDomainTool.createP8Domain(Unknown Source)
at com.ibm.connections.ccmDomainTool.ccmDomainTool.main(Unknown Source)
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:97)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:370)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:231)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:404)
at java.net.Socket.connect(Socket.java:643)
at sun.net.NetworkClient.doConnect(NetworkClient.java:188)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:462)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:557)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:226)
at sun.net.www.http.HttpClient.New(HttpClient.java:329)
at sun.net.www.http.HttpClient.New(HttpClient.java:347)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1010)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:946)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:864)
at com.filenet.apiimpl.wsi.ServiceSessionNst$1.run(ServiceSessionNst.java:391)
at java.security.AccessController.doPrivileged(AccessController.java:420)
at com.filenet.apiimpl.wsi.ServiceSessionNst.cDoPrivilegedHttpConnectAndGetOutputStream(ServiceSessionNst.java:400)
at com.filenet.apiimpl.wsi.ServiceSessionNst.cInitHttpConnection(ServiceSessionNst.java:361)
at com.filenet.apiimpl.wsi.ServiceSessionNst.cOpenMultipartOutputStream(ServiceSessionNst.java:279)
... 10 more
The relevant error here is java.net.ConnectException: Connection refused. From the given URL, the application is trying to connect to 'IMPERIUM04.ibmsw.ibm.aessatl.arrow.com:9082'.
Verify that the hostname and port name are correct. If the details are correct, ensure that the address is reachable. If you are on an enterprise environment, make sure that the firewall is configured to allow this connection.

VisualVM 1.32 doesn't connect to WAS (Websphere Application Server) 7.0.0.15

I'd be very pleased getting help from yours so many thanks in advance.
Can't manage to connect to a WAS server using VisualVM.
WAS properties setup:
Servers->Server types->WebSphere application servers->server1->Process
definition->Java Virtual Machine -> Properties JVM
-Djavax.management.builder.initial=
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=9999
WAS console output:
INFO [com.sun.tools.visualvm.jmx.impl.JmxModelImpl]:
connect(service:jmx:rmi:///jndi/rmi://:9999/jmxrmi)
java.io.EOFException: SSL peer shut down incorrectly
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:333)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
Caused: javax.net.ssl.SSLHandshakeException: Remote host closed
connection during handshake
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:817)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:632)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at java.io.DataOutputStream.flush(DataOutputStream.java:106)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:211)
Caused: java.rmi.ConnectIOException: error during JRMP connection
establishment; nested exception is:
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:286)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
Caused: javax.naming.CommunicationException [Root exception is
java.rmi.ConnectIOException: error during JRMP connection
establishment; nested exception is:
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
Caused: java.io.IOException: Failed to retrieve RMIServer stub
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$ProxyClient.tryConnect(JmxModelImpl.java:496)
at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$ProxyClient.connect(JmxModelImpl.java:440)
at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.connect(JmxModelImpl.java:220)
at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.(JmxModelImpl.java:209)
at com.sun.tools.visualvm.jmx.impl.JmxModelProvider.createModelFor(JmxModelProvider.java:61)
at com.sun.tools.visualvm.jmx.impl.JmxModelProvider.createModelFor(JmxModelProvider.java:42)
at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:111)
at com.sun.tools.visualvm.tools.jmx.JmxModelFactory.getJmxModelFor(JmxModelFactory.java:69)
at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.addJmxApplication(JmxApplicationProvider.java:267)
at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.createJmxApplication(JmxApplicationProvider.java:185)
at com.sun.tools.visualvm.jmx.JmxApplicationsSupport.createJmxApplicationImpl(JmxApplicationsSupport.java:286)
at com.sun.tools.visualvm.jmx.JmxApplicationsSupport.createJmxApplicationInteractive(JmxApplicationsSupport.java:263)
[catch] at
com.sun.tools.visualvm.jmx.impl.AddJMXConnectionAction$1.run(AddJMXConnectionAction.java:80)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1957)
Thank you a lot again.
Regards.
Good morning.
Well,we've discovered the solution,kinda easy indeed.
The propertie -Djava.rmi.server.hostname=hostname was pointing to localhost instead of ip.
I Hope this info be usefull to someone more.
Thank you very much.
Regards.

Resources