Return-Path: Delivered-To: apmail-wicket-users-archive@locus.apache.org Received: (qmail 67611 invoked from network); 2 Jun 2008 09:35:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jun 2008 09:35:11 -0000 Received: (qmail 2763 invoked by uid 500); 2 Jun 2008 09:35:11 -0000 Delivered-To: apmail-wicket-users-archive@wicket.apache.org Received: (qmail 2735 invoked by uid 500); 2 Jun 2008 09:35:11 -0000 Mailing-List: contact users-help@wicket.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@wicket.apache.org Delivered-To: mailing list users@wicket.apache.org Received: (qmail 2719 invoked by uid 99); 2 Jun 2008 09:35:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2008 02:35:11 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2008 09:34:21 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1K36R4-0008VG-At for users@wicket.apache.org; Mon, 02 Jun 2008 02:34:38 -0700 Message-ID: <17597421.post@talk.nabble.com> Date: Mon, 2 Jun 2008 02:34:38 -0700 (PDT) From: wenm To: users@wicket.apache.org Subject: problem when reading properties file MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: wm@tdc.dk X-Virus-Checked: Checked by ClamAV on apache.org I want to read a properties file test.properties, and show the value which is defined in properties file in a lable. But I can't read the properties file I have tried property.load(ClassLoader.getSystemResourceAsStream("test.properties")); property.load(this.getClass().getClassLoader().getResourceAsStream("test.properties")); property.load(PackageResource.get(test.class, "test.properties").getResourceStream().getInputStream()); property.load(((WebApplication) Application.get()).getServletContext().getResourceAsStream("test.properties")); But it always generate null point error java.lang.NullPointerException at java.util.Properties$LineReader.readLine(Properties.java:365) at java.util.Properties.load(Properties.java:293) Then I tried to test reading in main method, and it works fine there. public static void main(String[] args){ Properties property = new Properties(); try { property.load(ClassLoader.getSystemResourceAsStream("test.properties")); } catch (IOException e) { e.printStackTrace(); } System.out.println(property.getProperty("a key")); } Really can't understand why. Did I do something in wrong way? Thanks for any help or sugestion. -- View this message in context: http://www.nabble.com/problem-when-reading-properties-file-tp17597421p17597421.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org For additional commands, e-mail: users-help@wicket.apache.org