Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Davexception when connection to CRX

Avatar

Level 1

I tried to code a small client for connecting to CRX 2.2

I followed the steps here:

http://helpx.adobe.com/adobe-cq/using/programmatically-accessing-cq-content-using.html

Had problems, found out that I was missing libs and added the jars i found in comment 4 here.

http://forums.adobe.com/message/4734716#4734716

My code is

import java.util.logging.Level; import java.util.logging.Logger; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; import javax.jcr.Workspace; import javax.jcr.nodetype.NodeTypeManager; import org.apache.jackrabbit.commons.JcrUtils; public class CRXConn { public static void main(String[] args) { try { Repository repository = JcrUtils.getRepository("http://MYSERVERNAME/crx/server"); SimpleCredentials creds = new SimpleCredentials("admin", "MYLOGIN".toCharArray()); Session session = null; session = repository.login(creds, "crx.default"); /*KAABOOOOM*/ Workspace ws = session.getWorkspace(); Node rootNode = session.getRootNode(); NodeTypeManager ntMgr = ws.getNodeTypeManager();

 

However, when to code comes to the login row i get an DAVexception "Unauthorized".

 

2013-aug-13 09:03:58 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
2013-aug-13 09:03:58 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: Failure authenticating with BASIC

 

However, thats not true, the account is valid, and I have no problems to login the regular way. What to check next?

Am I still missing some library? Do i need some special setting for weblogic (which it runs on)?

1 Accepted Solution

Avatar

Correct answer by
Level 1

Found the error: It was a weblogic one. I needed to put

the <enforce-valid-basic-auth-credentials> element to config.xml within the <security-configuration> element.

<enforce-valid-basic-auth-credentials>false</enforce-valid-basic-auth-credentials>

</security-configuration>

 

Anyway, thanks for suggestions!

View solution in original post

5 Replies

Avatar

Level 6

You should omit "crx.default" from the repository login. I get the same effect when I add the "crx.default" in our unit test cases but when I use

session = repository.login( new SimpleCredentials(USERNAME,PASSWORD.toCharArray()) );

it works.

Avatar

Level 2

SimpleCredentials creds = new SimpleCredentials("admin", "MYLOGIN".toCharArray());
session = repository.login(creds);

should work.

Avatar

Level 1

Tried removing that as suggested, but get the same exception.

Avatar

Correct answer by
Level 1

Found the error: It was a weblogic one. I needed to put

the <enforce-valid-basic-auth-credentials> element to config.xml within the <security-configuration> element.

<enforce-valid-basic-auth-credentials>false</enforce-valid-basic-auth-credentials>

</security-configuration>

 

Anyway, thanks for suggestions!

Avatar

Level 1

Hi , I am getting the same exception....Where can I apply the fix as I am connecting to CRX with default Felix server. Please help.