[ 
http://nagoya.apache.org/jira/browse/HIVEMIND-78?page=comments#action_55873 ]
     
Paul Russell commented on HIVEMIND-78:
--------------------------------------

Unfortunately(!), I'm using Maven, so I'm not sure I can run Ant in forked mode 
:( As a temporary 'work around', I point a remote debugger at the build process 
and try and determine what's done wrong by looking at the message keys. I'll 
check-out hivemind and attach a patch.

> Certain classloaders (AntClassLoader for example) cause NullPointerException 
> in impl.MessageFormatter
> -----------------------------------------------------------------------------------------------------
>
>          Key: HIVEMIND-78
>          URL: http://nagoya.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

>
> 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://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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

Reply via email to