java.util.Properties$LineReader.readLine(Unknown Source) on opensaml1.1

I am getting following error while running the code below. Any help would be appreciated.

java.lang.NullPointerException
      at java.util.Properties$LineReader.readLine(Unknown Source)
      at java.util.Properties.load(Unknown Source)
      at org.opensaml.SAMLConfig.loadProperties(SAMLConfig.java:191)
      at org.opensaml.SAMLConfig.<init>(SAMLConfig.java:83)
      at org.opensaml.SAMLConfig.instance(SAMLConfig.java:152)
      at org.opensaml.SAMLBrowserProfileFactory.getInstance(SAMLBrowserProfileFactory.java:72)
      at com.SSOTest.SAMLAssertionCreator.createSAML(SAMLAssertionCreator.java:46)
      at org.apache.jsp.NCRSalesCentral_jsp._jspService(NCRSalesCentral_jsp.java:67)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Unknown Source)

import org.opensaml.ReplayCacheFactory;
import org.opensaml.SAMLAssertion;
import org.opensaml.SAMLAuthenticationStatement;
import org.opensaml.SAMLBrowserProfile;
import org.opensaml.SAMLBrowserProfileFactory;
import org.opensaml.SAMLIdentifier;
import org.opensaml.SAMLIdentifierFactory;
import org.opensaml.SAMLNameIdentifier;
import org.opensaml.SAMLResponse;
import org.opensaml.SAMLSubject;
import org.opensaml.SAMLBrowserProfile.BrowserProfileResponse;
 
public class SAMLAssertionCreator {
	
public BrowserProfileResponse createSAML() throws IOException
//	public void createSAML() throws IOException
	{
	 try
	 {
		System.out.println("1");
	SAMLBrowserProfile profile = SAMLBrowserProfileFactory.getInstance();

Open in new window

vijaymittalAsked:
Who is Participating?
 
rrzConnect With a Mentor Commented:
Is there a key in the properties file with the name that is being searched for ?
Show us the line that has it.
0
 
avdejConnect With a Mentor Commented:
The very cause of the Exception IS the java.io.InputStream object (which IS null) passed
FROM: org.opensaml.SAMLConfig.loadProperties (...)
TO: java.util.Properties.load( java.io.InputStream is)

Since this InputStream-object represents the content of your properties file -- the properties file: was not fount / could not be read / etc.

1. Make sure you have got the required properties file
2. Place it to the proper location
3. Check configuration settings to make sure the application can locate the file.

Avdej

0
 
basav_comConnect With a Mentor Commented:
Check this properties exists or not.

loadProperties(this.getClass().getResourceAsStream("/conf/opensaml.properties"));


package org.opensaml;
 
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Properties;
 
import javax.xml.namespace.QName;
import javax.xml.parsers.FactoryConfigurationError;
 
import org.apache.log4j.Logger;
import org.w3c.dom.Element;
 
/**
 *  OpenSAML configuration bundle.  Implemented as a singleton.  
 * 
 * @author     Walter Hoehn (wassa@columbia.edu)
 */
public class SAMLConfig {
 
	private static SAMLConfig instance;
    private Logger log = Logger.getLogger(SAMLConfig.class.getName());
 
    protected Properties properties;
    private SAMLIdentifier IDProvider = null;
    private Hashtable bindingMap = new Hashtable();
 
	protected SAMLConfig() {
 
		verifyUsableXmlParser();
 
		properties = new Properties();
		try {
			loadProperties(this.getClass().getResourceAsStream("/conf/opensaml.properties"));
		} catch (IOException e) {
			log.warn("Unable to load default library properties.");
		}
 
		org.apache.xml.security.Init.init();
 
		SAMLCondition.conditionTypeMap.put(
			new QName(XML.SAML_NS, "AudienceRestrictionCondition"),
			"org.opensaml.SAMLAudienceRestrictionCondition");
        SAMLCondition.conditionTypeMap.put(
            new QName(XML.SAML_NS, "AudienceRestrictionConditionType"),
            "org.opensaml.SAMLAudienceRestrictionCondition");
        SAMLCondition.conditionTypeMap.put(
            new QName(XML.SAML_NS, "DoNotCacheCondition"),
            "org.opensaml.SAMLDoNotCacheCondition");
        SAMLCondition.conditionTypeMap.put(
            new QName(XML.SAML_NS, "DoNotCacheConditionType"),
            "org.opensaml.SAMLDoNotCacheCondition");
 
		SAMLQuery.queryTypeMap.put(
            new QName(XML.SAMLP_NS, "AttributeQuery"),
            "org.opensaml.SAMLAttributeQuery");
		SAMLQuery.queryTypeMap.put(
            new QName(XML.SAMLP_NS, "AttributeQueryType"),
            "org.opensaml.SAMLAttributeQuery");
		SAMLQuery.queryTypeMap.put(
			new QName(XML.SAMLP_NS, "AuthenticationQuery"),
			"org.opensaml.SAMLAuthenticationQuery");
		SAMLQuery.queryTypeMap.put(
			new QName(XML.SAMLP_NS, "AuthenticationQueryType"),
			"org.opensaml.SAMLAuthenticationQuery");
		SAMLQuery.queryTypeMap.put(
			new QName(XML.SAMLP_NS, "AuthorizationDecisionQuery"),
			"org.opensaml.SAMLAuthorizationDecisionQuery");
		SAMLQuery.queryTypeMap.put(
			new QName(XML.SAMLP_NS, "AuthorizationDecisionQueryType"),
			"org.opensaml.SAMLAuthorizationDecisionQuery");
 
		SAMLStatement.statementTypeMap.put(
			new QName(XML.SAML_NS, "AttributeStatement"),
			"org.opensaml.SAMLAttributeStatement");
		SAMLStatement.statementTypeMap.put(
			new QName(XML.SAML_NS, "AttributeStatementType"),
			"org.opensaml.SAMLAttributeStatement");
		SAMLStatement.statementTypeMap.put(
			new QName(XML.SAML_NS, "AuthenticationStatement"),
			"org.opensaml.SAMLAuthenticationStatement");
		SAMLStatement.statementTypeMap.put(
			new QName(XML.SAML_NS, "AuthenticationStatementType"),
			"org.opensaml.SAMLAuthenticationStatement");
		SAMLStatement.statementTypeMap.put(
			new QName(XML.SAML_NS, "AuthorizationDecisionStatement"),
			"org.opensaml.SAMLAuthorizationDecisionStatement");
		SAMLStatement.statementTypeMap.put(
			new QName(XML.SAML_NS, "AuthorizationDecisionStatementType"),
			"org.opensaml.SAMLAuthorizationDecisionStatement");
 
        // Register default binding implementations...
        setDefaultBindingProvider(SAMLBinding.SOAP, getProperty("org.opensaml.provider.soapbinding"));
    }
 
	/**
	 * Returns the active OpenSAML configuration.
	 * @return SAMLConfig
	 */
	public synchronized static SAMLConfig instance() {
 
		if (instance == null) {
			instance = new SAMLConfig();
			return instance;
		}
		return instance;
	}
 
    /**
     * Returns the default provider of the SAMLIdentifier interface
     * @return  the default provider
     */
    public synchronized SAMLIdentifier getDefaultIDProvider() {
        if (IDProvider == null)
            IDProvider = SAMLIdentifierFactory.getInstance();
        return IDProvider;
    }
    
    public synchronized String getDefaultBindingProvider(String binding) {
        return (String)bindingMap.get(binding);
    }
    
    public synchronized void setDefaultBindingProvider(String binding, String provider) {
        bindingMap.put(binding,provider);
    }
    
	/**
	 * Enables a set of configuration properties.
	 * @param properties the configuration properties to be enabled
	 */
	public void setProperties(Properties properties) {
		this.properties.putAll(properties);
	}
 
	/**
	 * Enables a set of configuration properties.
	 * @param inStream an <code>InputStream</code> from which 
	 * a java properties file can be obtained.
	 */
	public void loadProperties(InputStream inStream) throws IOException {
		Properties newProperties = new Properties();
		newProperties.load(inStream);
		setProperties(newProperties);
	}
 
	/**
	 *  Sets a library configuration property<p>
	 * 
	 * @param  key      A property name
	 * @param  value    The value to set
	 */
	public void setProperty(String key, String value) {
		properties.setProperty(key, value);
	}
 
	/**
	 *  Gets a library configuration property
	 *
	 * @param  key      A property name
	 * @return          The property's value, or null if the property isn't set
	 */
	public String getProperty(String key) {
		return properties.getProperty(key);
	}
 
	/**
	 *  Gets a binary library configuration property in boolean form
	 *
	 * @param  key      A property name
	 * @return          The property's boolean value, or false if the property isn't set
	 */
	public boolean getBooleanProperty(String key) {
		return new Boolean(properties.getProperty(key)).booleanValue();
	}
 
    /**
     *  Sets a binary library configuration property in boolean form
     *
     * @param  key      A property name
     * @return          The property's boolean value, or false if the property isn't set
     */
    public void setBooleanProperty(String key, Boolean value) {
        setProperty(key, value.toString());
    }
    
    /**
     *  Gets a binary library configuration property in boolean form
     *
     * @param  key      A property name
     * @return          The property's boolean value, or false if the property isn't set
     */
    public int getIntProperty(String key) {
        return new Integer(properties.getProperty(key)).intValue();
    }
 
    /**
     *  Sets a binary library configuration property in boolean form
     *
     * @param  key      A property name
     * @return          The property's boolean value, or false if the property isn't set
     */
    public void setIntProperty(String key, int value) {
        setProperty(key, new Integer(value).toString());
    }
    
	private void verifyUsableXmlParser() {
		try {
			Class.forName("javax.xml.validation.SchemaFactory");
			Element.class.getDeclaredMethod("setIdAttributeNS", new Class[]{String.class, String.class,
					java.lang.Boolean.TYPE});
		} catch (NoSuchMethodException e) {
			throw new FactoryConfigurationError("OpenSAML requires an xml parser that supports DOM3 calls. "
					+ "Sun JAXP 1.3 has been included with this release and is strongly recommended. "
					+ "If you are using Java 1.4, make sure that you have enabled the Endorsed "
					+ "Standards Override Mechanism for this parser "
					+ "(see http://java.sun.com/j2se/1.4.2/docs/guide/standards/ for details).");
		} catch (ClassNotFoundException e) {
			throw new FactoryConfigurationError("OpenSAML requires an xml parser that supports JAXP 1.3. "
					+ "Sun JAXP 1.3 has been included with this release and is strongly recommended. "
					+ "If you are using Java 1.4, make sure that you have enabled the Endorsed "
					+ "Standards Override Mechanism for this parser "
					+ "(see http://java.sun.com/j2se/1.4.2/docs/guide/standards/ for details).");
		}
	}
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.