Wednesday, May 22, 2013

Err : Caused by: java.lang.SecurityException: User: weblogic, failed to be authenticated.

Hello Guys,

Sometimes you will have a tough time dealing with simple issues with WebLogic, same goes for this one. Today we will see what are the options of fix we have when we see some simple Authentication Issues, and these issues may eat up a big chunk of your brain figuring out the fix when everyone is watching you waiting for you to show some results, huh.!! that's really a tough time - that goes beyond when you are on call on bridge with customer waiting on his patience.

Lets find out some simple ways to fix this issue.

Normally the issue will look like very frightening one as it just throws out big stack trace resulting into failing the current operation, probably it will be StopServer or StartServer..

[root@localhost bin]# ./stopWebLogic.sh
Stopping Weblogic Server...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Please enter your username :weblogic
Please enter your password :
Connecting to t3://localhost:7001 with userid weblogic ...
This Exception occurred at Tue May 21 18:55:12 PDT 2013.
javax.naming.AuthenticationException [Root exception is java.lang.SecurityException: User: weblogic, failed to be authenticated.]
        at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:42)
        at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:788)
        at weblogic.jndi.WLInitialContextFactoryDelegate.pushSubject(WLInitialContextFactoryDelegate.java:682)
        at weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFactoryDelegate.java:469)
        at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:376)
        at weblogic.jndi.Environment.getContext(Environment.java:315)
        at weblogic.jndi.Environment.getContext(Environment.java:285)
        at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:197)
        at weblogic.management.scripting.WLSTHelper.populateInitialContext(WLSTHelper.java:520)
        at weblogic.management.scripting.WLSTHelper.initDeprecatedConnection(WLSTHelper.java:573)
        at weblogic.management.scripting.WLSTHelper.initConnections(WLSTHelper.java:313)
        at weblogic.management.scripting.WLSTHelper.connect(WLSTHelper.java:203)
        at weblogic.management.scripting.WLScriptContext.connect(WLScriptContext.java:61)
        at weblogic.management.scripting.utils.WLSTUtil.initializeOnlineWLST(WLSTUtil.java:147)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyMethod.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.PyObject.invoke(Unknown Source)
        at org.python.pycode._pyx4.connect$1(<iostream>:16)
        at org.python.pycode._pyx4.call_function(<iostream>)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyFunction.__call__(Unknown Source)
        at org.python.pycode._pyx15.f$0(/cust/weblogic/middleware/domains/xyz_domain/shutdown.py:6)
        at org.python.pycode._pyx15.call_function(/Oracle/weblogic/middleware/domains/xyz_domain/shutdown.py)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.Py.runCode(Unknown Source)
        at org.python.util.PythonInterpreter.execfile(Unknown Source)
        at weblogic.management.scripting.WLST.main(WLST.java:124)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at weblogic.WLST.main(WLST.java:29)
Caused by: java.lang.SecurityException: User: weblogic, failed to be authenticated.
        at weblogic.common.internal.RMIBootServiceImpl.authenticate(RMIBootServiceImpl.java:116)
        at weblogic.common.internal.RMIBootServiceImpl_WLSkel.invoke(Unknown Source)
        at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
        at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
        at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
        at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Problem invoking WLST - Traceback (innermost last):
  File "/Oracle/weblogic/middleware/domains/xyz_domain/shutdown.py", line 6, in ?
  File "<iostream>", line 22, in connect
  File "<iostream>", line 646, in raiseWLSTException
WLSTException: Error occured while performing connect : User: weblogic, failed to be authenticated.
Use dumpStack() to view the full stacktrace

Done
Stopping Derby Server...
[root@localhost bin]#


At this point of time you will get baffled and do not understand what you will be doing as next?

Relax.. There are few instances where you have to look for solution.


  1. Possible corruption of boot.properties
  2. Possible corruption of Embedded LDAP
  3. User Name or Password is Wrong in boot.properties
Instance 1 Possible corruption of boot.properties

Whenever you face the problem like the above you may have to look into the boot.properties files which are present at servers/security folder <domain/servers/servername/security>, if the boot.properties entries are encrypted and are looking fine you can ignore, however you can make sure by creating another one with same values of username and password in the following format and save it under servername/security folder as boot.properties

username=weblogic
password=passwordforweblogic 

And make sure you have boot.properties in required location.

Instance 2 : Possible corruption of Embedded LDAP

Chances of this Instance are more when compared to boot.properties ones, as whenever you shutdown the server improperly or if there are any mis-configuration with authentication data or if there are any changes in the environment where WebLogic Server is present, we have more chances of getting Embedded LDAP Corrupted.

To deal with this issue, we just have few simple steps :
1) Go to <domain>/servers/<serverName>/data/
2) Take Backup or Rename ldap folder
3) Restart Server

Here you will see that a new ldap folder gets created, but you will still have error starting up the server in case if you have changed your username and passwords after your setup.

In case if you see issues still then you have one option to fix it.

  1. Take a backup of ldapfiles Folder from new ldap directory
  2. Copy the ldapfiles from Old backed up ldap folder before you have restarted the server
  3. And Restart the server again.
With this you have more chances of fixing the issue

Instance 3 : User Name or Password is Wrong in boot.properties

This can be considered as Human Error as you need to remember the username and password you have specified, unless you do you will not be able to fix username and password issue.


Alright guys..!!

I believe with this you will be able to see hope of appreciation from your client/ customer.. in case if you think, I am not done.. please request you send me a mail or comment on this post so that I can reply with more options of fixes for similar type weird issues..

If you get any other issues with WebLogic Server / WebSphere Server  and Web Servers.. please drop me a mail here

Regards
Shailesh Dyade

No comments: