User failed to be authenticated in WebLogic

DreamBigAlvin picture DreamBigAlvin · Nov 19, 2013 · Viewed 30.6k times · Source

I'm having problem with authenticating my weblogic server, i assigned correct username and password, what went wrong with my project? Is there any configuration that i need to be configure with my web logic server that causes this error authentication and what it would be? I already added wlfullclient.jar file.

Exception in thread "main" javax.naming.AuthenticationException [Root exception is java.lang.SecurityException: User: webogic, failed to be authenticated.]
    at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:42)
    at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:808)
    at weblogic.jndi.WLInitialContextFactoryDelegate.pushSubject(WLInitialContextFactoryDelegate.java:697)
    at weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFactoryDelegate.java:485)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:373)
    at weblogic.jndi.Environment.getContext(Environment.java:319)
    at weblogic.jndi.Environment.getContext(Environment.java:288)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at com.rest.client.Type4Conn.main(Type4Conn.java:23)
Caused by: java.lang.SecurityException: User: webogic, 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:693)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:519)
    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:515)
    at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

Here is my code:

 public static void main(String ar[])throws Exception{
        String username="weblogic";
        String password="weblogic";

        Properties p=new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
        p.put(Context.PROVIDER_URL,"t3://192.168.1.188:7001");        
        p.put(Context.SECURITY_PRINCIPAL, username);        
        p.put(Context.SECURITY_CREDENTIALS, password);        
        InitialContext ctx=new InitialContext(p);
        DataSource ds=(DataSource)ctx.lookup("ds_orclmrcos");    
        System.out.println(ds);
        Connection con=ds.getConnection();
        Statement st=con.createStatement();

        st.executeUpdate("insert into TBL_CUSTOMER(CUST_ID, CUST_FNAME, CUST_MNAME, CUST_LNAME,CUST_ADDRESS,CUST_STATUS)"+
        "VALUES('C-002', 'ALVIN', 'C.','TEST','MANILA', 'PERMANENT')");

        System.out.println(" records inserted");


    }

Answer

Alfred Xiao picture Alfred Xiao · Nov 19, 2013

WebLogic11g and 12c require passwords to include number or symbols - "[Security:099116]The number of numeric or special characters in a password can not be less than 1." - so I think your password 'weblogic' is not going to work.

You can goto WebLogic Admin Console to reset the password: Admin Console >> Security Realms >> myrealm >> Users and Groups >> weblogic >> Passwords.

EDIT: It works on my machine! And I hit below similar exception stack if I provide a wrong password:

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)

I used the same code as yours, and wlfullclient.jar (interesting though, it is from my DB installation folder: 11.2.0.3/dbhome_1/owb/lib/int/wlfullclient.jar).