Search code examples
javaapachetomcatnetbeanscatalina

Unlock Apache Tomcat user LockOutRealm


I'm facing problem with running simple empty web service through NetBeans, since i downloaded and installed Apache Tomcat. An empty web project cannot be openned - requires authentication. Tomcat runs well (opens web page at localhost:8080), but further actions(ManagerApp link) requires login and password. I have already added necessary fields to tomcat-users.xml.

<role rolename="manager-gui"/>
<user username="medet" password="mira" roles="manager-gui"/>

When i try to enter these login and password, apache log says that they are blocked, even if they enterred for the first time. I tried to create java class that extends LockOutRealm in order to unlock my users (since it has unlock(String user) function).

public class UserUnlocker extends LockOutRealm{

@Override
public void unlock(String username) {
    super.unlock(username); 
}

public static void main(String [] args) {
    UserUnlocker mt = new UserUnlocker();
    try {
        mt.unlock("admin");
    }
    catch(Exception ex) {
        ex.printStackTrace();
    }
}
}

Exception:

java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
at org.apache.catalina.util.LifecycleBase.<clinit>(LifecycleBase.java:37)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Exception in thread "main" C:\Users\mkoilybai\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1

Any idea?


Solution

  • OK, i figured it out. I reinstalled Apache and again added server to NetBeans. Before deploying anything, i added new user into tomcat-users.xml with manager-gui rights. It allows me to enter Manager App link in tomcat welcome page (localhost:8080). But i still can't deploy my test WebService. It requires additional rights for my user (manager-script). I again edited tomcat-users.xml, but it didn't make sense. Seems like i need to do all the stuff again. If you guys have easier solution, please let me know.