[ http://issues.apache.org/jira/browse/HIVEMIND-78?page=all ]
     
James Carman resolved HIVEMIND-78:
----------------------------------

     Resolution: Fixed
    Fix Version: 1.1

> Certain classloaders (AntClassLoader for example) cause NullPointerException 
> in impl.MessageFormatter
> -----------------------------------------------------------------------------------------------------
>
>          Key: HIVEMIND-78
>          URL: http://issues.apache.org/jira/browse/HIVEMIND-78
>      Project: HiveMind
>         Type: Bug
>   Components: framework
>     Versions: 1.0, 1.1
>  Environment: MacOSX. Running unit tests of code running within hivemind 
> using JUnit inside Ant inside Maven.
>     Reporter: Paul Russell
>     Assignee: James Carman
>      Fix For: 1.1
>  Attachments: hivemind-package-defect.diff
>
> MessageFormat uses java.lang.Class.getPackage() to obtain the name of the 
> package for the 'reference class' in order to choose an appropriate resource 
> bundle. Unfortunately,  java.lang.Class.getPackage() does not guarantee to 
> return a Package object.
> It may return 'null' if (a) the reference class is loaded by the primordial 
> classloader, or (b) if the classloader didn't create a package object and 
> associated it with the class.
> I am seeing this problem while running unit tests of my application within 
> Maven. Example stacktrace follows:
> java.lang.ExceptionInInitializerError
>       at 
> org.apache.hivemind.impl.RegistryImpl.getServicePoint(RegistryImpl.java:142)
>       at 
> org.apache.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:149)
>       at org.apache.hivemind.impl.RegistryImpl.startup(RegistryImpl.java:321)
>       at 
> org.apache.hivemind.impl.RegistryBuilder.constructRegistry(RegistryBuilder.java:417)
>       ... lots more
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.hivemind.impl.MessageFormatter.<init>(MessageFormatter.java:49)
>       at 
> org.apache.hivemind.impl.MessageFormatter.<init>(MessageFormatter.java:44)
>       at org.apache.hivemind.impl.ImplMessages.<clinit>(ImplMessages.java:45)
>       ... 59 more
> The only safe way that I can see to achieve the same effect as 
> Class.getPackage().getName() is to do something like:
> String lReferenceClassName = referenceClass.getName();
> String lPackageName = 
> lReferenceClassName.substring(0,lReferenceClassName.lastIndexOf('.'));
> ... probably as a private function within MessageFormat itself.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to