Search code examples
antwso2wso2-esbwso2-enterprise-integrator

WSO2 EI 6.5.0 - admin password reset using chpasswd.bat due to a UserStoreException


I am trying to reset admin user password by using chpasswd.bat as forgot my old password in WSO2 EI 6.5.0 by follows this link

OS: windows 10

prerequisite:

  • Apache Ant 1.10.7 has been installed in my machine.

apache ant

  • environment variable set done.

env variable

path for ant home

  • Since i am using default H2 Database, Copied related H2 JDBC driver into <PRODUCT_HOME>/lib/

h2 jar

  • goto product path <PRODUCT_HOME>/bin/ and execute below command

chpasswd.bat --db-driver "org.h2.Driver" --db-url "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000" --db-username "wso2carbon" --db-password "wso2carbon" --username "admin" --new-password "newadmin"

after executing above command getting below log

C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\bin>chpasswd.bat --db-url "jdbc:h2:$CARBON_HOME\repsitory\database\WSO2CARBON_DB"
Buildfile: C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\bin\build.xml

setup:
     [copy] Copying 40 files to C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\lib
    [mkdir] Created dir: C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\tmp\setup
    [unzip] Expanding: C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\components\plugins\org.wso2.carbon.security.mgt.stub_5.12.387.jar into C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\tmp\setup
    [unzip] Expanding: C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\components\plugins\org.wso2.carbon.security.mgt.ui_5.12.387.jar into C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\tmp\setup
    [unzip] Expanding: C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\components\plugins\org.wso2.carbon.security.mgt_5.12.387.jar into C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\tmp\setup
   [delete] Deleting directory C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\tmp\setup
    [unzip] Expanding: C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\components\plugins\h2_1.3.175.wso2v1.jar into C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\lib
    [unzip] Expanding: C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\components\plugins\org.wso2.carbon.utils_4.4.40.jar into C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\lib
     [move] Moving 91 files to C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\lib
   [delete] Deleting directory C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\lib\META-INF
   [delete] Deleting directory C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\wso2\lib\org

BUILD SUCCESSFUL
Total time: 15 seconds
Username: admin
New password:           in

Re-enter new password:           in

log4j:WARN Error during default initialization
java.lang.NoClassDefFoundError: org/wso2/carbon/bootstrap/logging/LoggingBridge
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
        at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:327)
        at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:124)
        at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:785)
        at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
        at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
        at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
        at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
        at org.apache.log4j.Logger.getLogger(Logger.java:104)
        at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262)
        at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:108)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025)
        at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:844)
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:269)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
        at org.wso2.carbon.user.core.config.RealmConfigXMLProcessor.<clinit>(RealmConfigXMLProcessor.java:56)
        at org.wso2.carbon.core.util.PasswordUpdater.run(PasswordUpdater.java:158)
        at org.wso2.carbon.core.util.PasswordUpdater.main(PasswordUpdater.java:48)
Caused by: java.lang.ClassNotFoundException: org.wso2.carbon.bootstrap.logging.LoggingBridge
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 40 more
Error updating credentials for user wso2admin : org.wso2.carbon.user.core.UserStoreException: Error while reading realm configuration from file
C:\Development_Avecto\WSo2EIServers\wso2ei-6.5.0\wso2ei-6.5.0\bin>
  • some Jar called ant-contrib-1.0b3 placed after getting above error inside apache-ant-1.10.7\lib path

ant lib path

Is there any config i missed? or how to run that chpasswd command in windows 10 to reset password ?


Solution

  • I was able to fix this issue for EI 6.5.0. If you have WSO2 subscription try updating the product. If not follow the instructions below.

    Note: I did not have a Windows environment to test hence I fixed this for a Linux environment. You can do a diff between the following file and include the required fixed in the bat file.

    Copy the org.wso2.carbon.bootstrap-4.5.3.jar to the ${EI_HOME}/wso2/lib directory. This will get rid of the NoClassDefFoundError issue.

    Then update the chpasswd.sh with the following content.

    #!/bin/sh
    # ----------------------------------------------------------------------------
    #  Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
    #
    #  Licensed under the Apache License, Version 2.0 (the "License");
    #  you may not use this file except in compliance with the License.
    #  You may obtain a copy of the License at
    #
    #      http://www.apache.org/licenses/LICENSE-2.0
    #
    #  Unless required by applicable law or agreed to in writing, software
    #  distributed under the License is distributed on an "AS IS" BASIS,
    #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    #  See the License for the specific language governing permissions and
    #  limitations under the License.
    
    # -----------------------------------------------------------------------------
    #
    # Environment Variable Prequisites
    #
    #   CARBON_HOME   Home of CARBON installation. If not set I will  try
    #                   to figure it out.
    #
    #   JAVA_HOME       Must point at your Java Development Kit installation.
    #
    # NOTE: Borrowed generously from Apache Tomcat startup scripts.
    
    # if JAVA_HOME is not set we're not happy
    if [ -z "$JAVA_HOME" ]; then
      echo "You must set the JAVA_HOME variable before running chpasswd."
      exit 1
    fi
    
    # OS specific support.  $var _must_ be set to either true or false.
    cygwin=false
    os400=false
    case "`uname`" in
    CYGWIN*) cygwin=true;;
    OS400*) os400=true;;
    esac
    
    # resolve links - $0 may be a softlink
    PRG="$0"
    
    while [ -h "$PRG" ]; do
      ls=`ls -ld "$PRG"`
      link=`expr "$ls" : '.*-> \(.*\)$'`
      if expr "$link" : '.*/.*' > /dev/null; then
        PRG="$link"
      else
        PRG=`dirname "$PRG"`/"$link"
      fi
    done
    
    # Get standard environment variables
    PRGDIR=`dirname "$PRG"`
    
    # Only set CARBON_HOME if not already set
    [ -z "$CARBON_HOME" ] && CARBON_HOME=`cd "$PRGDIR/.." ; pwd`
    
    # For Cygwin, ensure paths are in UNIX format before anything is touched
    if $cygwin; then
      [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
      [ -n "$CARBON_HOME" ] && CARBON_HOME=`cygpath --unix "$CARBON_HOME"`
      [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
    fi
    
    # For OS400
    if $os400; then
      # Set job priority to standard for interactive (interactive - 6) by using
      # the interactive priority - 6, the helper threads that respond to requests
      # will be running at the same priority as interactive jobs.
      COMMAND='chgjob job('$JOBNAME') runpty(6)'
      system $COMMAND
    
      # Enable multi threading
      QIBM_MULTI_THREADED=Y
      export QIBM_MULTI_THREADED
    fi
    
    ant -buildfile "$CARBON_HOME"/bin/build.xml
    
    # update classpath
    CARBON_CLASSPATH=""
    for f in "$CARBON_HOME"/wso2/lib/*.jar
    do
      CARBON_CLASSPATH=$CARBON_CLASSPATH:$f
    done
    
    for g in "$CARBON_HOME"/repository/lib/*.jar
    do
      CARBON_CLASSPATH=$CARBON_CLASSPATH:$g
    done
    
    for h in "$CARBON_HOME"/wso2/lib/api/*.jar
    do
      CARBON_CLASSPATH=$CARBON_CLASSPATH:$h
    done
    
    for i in "$CARBON_HOME"/bin/*.jar
    do
      CARBON_CLASSPATH=$CARBON_CLASSPATH:$i
    done
    
    CARBON_CLASSPATH=$CARBON_CLASSPATH:$CLASSPATH
    
    # For Cygwin, switch paths to Windows format before running java
    if $cygwin; then
      JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
      CARBON_HOME=`cygpath --absolute --windows "$CARBON_HOME"`
      CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
      JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
    fi
    
    # ----- Execute The Requested Command -----------------------------------------
    cd "$CARBON_HOME"
    
    CARBON_CLASSPATH="$CARBON_HOME/lib/patches":"$CARBON_HOME/conf":$CARBON_CLASSPATH
    
    $JAVA_HOME/bin/java -Dcarbon.config.dir.path="$CARBON_HOME/conf" -cp "$CARBON_CLASSPATH" org.wso2.carbon.core.util.PasswordUpdater $*
    

    Also note that you do not have to copy any additional drivers for H2 DB access as the product already have the driver installed. Also I observed a issue with your database URL. Refer the following command and fix your command accordingly.

    sh chpasswd.sh --db-driver "org.h2.Driver" --db-url "jdbc:h2:../repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000" --db-username "wso2carbon" --db-password "wso2carbon" --username "admin" --new-password "newadmin"
    

    References: https://github.com/wso2/micro-integrator/commit/0754a7130eacf88dccc960e92227f2c5635a63de