Receiving NullPointerException while using Jasypt and Spring Security 3.1 -
i trying configure jasypt spring security. configuration file looks this:
jdbc.driver=com.mysql.jdbc.driver jdbc.url=jdbc:mysql://localhost:8090/sample jdbc.username=enc(*****) *****=the salted username jdbc.password=enc(*****) *****=the salted password
my servlet xml contains proper bean setup in format:
<bean id="propertyplaceholderconfigurer" class="org.jasypt.spring31.properties.encryptablepropertyplaceholderconfigurer"> <constructor-arg ref="configurationencryptor" /> <property name="location" value="/web-inf/jdbc.properties" /> </bean> <bean id="configurationencryptor" class="org.jasypt.encryption.pbe.standardpbestringencryptor"> <property name="config" ref="environmentvariablesconfiguration" /> </bean> <bean id="environmentvariablesconfiguration" class="org.jasypt.encryption.pbe.config.environmentstringpbeconfig"> <property name="algorithm" value="pbewithmd5anddes" /> <property name="passwordenvname" value="app_encryption_password" /> <!--<property name="password" value="**********" />--> </bean> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <property name="driverclassname" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean>
my environment variable set in windows app_encryption_password. visible when echo command line. when use setup, null pointer stack trace below. when use hard coded salt password "-->", application runs smoothly. can show me why jasypt or spring might not picking on environment variable properly? information welcomed. thanks.
org.springframework.web.context.contextloader initwebapplicationcontext severe: context initialization failed java.lang.nullpointerexception @ org.jasypt.encryption.pbe.config.simplepbeconfig.getpasswordchararray(simplepbeconfig.java:434) @ org.jasypt.encryption.pbe.standardpbebyteencryptor.resolveconfigurationpassword(standardpbebyteencryptor.java:740) @ org.jasypt.encryption.pbe.standardpbebyteencryptor.initialize(standardpbebyteencryptor.java:590) @ org.jasypt.encryption.pbe.standardpbestringencryptor.initialize(standardpbestringencryptor.java:553) @ org.jasypt.encryption.pbe.standardpbestringencryptor.decrypt(standardpbestringencryptor.java:705) @ org.jasypt.properties.propertyvalueencryptionutils.decrypt(propertyvalueencryptionutils.java:72) @ org.jasypt.spring31.properties.encryptablepropertyplaceholderconfigurer.convertpropertyvalue(encryptablepropertyplaceholderconfigurer.java:109) @ org.springframework.beans.factory.config.propertyresourceconfigurer.convertproperty(propertyresourceconfigurer.java:121) @ org.springframework.beans.factory.config.propertyresourceconfigurer.convertproperties(propertyresourceconfigurer.java:104) @ org.springframework.beans.factory.config.propertyresourceconfigurer.postprocessbeanfactory(propertyresourceconfigurer.java:81) @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:687) @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:662) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:454) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:388) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:293) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:111) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4701) @ org.apache.catalina.core.standardcontext$1.call(standardcontext.java:5204) @ org.apache.catalina.core.standardcontext$1.call(standardcontext.java:5199) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:303) @ java.util.concurrent.futuretask.run(futuretask.java:138) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) @ java.lang.thread.run(thread.java:662) aug 7, 2013 8:46:15 org.apache.catalina.core.standardcontext listenerstart severe: exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener java.lang.nullpointerexception @ org.jasypt.encryption.pbe.config.simplepbeconfig.getpasswordchararray(simplepbeconfig.java:434) @ org.jasypt.encryption.pbe.standardpbebyteencryptor.resolveconfigurationpassword(standardpbebyteencryptor.java:740) @ org.jasypt.encryption.pbe.standardpbebyteencryptor.initialize(standardpbebyteencryptor.java:590) @ org.jasypt.encryption.pbe.standardpbestringencryptor.initialize(standardpbestringencryptor.java:553) @ org.jasypt.encryption.pbe.standardpbestringencryptor.decrypt(standardpbestringencryptor.java:705) @ org.jasypt.properties.propertyvalueencryptionutils.decrypt(propertyvalueencryptionutils.java:72) @ org.jasypt.spring31.properties.encryptablepropertyplaceholderconfigurer.convertpropertyvalue(encryptablepropertyplaceholderconfigurer.java:109) @ org.springframework.beans.factory.config.propertyresourceconfigurer.convertproperty(propertyresourceconfigurer.java:121) @ org.springframework.beans.factory.config.propertyresourceconfigurer.convertproperties(propertyresourceconfigurer.java:104) @ org.springframework.beans.factory.config.propertyresourceconfigurer.postprocessbeanfactory(propertyresourceconfigurer.java:81) @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:687) @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:662) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:454) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:388) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:293) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:111) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4701) @ org.apache.catalina.core.standardcontext$1.call(standardcontext.java:5204) @ org.apache.catalina.core.standardcontext$1.call(standardcontext.java:5199) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:303) @ java.util.concurrent.futuretask.run(futuretask.java:138) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) @ java.lang.thread.run(thread.java:662)
for else facing issue , stumbling upon question, restarting eclipse fixed issue.
note: must close eclipse re-open. clicking "restart" won't work doesn't kill java process completely.
Comments
Post a Comment