Tomcat 8 Manager, HTML and Text running, access from ANT Connection Refused - java

first time poster here. I'm setting up a new Tomcat 8 instance and I'm trying to utilize tomcat 8 manager from my build.xml script (via IntelliJ). I'm using the list command to test the connection, but want I really want is stop/start/redeploy/etc. I've tested both manager/text/ and manager/html succesfully.
[Windows 7 box]
Code snippets incoming
tomcat-users.xml:
<role rolename="admin-gui"/>
<role rolename="manager-script" />
<role rolename="manager-gui" />
<user username="script" password="test" roles="admin-gui,manager-script"/>
<user username="manager" password="test" roles="admin-gui,manager-gui"/>
build.xml:
<target name="list"
description="List installed applications on servlet container">
<echo>List Using:(${manager.url}) [${manager.username}|${manager.password}]</echo>
<list url="${manager.url}"
username="${manager.username}"
password="${manager.password}"/>
</target>
Output from 'list' task from IntelliJ:
List Using:(http://localhost:8080/manager/text) [script|test]
Task: list
C:\apps\myapp\build.xml:478: java.net.ConnectException: Connection refused: connect
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:269)
...etc
Every tutorial I go to talks about setting up Tomcat-Users.xml or opening port 8443 for the manager, but I haven't seen an answer for what to do if you have confirmed manager is running (it is) but build.xml/ANT seem have trouble getting authorized.

Things to check:
Have you actually confirmed that manager app is deployed to the /manager context? It's only deployed by default on the default host. For other virtual hosts, this is something you must do manually. Try visiting http://localhost:8080/manager with your web browser. Try logging in with the manager-gui user.
Does your tomcat instance run more than one virtual host? If so, it's possible that your ant task is hitting a different virtual host than one you want. Check your $CATALINA_HOME/conf/server.xml file's <Engine> and <Host> elements. Does <Engine> contain just one <Host>? If it contains multiple hosts, whate are the name attributes set to? What is the defaultHost attribute of <Engine> set to?

Related

IIS rewrite rule with Tomcat 9.0

I have deployed a Spring Boot application in Tomcat in Windows Server and it's accessible on browser via http://server-name:8080/app. Now, for end users I don't want them to hit the app at port 8080, so I have configured an IIS rewrite rule
<rule name="app" enabled="true" stopProcessing="false">
<match url="^app.*" />
<action type="Rewrite" url="http://server-name:8080/{R:0}" logRewriteUrl="true" />
</rule>
Now, when I hit http://server-name/app, it works, but the subsequent calls are going to http://server-name:8080/app.
I am not sure if there is a problem with the IIS rule since I ran the app.war using same application.properties as
java -jar app.war --server.port=8080 --spring.config.import=application.properties
The only caveat here is I am passing context path in properties as
server.servlet.context-path=/app
and in this scenario all the URL calls go without port 8080. If anyone have any insight or solution, please share.
Please NOTE: I can't host Tomcat on port 80 as there are other apps running on port 80 which uses the API from app deployed in Tomcat.

Eureka+Cloud-Config with Wildfly and deployment order

I need to integrate some SpringBoot services in a Wildfly environment.
There is a Eureka-Server+Cloud Config-Service runing as a WAR in a wildfly. I cannot see the dashboard, but I can see the self-registered service in the XML data in ..eureka/apps
If I start a SpringBoot client for Eureka/Cloud Config in a standalone mode - it connects perfectly to this Wildfly/Eureka/CloudConfig service. The same, when I add this client as a WAR into the already running Wildfly/Eureka/CloudConfig system.
But when I kill the server and restart it, the parallel deployment of the two WARs produce of course a lot of exception during startup. Thats ok, because the Eureka Server isn't up yet. But after it's - the client registeres itself correctly to the Eureka server (I see it in eureka/apps again). But the client sends exceptions all the time.
2018-06-22 12:40:10,345 WARN [org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration] (DiscoveryClient-CacheRefreshExecutor-0) Could not locate configserver via discovery: java.lang.IllegalStateException: No instances found of configserver (EUREKA-DISCOVERY-SERVICE)
at org.springframework.cloud.config.client.ConfigServerInstanceProvider.getConfigServerInstance(ConfigServerInstanceProvider.java:25)
at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration.refresh(DiscoveryClientConfigServiceBootstrapConfiguration.java:80)
at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration.heartbeat(DiscoveryClientConfigServiceBootstrapConfiguration.java:72)
at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:261)
at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:180)
at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:142)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:406)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354)
at org.springframework.cloud.netflix.eureka.CloudEurekaClient.onCacheRefreshed(CloudEurekaClient.java:112)
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:981)
at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1471)
at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1438)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
The exception comes every 30sec (refresh time).
I don't understand, why this happens. The ...eureka/apps result shows the service
<applications>
<versions__delta>1</versions__delta>
<apps__hashcode>UP_2_</apps__hashcode>
<application>
<name>EUREKA-DISCOVERY-SERVICE</name>
<instance>
<instanceId>192.168.207.94:eureka-discovery-service:8443</instanceId>
<hostName>localhost</hostName>
<app>EUREKA-DISCOVERY-SERVICE</app>
<ipAddr>192.168.207.94</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="false">80</port>
<securePort enabled="true">8443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1529662231729</registrationTimestamp>
<lastRenewalTimestamp>1529663993904</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1529662210687</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>8443</management.port>
<configPath>/eureka-ds/config</configPath>
</metadata>
<homePageUrl>http://localhost:80/</homePageUrl>
<statusPageUrl>http://localhost:8443/actuator/info</statusPageUrl>
<healthCheckUrl>http://localhost:8443/actuator/health</healthCheckUrl>
<secureHealthCheckUrl>https://localhost:8443/actuator/health</secureHealthCheckUrl>
<vipAddress>eureka-discovery-service</vipAddress>
<secureVipAddress>eureka-discovery-service</secureVipAddress>
<isCoordinatingDiscoveryServer>true</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1529662231729</lastUpdatedTimestamp>
<lastDirtyTimestamp>1529662193289</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
<application>
<name>MARK2</name>
<instance>
<instanceId>192.168.207.94:mark2:9998</instanceId>
<hostName>192.168.207.94</hostName>
<app>MARK2</app>
<ipAddr>192.168.207.94</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">9998</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1529662210686</registrationTimestamp>
<lastRenewalTimestamp>1529663979339</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1529662210687</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>9998</management.port>
<configPath>/eureka-ds/config</configPath>
<user>user</user>
<password>software1</password>
</metadata>
<homePageUrl>http://192.168.207.94:9998/</homePageUrl>
<statusPageUrl>http://192.168.207.94:9998/actuator/info</statusPageUrl>
<healthCheckUrl>http://192.168.207.94:9998/actuator/health</healthCheckUrl>
<vipAddress>mark2</vipAddress>
<secureVipAddress>mark2</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1529662210687</lastUpdatedTimestamp>
<lastDirtyTimestamp>1529662208806</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
</applications>
This answer may be helpful for the error No instances found of configserver(configserver),
Spring Cloud Config Server has the default name as "configserver" If you override this name using the spring.application.name=my-config-server in application.properties then in the Config Client application's bootstrap.properties you need to use spring.cloud.config.discovery.service-id=my-config-server
Sample Config Server
spring.application.name=my-config-server
eureka.instance.hostname=localhost
server.port=8888
spring.cloud.config.server.git.uri=file:////Users/asadhat/work/lab/spring-cloud
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
Sample Config Client
spring.application.name=my-config-client
server.port=7000
eureka.instance.hostname=localhost
spring.cloud.config.discovery.enabled=true
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
spring.cloud.config.discovery.service-id=my-config-server
I found a way, to get it work.
If I set spring.cloud.config.fail-fast=false (which is the default) then the service makes multiple retries. Then during bootstrap the service sends errors, but after the config server is up, the client service registeres and everything is ok. That takes some seconds...
then - I learned, do not put Eureka server and Cloud config server in one service. Even it is a good idea to reduce the minimize the infrastructure, the cloud config service is a little bit triggy and needs full access to the URL path. Even defining prefixe doesn't really work because of a minor bug (there is a pull request).
third - in a Wildfly environment define the StatusPageURLPath and HealthCheckURLPath correctly (see above, it's wrong)

Tomcat's server status login problems

I use VPS server with Debian8 and installed Tomcat8.0.45, Java8, MySQL. I use command line through PuTTY.
I started tomcat and in web browser I could see "If you're seeing this, you've successfully installed Tomcat. Congratulations!" which means everything is fine. Then I tried to check status of the server or in other words when I tried to access http://ip_adress:8080/manager then popud up prompt window and required login and password.
I already uncommented user-roles in tomcat-users.xml file and added this:
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="password" roles="manager,tomcat,manager-gui,admin-gui,manager-script,manager-jmx,manager-status"/>
Then I restarted tomcat server and typed login and password but still I am asked for login and password. Whatever I type in each time pops up loging window and I cannot access server status site.
Does anyone can help me?
I resolved the problem. Instead of use command: systemctl stop tomcat which seems to not stopping server, I used ./shutdown.sh.

windows single sign on tomcat through IIS Url rewrite

I'm facing a difficult setup where I have to configure single sign on, based on the logged in used on my tomcat application.
I already took some steps which allow me to login via single sign on directly on my tomcat application by using waffle.
I have 1 server where I have a tomcat running and a IIS running (but this IIS will move to another server in the same domain in the future).
I have the Tomcat running on port 8205 and the IIS configure to accept url's from authpoc.company.com. IIS does a redirect to localhost:8025 via URL Rewrite.
My web.xml from IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:8205/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
What works
When opening the application directly on localhost:8205 on the server. I get a nice single sign on based on my domain user.
When opening the application directly on the ip of the server. 192.168.1.1:8205. I can log in but single sign on does not work anymore. This I don't understand. (edit: solved, this is a setting in Internet explorer, see SSO waffle asking username and password for more information)
What doesn't work
When redirecting from IIS, I don't get to login into my tomcat application. I have windows authentication enabled, with Negotiate and NTML enabled (in this sequence).
I read a lot on the internet but I can't find anyone with this particular setup. I don't really have the impression I'm doing something exotic.
One possiblity is that I should connect IIS via AJP instead of a much simpeler URL rewrite.
any help is welcome! Thanks
I got an answer on the google groups saying this is not possible because of the reverse proxy counting as a hop.
https://groups.google.com/forum/#!topic/waffle-users/VCaawJMD0Mw
I'm going to try another approach

Tomcat change password will it affect running application

I have installed tomcat server and I forgot my username/passoword. I have edited my tomcat-user.xml file like this:
<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin,manager"/>
Now my tomcat-manager working fine.
Two questions:
If anybody knew my previous password, will they be able to access my tomcat-manager?
Once I added the tomcat username and password, will it affect immediately or do I have to restart?
Answering to your question below.
1) Well, It depends on the domain you both are and the server where you locate your tomcat. (If you setup your tomcat in a public server and its password is known by many people, you are in trouble).
Better to reset the password to be in a safer side.
2) You must stop the tomcat instance, reset your password and The server must be restarted before changes to configuration settings will take effect.

Categories

Resources