How to change user config in docker tomcat 8? - java

Using docker quick start terminal I have started a tomcat container and it is running and i can able to open the tomcat homepage. But i can't able to open the manager app by using default username:"admin" password:"admin". How can i update the config of tomcat??

from the doc https://hub.docker.com/_/tomcat/:
The configuration files are available in /usr/local/tomcat/conf/. By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user in tomcat-users.xml.
If you want, you can replace this folder from your host with a volume in your run (docker run [...] -v /your/conf/:/usr/local/tomcat/conf/ [...])

In your catalina base directory you need to include something like:
<role rolename="manager"/>
<user username="admin" password="admin" roles="manager"/>
at file
"\CATALINA_BASE\conf\tomcat-users.xml"
For Manager Apps : GUI access
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-gui"/>

Related

Get Tomcat console [duplicate]

using this tutorial http://www.eclipse.org/birt/phoenix/deploy/viewerSetup.php#install_viewer
And it tells me to display the Tomcat manager application through this link http://localhost:8080/manager/html.
However when I click it I get an error from my browser saying it could not connect. Why is this? How exactly does one display the Tomcat Manager Application
If you are launching tomcat from within Eclipse (using the webtools tomcat server adapter) you will have to make sure you have changed the settings to use the installation directory to launch instead of the default which uses a separate location for loading and deploying webapps. So just having the manager in your webapps in the tomcat installation wont be enough to see the manager since by default tomcat launched by Eclipse doesn't look for apps in the webapps folder.
Just make sure that catalina.base and catalina.home point to the tomcat installation directory
I solved that problem by setting up the server management in Eclipse to take control of the Tomcat installation, which has the manager enabled. This thread explains how to do it:
Tomcat started in Eclipse but unable to connect to http://localhost:8085/
Anyway I have the console at the address you mentioned:
localhost:8080/manager/html
in Tomcat 7.
Below things worked for me on fresh installation of apache-tomcat-7.0.63 -
Please make changes to below files and restart the server using %CATALINA_HOME%\bin>catalina.bat start and then try -
http://localhost:8080/manager/html
1) configured variables - CATALINA_HOME and CATALINA_BASE
2) created manager.xml file inside %CATALINA_HOME%\conf\Catalina\localhost
please paste below lines into manager.xml file -
<Context privileged="true" antiResourceLocking="false"
docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.0\.0\.1" />
</Context>
3) modified %CATALINA_HOME%\conf\tomcat-users.xml file
please paste below lines into tomcat-users.xml file
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
4) modified %CATALINA_HOME%\conf\server.xml
Search this line '<Engine name="Catalina" defaultHost="localhost">' and add below line after that -
<Realm className="org.apache.catalina.realm.MemoryRealm" />
Make sure you activated the manager app and created a user that has access to it. For details see the documentation to your Tomcat-Version (e.g. for Tomcat 7: http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html )
Hey this issue just took me a lot of time to fix, so my tips would be (if it's relevant to others that view this page as well):
Use command line commands (set CATALINA_HOME etc..) instead of changing it through control panel enviroment variables.
When people use %.....% it means give the path to the folder of this variable, except the folder which you are at in command promplt. For example if you are in C:\ in command line and someone tells you to do %CATALINA_HOME%\bin, assuming for example the path for CATALINA_HOME is C:\Program Files, it means write in command line: Pragram Files\bin (excluding C:).
Could have saved me a lot of time.
Right Click On Apache Tomcat
Select Open
Go to Server Locations Tab
Select use tomcat installation
Goto the installation directory
Edit apache-tomcat-8.0/conf/tomcat-users.xml
Add the below users in the xml file
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<role rolename="manager"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager-gui,manager"/>
Copy tomcat-user.xml file in eclipse workspace server's tomcat directory
Now open tomcat manager page http://localhost:/manager/html/
Use username and password tomcat and manager page will open on your browser
If you want to keep using the workspace metadata for you Eclipse Tomcat instance, here's how you can get the manager webapp to work.
The base configuration instructions can be found in Apache Tomcat 7 Manager App HOW-TO.
In your Servers IDE project, the <server name>-config\server.xml file should have the following nested entries:
...
<Service name="Catalina">
...
<Engine defaultHost="localhost" name="Catalina">
...
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
...
Open your Eclipse workspace metadata, where the Tomcat instance folders are published, i.e.:
<your-workspace-dir>\.metadata\.plugins\org.eclipse.wst.server.core\tmp<n>
there, inside the conf\ folder create a new folder named Catalina (derived from <Engine ... name="Catalina"> above), inside this folder create another one named localhost (derived from <Host ... name="localhost" ...> above) and in this last one edit a file named manager.xml with the content as per the linked docs:
<Context privileged="true" antiResourceLocking="false"
docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.0\.0\.1" />
</Context>
Now publish and start the server instance, the manager will be deployed along side the other webapps you have added — for me it is the last one being deployed.
Tested with Tomcat 7, but I guess it would work for any Tomcat version that supports that linked configuration.
Side note
Do not create the above mentioned folders and files inside the configuration stored in the Eclipse Servers project, they won't be published in the org.eclipse.wst.server.core\tmp<n>\conf directory.

How to set environment variables in JBoss

We are developing an application that is deployed in a JBoss.
we would like to define a properties files like this:
URL_DEVELOPMENT.properties = ...
URL_TEST.properties = ...
URL_PRODUCTION.properties = ...
and define an environment variable in the JBoss which contains the information about the execution context
for example --> ENVIRONMENT = DEVELOPMENT
Anyone knows:
How to set environment variables in JBoss.
How to get these variables from an applicacion deployed in JBoss in runtime execution?
The easiest and most straight forward way is to log into jboss web admin:
www.yoururl:9990
Then under configuration, look for system property.
At runtime, it is very easy: System.getProperty(yourPropertyKey) and the good thing is that a change in any of these properties is reflected immediately at runtime.
The other scenario is to open up standalone.xml
<server ...>
<system-properties>
<property name="eclipselink.archive.factory" value="org.jipijapa.eclipselink.JBossArchiveFactoryImpl"/>
</system-properties>
</server>
The other option is to read on jboss cli and configure system properties from there. (Only useful if you want to work with remote jboss and you cannot ssh into the server, and you cannot access the web admin)

Tomcat 7 manager /text interface does not work

I've just setup a new Tomcat 7.0.59 installation and added the Tomcat Manager application to web-apps. I'm able to login and use the web interface to manager via http://host:8080/manager/html as I could with Tomcat 6. The Tomcat 7 documentation (http://tomcat.apache.org/migration-7.html#Manager_application) states:
Note that the URL for the text interface has changed from "" to "/text"
The problem that I have is that using the /text URI attribute doesn't work.
http://host:8080/manager/list (works)
http://host:8080/manager/text/list (returns 404)
Is there some configuration setup that I need to do in order to get this to work properly?
Edit your tomcat-users.xml to have a user with the manager-script role. It should look something like this:
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="<username>" password="<password>" roles="manager-gui,manager-script"/>
</tomcat-users>
On my ubuntu system, the file is located in /etc/tomcat7/tomcat-users.xml
Ok, so the recommendations for the manager-script role were important to solving my issue and for that I thank dnault and James for your feedback as I missed that in the documentation.
The biggest issue for the /manager/text not working was a bonehead mistake on my part. We breakout the catalina_home directory from the binary distribution of Tomcat. If I need manager for an installation, I create a symlink from the catalina_home/web-apps directory to the distribution web-apps/manager directory. In doing so, I linked it to the Tomcat 6 distro instead of Tomcat 7.
Changing the symlink and adding the manager-script solved my issue.
I think the root cause is server refuse maven's write action, Here my solution:
<user username="xxx" password="xxx" roles="manager-gui,manager-script,manager-jmx,manager-status"/>

Webstart Security is Impossible. Trying to use with glassfhish 4

The end goal is to provide application client downloads using Java webstart from Glassfish 4.
I've been trying to get this working for 3 days, researching every method I can find and no matter what I try, webstart is blocked.
Exception list. Doesn't work.
Adding the certificate as a trusted certificate. Doesn't work.
Sandbox which doesn't need any permissions. Doesn't work.
Updating Java. Doesn't work.
I can't seem to find the deployment rule sets option but this sounds like something that needs full windows server integration etc.
There is no medium option in the Java console security settings as I am using java 8.0.31.
Simple test app that has nothing but static main void which prints a message to command line. Cannot get it to work...
It is starting to drive me crazy that it is impossible to develop anything using webstart, the only options I can see are purchasing a certificate for local development or totally dropping webstart...
How I added the certifacte to my machine - the certificate is shown in my Java console.
Here is the simple scenario I cannot get working:
package com.cbprogramming;
import javafx.application.Application;
import javafx.stage.Stage;
public class Main extends Application {
#Override
public void start(Stage primaryStage) throws Exception {
System.out.println("Test");
}
public static void main(String[] args) {
launch(args);
}
}
I then used IntelliJ Idea to create a JavaFX application that packages it including the webstart jar file, JNLP file and html web page including custom manifest fields for permissions: sandbox and codebase.
The JNLP file, I also tried with the security and permissions tags, both all-permissions and sandbox.
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="WebstartTest.jnlp">
<information>
<title>Webstart Test</title>
<vendor>Testing</vendor>
<description>A Java Webstart testing app</description>
<offline-allowed/>
</information>
<resources>
<jfx:javafx-runtime version="8.0+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
</resources>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="WebstartTest.jar" size="1190" download="eager" />
</resources>
<security>
<all-permissions/>
</security>
<applet-desc width="600" height="400" main-class="com.javafx.main.NoJavaFXFallback" name="WebstartTest" >
<param name="requiredFXVersion" value="8.0+"/>
</applet-desc>
<jfx:javafx-desc width="600" height="400" main-class="com.test.Main" name="WebstartTest" />
<update check="background"/>
</jnlp>
And the manifest file:
Manifest-Version: 1.0
permissions: sandbox
codebase: file:///d:/test/
JavaFX-Version: 8.0
Class-Path:
Created-By: JavaFX Packager
Main-Class: com.test.Main
Name: com/test/Main.class
SHA-256-Digest: 8BK5m/ojirCK/QEx8Oe+9z/L6P8JXin0CMDK4R2mkAI=
I have added the jnlp, jar and html files to the exceptions list, I've tried both with file:// and file:///, I've also tried adding the glassfhish URL to the exception list, http and https...
I am developing on a Win 8.1 pro machine using Jdk 8.0.31.
Every forum I have read users are saying any one of these options fix their problem. What am I doing so wrong?!? Is 8.0.31 broken? Or is webstart just not worth using?
Here is what I found incase others find it useful.
It looks like Glassfish 4.1 has a webstart bug when using Java 7 update 25 or later (currently 8.0.31). The workaround is to use an older version of Java.
I never could get the java console exceptions list to work.
Adding the certificate as trusted let webstart work from a local file/html file but it still didn't work through glassfish.
The tags needed to be removed from jnlp files now that they are in the jar manifest file or the application was blocked, these tags are added automaticlly by glassfish and intellij JavaFX packager.
Another thought is to setup a local certificate authority and add it as trusted through the java console - this way it isn't a self signed certificate.
Also, to get a glassfish application client debugging in IntelliJ:
Create a batch file: start "name" cmd /c "<installdir>\glassfish\bin\appclient.bat -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -client <dir>\TEMPSClient.jar"
Create a remote debugging configuration and set it to run the created script using the external tool in the before launch section.
This uses the default ports etc. for remote debugging, and will run the application jar in the glassfish client container before attaching the debugger to it. To get console output, redirect stdout and stderr to a log file and attach the log file to your remote debug configuration.
I first tried using the embedded ACC but couldn't get that working (copy/paste from docs has functions that don't even exist...). It would be great if someone knows of a good tutorial for using the embedded ACC.

NetBeans 7.1.2 tomcat /manager access configuration issue

I am trying to access the /manager page of the Tomcat instance installed by NetBeans 7.1.2.
When I right click the corresponding tree node for properties, I get this:
which seems to suggest I could use these credentials, but they don't work.
When I take a look at tomcat-users.xml, this user does not seem to exist:
<tomcat-users>
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary.
-->
<!--
NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove
<!.. ..> that surrounds them.
-->
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
-->
</tomcat-users>
Am I supposed to create it? If yes, I have tried, but could not find the proper roles. What would be the proper line to add? (and yes I have rebooted Tomcat)
In the properties dialog, you can see two variables:
CATALINA_HOME, the directory where you chose to install Tomcat. e. g. c:\Program Files\Apache Software Foundation\Tomcat 6.0. Tomcat uses this variable to find its internal classes and libraries.
CATALINA_BASE the directory of the configuration files and directories, such as the web application directories. If CATALINA_BASE isn't set, it defaults to the value of CATALINA_HOME. e. g. C:\Users\JVerstry\.netBeans\7.1.2\apache-tomcat-7.0.22.0_base
If you want to use the manager, you need deploy (copy) the manager application in the proper folder located in C:\Users\JVerstry\.netBeans\7.1.2\apache-tomcat-7.0.22.0_base if this application don't exists (see the directory conf/Catalina/localhost) and add the role manager-gui to the user

Categories

Resources