Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2856

PackageStringResourceLoader.loadStringResource() causes NullPointerException when used in a Class within the root package (i.e. it has no package declaration)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.4.7
    • 1.4.9, 1.5-M1
    • wicket
    • None

    Description

      Cause is the line

      String packageName = clazz.getPackage().getName();

      because Class.getPackage() [respectivly Package.getPackage(Class)] returns null if a class has no dot in its full qualifier.

      Example (from the Java Doc for org.apache.wicket.model.StringResourceModel):

      -------------------- CODE ------------------------
      import org.apache.wicket.markup.html.WebPage;
      import org.apache.wicket.markup.html.basic.Label;
      import org.apache.wicket.model.StringResourceModel;

      public class MyPage extends WebPage {

      public MyPage()

      { add(new Label("username", new StringResourceModel("label.username", this, null))); }

      }
      -------------------- CODE ------------------------

      If this class is in the root directory (no package declaration as above) a NullPointerException is thrown.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            d.meuser Dirk Meuser
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: