java.lang.NullPointerException

Spring JIRA | Maximilian Störzer | 9 years ago
  1. 0

    Hello everybody, we want to use Spring LDAP in a project and encountered the following problem: We manually create the LDAP Template as follows: private LdapTemplate crateLdapTemplate(final String userName, final String password) { LdapContextSource source = new LdapContextSource(); source.setUrl(url); source.setBase(base); // TODO crash(NPE) if 'false' -> Bug? source.setAnonymousReadOnly(true); // Credentials source.setUserName("uid=" + userName + ",ou=people"); source.setPassword(password); // TODO crash(NPE) if 'true' -> Bug? source.setCacheEnvironmentProperties(false); LdapTemplate ldapTemplate = new LdapTemplate(source); return ldapTemplate; } When setting either setCacheEnvironmentProperties to true or setAnonymousReadOnly to false, accessing LDAP fails with a NullPointerException. Access is as follows: List < NjSecurityUser > users = ldapTemplate.search("", filter.encode(), userMapper); Exception is as follows: java.lang.NullPointerException at org.springframework.ldap.support.AbstractContextSource.setupAuthenticatedEnvironment(AbstractContextSource.java:123) at org.springframework.ldap.support.AbstractContextSource.getAuthenticatedEnv(AbstractContextSource.java:373) at org.springframework.ldap.support.AbstractContextSource.getReadOnlyContext(AbstractContextSource.java:104) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:263) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:231) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:526) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:510) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:359) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:380) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:400) at security.Authentification2SpringLdap.getUser(Authentification2SpringLdap.java:252) at security.Authentication2SpringLDAPTest.testFindAllUsers(Authentication2SpringLDAPTest.java:45) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) It seems that setting up an authentification source fails (it is not set explicitly but accessed and dereferenced although null). We do not want to use acgi, though - just plain user/password authentication. Is there a misconception how we use / set up the ldap template or is this a bug in Spring LDAP? Borwsing the documentation and the issue database could not resolve the issue. Thanks for any hints! Best regards, Max

    Spring JIRA | 9 years ago | Maximilian Störzer
    java.lang.NullPointerException
  2. 0

    Hello everybody, we want to use Spring LDAP in a project and encountered the following problem: We manually create the LDAP Template as follows: private LdapTemplate crateLdapTemplate(final String userName, final String password) { LdapContextSource source = new LdapContextSource(); source.setUrl(url); source.setBase(base); // TODO crash(NPE) if 'false' -> Bug? source.setAnonymousReadOnly(true); // Credentials source.setUserName("uid=" + userName + ",ou=people"); source.setPassword(password); // TODO crash(NPE) if 'true' -> Bug? source.setCacheEnvironmentProperties(false); LdapTemplate ldapTemplate = new LdapTemplate(source); return ldapTemplate; } When setting either setCacheEnvironmentProperties to true or setAnonymousReadOnly to false, accessing LDAP fails with a NullPointerException. Access is as follows: List < NjSecurityUser > users = ldapTemplate.search("", filter.encode(), userMapper); Exception is as follows: java.lang.NullPointerException at org.springframework.ldap.support.AbstractContextSource.setupAuthenticatedEnvironment(AbstractContextSource.java:123) at org.springframework.ldap.support.AbstractContextSource.getAuthenticatedEnv(AbstractContextSource.java:373) at org.springframework.ldap.support.AbstractContextSource.getReadOnlyContext(AbstractContextSource.java:104) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:263) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:231) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:526) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:510) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:359) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:380) at org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:400) at security.Authentification2SpringLdap.getUser(Authentification2SpringLdap.java:252) at security.Authentication2SpringLDAPTest.testFindAllUsers(Authentication2SpringLDAPTest.java:45) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) It seems that setting up an authentification source fails (it is not set explicitly but accessed and dereferenced although null). We do not want to use acgi, though - just plain user/password authentication. Is there a misconception how we use / set up the ldap template or is this a bug in Spring LDAP? Borwsing the documentation and the issue database could not resolve the issue. Thanks for any hints! Best regards, Max

    Spring JIRA | 9 years ago | Maximilian Störzer
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.ldap.support.AbstractContextSource.setupAuthenticatedEnvironment()
    2. spring-ldap-core
      LdapTemplate.search
      1. org.springframework.ldap.support.AbstractContextSource.setupAuthenticatedEnvironment(AbstractContextSource.java:123)
      2. org.springframework.ldap.support.AbstractContextSource.getAuthenticatedEnv(AbstractContextSource.java:373)
      3. org.springframework.ldap.support.AbstractContextSource.getReadOnlyContext(AbstractContextSource.java:104)
      4. org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:263)
      5. org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:231)
      6. org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:526)
      7. org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:510)
      8. org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:359)
      9. org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:380)
      10. org.springframework.ldap.LdapTemplate.search(LdapTemplate.java:400)
      10 frames
    3. security
      Authentication2SpringLDAPTest.testFindAllUsers
      1. security.Authentification2SpringLdap.getUser(Authentification2SpringLdap.java:252)
      2. security.Authentication2SpringLDAPTest.testFindAllUsers(Authentication2SpringLDAPTest.java:45)
      2 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:585)
      4 frames
    5. JUnit
      TestSuite.run
      1. junit.framework.TestCase.runTest(TestCase.java:154)
      2. junit.framework.TestCase.runBare(TestCase.java:127)
      3. junit.framework.TestResult$1.protect(TestResult.java:106)
      4. junit.framework.TestResult.runProtected(TestResult.java:124)
      5. junit.framework.TestResult.run(TestResult.java:109)
      6. junit.framework.TestCase.run(TestCase.java:118)
      7. junit.framework.TestSuite.runTest(TestSuite.java:208)
      8. junit.framework.TestSuite.run(TestSuite.java:203)
      8 frames
    6. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
      2. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      6. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      6 frames