Build application on docker - java

I build web application and service to docker from tomcat directory, in web application application.properties file I specify service url with port 8886 but when i use web call to api the application is calling on port 886. Please help me!!
I tried changing other ports, changing environment variable name but same result

Related

Two war files deployed in same docker container is not accessible

I have deployed two war file in docker container, say app1.war and app2.war. app1.war is calling internally app2.war to access few services. I am able to access service in app1.war from browser and internally when app1.war tries to call service in app2.war I am getting following error
I am using Apache server and each request will be first hit to apache server and then directed to the services running in container. Apache server is running in my host as a service.
I have created Dockerfile by taking tomcat as base and copied app1.war and app2.war in webapps folder and expose port is 8080
and build image as
docker build -t myapp .
execute it as
docker run -it -p 9999:8080 myapp
http://localhost:9999/app1/service1 ----- this is accessible and this URL is internally calling a service which is deployed in app2 http://localhost:9999/app2/calculation
on hitting http://localhost:9999/app2/calculation URL I am getting below error
Connection error for URL[http://localhost/app2/calculation/]. Exception: [I/O error on POST request for "http://localhost/app2/calculation/": Connect to localhost:80 [localhost/127.0.0.1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:80 [localhost/127.0.0.1] failed: Connection refused (Connection refused)].
I am looking for a solution for this issues and want to know where exactly the issue is. Any response is highly appreciated.
Your app2 deployed on Tomcat is exposed on port 8080 within the container, not 9999. Therefore, you're getting error when trying to access it on port 9999 from within the container. If you change internal endpoint to 8080 for app2, it should work.
Now, deploying 2 war files on the same Tomcat like this is actually an anti-pattern in containerized world. The usual architecture would be to have 2 separate images/containers, each having its own war file.

Running multiple Spring boot executable jars on self contained server as Linux services

I have deployed my first spring boot web application executable jar in self contained tomcat server successfully and accessing it on port 8080 but when I deployed my second app on different port using init.d on port 42000 I am unable to access it. I have looked the log in /var/log the application starts successfully without any errors. What would be the causes for my problem?

spring boot fat jar register to eureka with a weird port

I encountered a weird problem with spring cloud. I run a spring cloud project defined server port as 8888 in eclipse as run as java application, and register this project to the remote eureka server, it's working fine. but when I package the project and run as java -jar, will register to eureka server with 8080 port, so other service access this service will get a connection refused error.

Trying to run Glassfish server on OpenShift in a DIY cartridge

I'm trying to run Glassfish on OpenShift in a DIY cartridge and I have a problem because I'm receiving an error saying that I can't bind the port 8080.
I have been talking with Openshift support and they have told me that I must remove a ruby file that is binding the 8080 port.
Error:
[#|2015-04-21T17:58:27.887-0400|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=1;_ThreadName=main;|Shutting down v3 due to startup exception : Permission denied: 8080=com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectorHandler#15ac5d5|#]
I think that I have done this, because I have removed a .rb file in the git directory but the problem persists.
Does anyone have any suggestions?
You need to make sure that your glassfish server is binding to port 8080 on your gear's ip address, which is your OPENSHIFT_DIY_IP environment variable.

Moskito inspect monitoring tool integration with Java web application issue

I have an issue setting up an rmi port on Apache Tomcat server
(set JAVA_OPTS=%JAVA_OPTS% -DlocalRmiRegistryPort=9401)
Here are the steps i have done and getting the error respectively.
Issue with MoSKito tool while configuring RMI port on Tomcat
I am also tried to configure MoSkito inspect on my java web application. as part of it, i have been trying to make RMI port using "set JAVA_OPTS=%JAVA_OPTS% -DlocalRmiRegistryPort=9401" on catalina.bat. there is no error as such but 9401 is not getting connected.
Steps followed:
1) My OS is Windows 7
2) I have installed Apache Tomcat v7
3) I have downloaded Moskito inspect .war file from http://www.moskito.org/download.html and
4) Installed Moskito inspect on my tomcat server, the MoSKito inspect web UI is loading good.
5) I have created a sample java web application and deployed on same tomcat server. and web application also working good.
6) Now i have taken step to configure RMI port 9041 using below command on \bin\catalina.bat file(since i am on Windows OS).
I have put the below command on top of the file in \bin\catalina.bat
set JAVA_OPTS=%JAVA_OPTS% -DlocalRmiRegistryPort=9401
7) and started tomcat server, and then opened Moskito application on browser and gone to Quick Connect option on and given localhost and rmi port 9401 to call remote invocation.
Its failed.... its always giving error as MoSKito encountered an error:
Cannot connect to localhost#localhost:9401, due: Can not resolve manually set reference. Server at localhost, port: 9401 is down or not properly configured
[net.anotheria.moskito.webui.util.APILookupUtility.findRemote(APILookupUtility.java:168), net.anotheria.moskito.webui.util.APILookupUtility.findRemote(APILookupUtility.java:142), net.anotheria.moskito.webui.util.APILookupUtility.getAdditionalFunctionalityAPI(APILookupUtility.java:113),
Q1: How to set -DlocalRmiRegistryPort=9401 on tomcat on Windows OS.
Q2: Once we set port, how to ensure port is set properly and its up and ready state for connection.
Q3: Once port is set properly, then how to set / configure specified java web application needs to be configured for MoSKito, since we could have more than one java web application on same tomcat server.
Please guide me, thank you :)
in order to be able to connect to a MoSKito monitored application you have to enable an agent that binds itself to port 9401 and answers your replies. To do so, you have to add a dependency to your pom (if you are using maven):
<!-- Enabling MoSKito Inspect Embedded -->
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-inspect-remote</artifactId>
<version>${moskito.version}</version>
</dependency>
Please keep in mind that the current MoSKito version is 2.5.4
If you are using a servlet 3.0 compatible container (tomcat 7, jboss wildfly) you are done. If you are using an older container you may need to add following to your web.xml:
<listener>
<listener-class>net.anotheria.moskito.webui.embedded.StartMoSKitoInspectBackendForRemoteListener</listener-class>
</listener>
If you are using no container at all, you can start it manually:
net.anotheria.moskito.webui.embedded.StartMoSKitoInspectBackendForRemote.startMoSKitoInspectBackend()
Now for you questions:
Q1: via catalina.bat. You were doing it correctly.
Q2: if the agent is configured everything will work correctly.
Q3: You may want to check out step by step guide here:
http://blog.anotheria.net/msk/the-complete-moskito-integration-guide-step-1/
Regards
Leon

Categories