I am trying to use a valve from IBM for role based authentication into Tomcat 9 using HTML headers passed from IBM Secure Access Manager (Tivoli Access Manager). I have configured the valve within the Engine Block as shown below:
<Engine name="Catalina" defaultHost="localhost" >
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />
</Realm>
<!-- Here is my valve declaration -->
<Valve className="com.ibm.tivoli.integration.am.catalina.valves.AMTomcatValve"
debugTrace="true" addRoles="myrolename" groupsHeader="iv-groups" />
<Host name="localhost" appBase="/path/to/WARs" unpackWARs="true" autoDeploy="true" >
<Valve classname="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b />
</Host>
</Engine>
However, this causes Tomcat to fail to start. Here is the Stacktrace:
Server start FAILED
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:306)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:491)
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.Authenticator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 35 more
I am not sure what is causing this error as the class org.apache.catalina.Authenticator clearly exists within my catalina.jar located within my $CATALINA_HOME/lib directory. I have placed my AMTomcatValve.jar into $CATALINA_HOME/lib and added it to the classpath that is given to the java command that starts up tomcat.
Also the Tomcat image starts when the valve tag is removed. It also starts when the valve is moved outside of the engine block (this removes it from the context however), but I am met with an "Unexpected Authentication Error" when trying to get into my app using the IBM Security Access Manger WebSeal.
Are there any suggestions on how to get Tomcat to find this class? I'd really like to avoid writing a custom login/authentication valve
Related
i try to set my domain as vhost.
My config looks like this:
<Host name="example.de" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Alias>www.example.de</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="example_access" suffix=".log"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" docBase="/opt/tomcat/webapps/app1" debug="0" reloadable="true" />
</Host>
This config works with every subdir in the webapps-directory, except for the directory I want. If I try to open the Domain, there is an empty browsertab. (Error 404) But if I call it like www.example.de/app1, the app still works and everything ist fine :/
I don't have any idea :/
PS: It's a clean setup of Tomcat, just extracted and edited the server.xml for the vHost-settings
Remember to deploy every application you'd like to appear in a virtual host, including the ROOT application. If you don't have a ROOT application, there is no "default" application that Tomcat can fall-back to, and your clients will get 404 responses when requesting /.
I am using/trying to deploy grails war app to the tomcat7 virtual host configured in server.xml. I have modified etc/hosts to redirect www.mytest.com to localhost (referred from ramkitech). There seems no problem in the code as it works in development(By this, I mean I run my code from grails run-app and access http://localhost:8080/app/). The problem is when I deploy it to independent tomcat7 and put it as ROOT.war in the webapps folder and run the tomcat service, I can access the war based app at http://www.mytest.com:8080/ and when I try to set cookies, they do not seem to be stored and hence, I can't access the cookies set. By the way, the war was generated by the grails dev war. What could be going wrong here?
Server.xml
<Host name="www.mytest.com" appBase="webapps"
unpackWARs="true" autoDeploy="true" >
<Alias>mytest.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
I referred this from http://www.ramkitech.com/2012/02/understanding-virtual-host-concept-in.html and I am using grails cookie plugin 1.4 and basically call savePreference() with ajax providing sample cookie from the the view.
def savePreference(Map cleanParams=[:]) {
cleanParams.each{key,val->
cookieService.setCookie(key, val)
}
return "OK"
}
and here is sample cookie key value pairs I store:
prod_type:A
prod_categoryId:2
prod_id:3
I have been searching for days on how to get this to work but I have had no success.
I have a project which listens on port 6789 and when a connection is made I need to perform some specific actions. To do that I am trying to use a listener so that anytime that my servers Engineis run upon a connection being made.
Basically a mobile application is going to connect to an instance of a server, as soon as the connection is made, the server needs to authenticate the user, then receive data from the phone and place it in the database. If there is another way to do this please let me know. I have looked at filters but those need a url path to activate, and I also do not know how to use a servlet which will fire when a connection is made!
I have this so far in my server.xml:
<Service name="Catalina">
<Connector connectionTimeout="20000" port="6789" protocol="HTTP/1.1"
redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<Engine defaultHost="localhost" name="Catalina">
<Listener className="Listeners.EngineListener" />
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost"
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="PhoneListener" path="/PhoneListener"
reloadable="true" source="org.eclipse.jst.jee.server:PhoneListener">
</Context>
</Host>
</Engine>
</Service>
I have the full path to the file in the <Listener> tag. This is the same way I have executed many filters (authentication and noCache).
The class which implements the LifeCycleListener is here"
package Listeners;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
#ManagedBean
#SessionScoped
public class EngineListener implements LifecycleListener
{
#Override
public void lifecycleEvent(LifecycleEvent event)
{
// TODO Auto-generated method stub
System.out.println("The engine listener is working!");
}
}
The bean declaration is meaningless here, I get the same result with and without the bean declaration.
I have been working at this for a few days now.
I have installed maven and used it to fix dependencies. I have made new projects in new workspaces in an attempt to remedy and class path errors. I have tried to switch from the Majorra JSF library to the MyFaces library, I get the same errors. I am honestly at my wits end with the Listener.
Any ideas?
It turns out that there were no errors in my code, but an error with where files are placed. I have exported the PhoneListenerproject as a .jar and put it into the /lib folder of the server I am awaiting a connection on.
The server could not find my Listeners.PhoneListener as it was not in the start up directory of the server itself.
Somehow I cannot normally map domain to my webapp in tomcat7.
Here is the parts from server.xml:
<Engine name="Catalina" defaultHost="localhost">
<Host name="mydomain.com" appBase="webapps" autoDeploy="true" unpackWARs="true">
<Alias>www.mydomain.com</Alias>
<Context path="" docBase="myapp"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
Does the defaultHost must be localhost or mydomain.com?
I have written a script which deploys myapp in ubuntu:
#!/bin/bash
service tomcat7 stop
rm -rf /usr/share/tomcat/webapps/myapp/
cp myapp.war /usr/share/tomcat/webapps/
service tomcat7 start
After running this script I can access my app only like this: mydomain.com/myapp
If I restart tomcat then it maps to the domain ok, but there is two webapps running.
What am I doing wrong?
To make your web application the default webapp you can simply
rename your myapp.war to ROOT.war,
rm -r /usr/share/tomcat/webappas/ROOT
cp ROOT.war /usr/share/tomcat/webapps
more information available at: http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F
I have a Java based web application which is deployed on Ubuntu machine. I can access the web application at localhost:8080 and it is working as expected.
Now I have domain name for the web application and I want to access web application through the browser using the domain name(http://www.xyz.com).
I want to know the steps which are required to achieve it. Before posting this question, I search over the google.
I have already added the host details in the conf/server.xml.
<Host name="xyz.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Alias>www.xyz.com</Alias>
<Context path="" docBase="" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
Also, I made changes in the /etc/hostname and added following
<IP Address> www.xyz.com xyz
What else do I need to do?