Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-04-06
4
Medium Priority
?
3,553 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:vijaymittal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 28

Accepted Solution

by:
rrz earned 672 total points
ID: 24077971
Is there a key in the properties file with the name that is being searched for ?
Show us the line that has it.
0
 
LVL 3

Assisted Solution

by:avdej
avdej earned 664 total points
ID: 24078222
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
 
LVL 12

Assisted Solution

by:basav_com
basav_com earned 664 total points
ID: 24078298
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question