I cannot access Tomcat manager via chrome browser, although it works on Edge - tomcat8.5

I edited the tomcat-users.xml file. It works on Microsoft Edge, but not Google chrome.
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<user name="admin" password="admin" roles="admin-gui,admin-script,manager-gui,manager-status,manager-script,manager-jmx"/>

Related

Port forwarding with WCF vb.net TCP chat app

I created a TCP chat app in Visual Basic C# by this tutorial video, and my friend cant connect to the chat server because he is on an other network. How to fix this? I forwarded the ports, but if I enter not local IP address in App.config it crashes. I need help! I trying to fix this sciene 2 days but nothing, I found nothing about this.
The Server's App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<services>
<service name="ProvinciaEZChatBySTEVEN_S.ChattingService">
<endpoint address="net.tcp://localhost:9876/ChattingService"
binding="netTcpBinding" bindingConfiguration="" name="ChattingServiceEndPoint"
contract="ProvinciaEZChatBySTEVEN_Interfaces.IChattingService" />
</service>
</services>
</system.serviceModel>
</configuration>
The Client's App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<client>
<endpoint address="net.tcp://localhost:9876/ChattingService"
binding="netTcpBinding" bindingConfiguration="" contract="ProvinciaEZChatBySTEVEN_Interfaces.IChattingService"
name="ChattingServiceEndPoint" kind="" endpointConfiguration="" />
</client>
</system.serviceModel>
</configuration>

How to set default-encoding in undertow subsystem as utf-8 with a CLI script?

I'm running a WildFly10 Application Server. Now I noticed that as I changed the default encoding in the standalone.xml configuration file to utf-8, the change got erased as the server was rebooted.
Then I read up that I should use a CLI script. Now, how can I do that? What form of CLI script would add the attribute default-encoding="UTF-8" to the undertow subsystem as follows:
Here's the unmodified part of standalone.xml:
<subsystem xmlns="urn:jboss:domain:undertow:3.0">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="http"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
And here it is modified, as I'd like it to be and remain in the standalone.xml:
<subsystem xmlns="urn:jboss:domain:undertow:3.0">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default" default-encoding="UTF-8">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
So the only thing changed here is the added default-encoding="utf-8" attribute in the <servlet-container> tag. How can I add it via a CLI script? Thank you.
run write-attribute operation on servlet-container resource
/subsystem=undertow/servlet-container=default:write-attribute(name="default-encoding", value="utf-8")

Deploy Maven project in Tomcat8 from Eclipse IDE

<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8099/manager/html</url>
<username>tomcat</username>
<password>admin</password>
<path>/example</path>
</configuration>
Cannot invoke Tomcat manager:
Connection refused: connect -> [Help 1]
Why this error? I am using Apache Tomcat 8.
When you want Maven deploy your web application (WAR artifact) to Tomcat 8 server, you still use tomcat7-maven-plugin.
Inside pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>tomcat8_vy</server>
</configuration>
</plugin>
Inside Maven installed directory, looking file settings.xml, path likes this /apache-maven-3.3.9/conf/settings.xml
<servers>
<server>
<id>tomcat8_vy</id>
<username>tomcat_username</username>
<password>tomcat_password</password>
</server>
</servers>
Inside Tomcat installed directory, looking file tomcat-users.xml, path likes this /apache-tomcat-8.0.36/conf/tomcat-users.xml
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<user username="tomcat_username" password="tomcat_password" roles="manger-gui,manager-status,manager-script,manager-jmx"/>
</tomcat-users>
Go to directory of web-app where have pom.xml, type command
mvn tomcat7:deploy
or
mvn tomcat7:redeploy
for second deploy onward (If server no shutdown).
You can run/execute deploy from IDE's Maven plug-in.

Redirect http to https is not working

I want to redirect Http to Https. So for that I created a certificate using 'keytool -genkey -alias mydomain -keyalg RSA -keystore keystore.jks -storepass password' this command.
pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<warSourceDirectory>${webappDirectory}</warSourceDirectory>
<path>bigdata</path>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
<httpsPort>8443</httpsPort>
<keystoreFile>/usr/local/Keystorefiles/keystore.jks</keystoreFile>
<keystorePass>arya123</keystorePass>
<password>arya123</password>
</configuration>
</plugin>
web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>securedapp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
Server.xml
<?xml version="1.0" encoding="UTF-8"?>
<Server address="localhost" port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.JasperListener"/>
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<GlobalNamingResources>
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector address="dt" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<!-- <Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" redirectPort="8443" />-->
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/usr/local/Keystorefiles/keystore.jks"
keystorePass="arya123" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<Engine defaultHost="dt" name="Catalina">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="dt" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>
<Context docBase="HelloWeb" path="/HelloWeb" reloadable="true" source="org.eclipse.jst.jee.server:HelloWeb"/><Context docBase="SpringMVCExample" path="/SpringMVCExample" reloadable="true" source="org.eclipse.jst.jee.server:SpringMVCExample"/><Context docBase="TrialApp" path="/TrialApp" reloadable="true" source="org.eclipse.jst.jee.server:TrialApp"/><Context docBase="ABDFver3" path="/bigdata" reloadable="true" source="org.eclipse.jst.jee.server:ABDFver3"/></Host>
</Engine>
</Service>
</Server>
This much I did. But when I gave URL it doesn't redirect to Https. Could anyone help me?
I assume you don't want to manually do the 'redirect-thing'. Normally this is done by the server for you - and that's the reason why you don't just have to edit settings within your application but also on your server!
One of many tutorials for Tomcat can be found here: https://www.mulesoft.com/tcat/tomcat-ssl

Spring roo Cannot invoke Tomcat manager: Connection refused: connect

I have a problem deploying my Spring Roo application with Maven, using Spring Tools Suite 3.5.1 . I've been reading posts like this tomcat-maven-plugin 403 error but I continue with the following error:
Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:redeploy (default-cli) on project prueba: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1]
I'm running the maven doing this:
Right click over the project => Run as => Run configurations => New Maven Build => Goals: tomcat7:deploy
I've set my config files like this:
pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>tomcat</server>
<path>/prueba</path>
</configuration>
</plugin>
tomcat-users.xml
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="s3cret" roles="manager-script,manager-gui"/>
</tomcat-users>
settings.xml
<settings>
<servers>
<server>
<id>myserver</id>
<username>tomcat</username>
<password>s3cret</password>
</server>
</servers>
</settings>
Some posts are in controversy because of this line
<url>http://127.0.0.1:8080/manager/text</url>
They say I have to put html instead of text but It doesn't works and I can't rid of this error.
Thanks in advance
Finally I was able to solve this error. I followed the last steps from this blog and my working files have the following content:
pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/ssigdl</path>
<update>true</update>
<url>http://localhost:8080/manager/text</url>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
Note the password and username are exposed here so I removed the settings.xml file. When you don't want to expose these data you can create the ${user.home}/.m2/settings.xml,
tomcat-users.xml
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="tomcat"></role>
<role rolename="manager-gui"></role>
<role rolename="manager-script"></role>
<role rolename="admin-gui"></role>
<user password="tomcat" roles="tomcat,manager-gui,admin-gui,manager-script"
username="tomcat"></user>
</tomcat-users>
I just ran the maven command tomcat7:deploy
IMPORTANT: Don't forget to start the VMware vFabric tc Server Developer Edition (Tomcat) before running the maven command. I believed the tomcat7:deploy command started the server and then try to deploy but you have to start manually the server to deploy succesfully.

Resources