Solved

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

Posted on 2009-04-06
4
3,301 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
4 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 168 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 166 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 166 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now