[Prev] Thread [Next]  |  [Prev] Date [Next]

[jboss-user] [Beginners Corner] - Reflection issue with jars in ear/lib directory in 4.2.0CR2 mexcell Mon Apr 30 18:10:44 2007

Using 4.2.0CR2.

I am using TestNG from within a Stateless Session Bean. The TestNG jar for 
jdk1.5 is in the ear/lib directory, and I can import the main TestNG class just 
fine, so I know it is actually on the classpath. TestNG uses reflection 
internally to load and instantiate some TestRunners, etc. I get:

  |     java.lang.Class.getConstructor0(Class.java:2647)
  |     java.lang.Class.getConstructor(Class.java:1629)
  |     org.testng.TestNG.initializeAnnotationFinders(TestNG.java:692)
  |     org.testng.TestNG.run(TestNG.java:701)

The relevant section of ClassHelper.java is:

  |   try {
  |       Class clazz= forName(JDK5_ANNOTATIONFINDER_CLASS);
  |       Constructor ctor= clazz.getConstructor(new Class[] 
{IAnnotationTransformer.class});//Exception here
  |       return (IAnnotationFinder) ctor.newInstance(new Object[] 
  |     }
  |     catch(Exception ex) {
  |       throw new TestNGException("Cannot create/initialize the JDK5 
annotation finder " + JDK5_ANNOTATIONFINDER_CLASS, ex);
  |     }

Please note that I added the comment showing which line throws the exception 
(line 175)

It works fine when called from the web context if the jar is in WEB-INF/lib, 
but that doesn't meet our needs.

According to http://jira.jboss.com/jira/browse/JBAS-4037 the lib directory 
within an ear should work as defined in the EE5 spec - Does that not include 
reflection? (Or is this a bug?)

Thanks in advance for any help you can supply. 

View the original post : 

Reply to the post : 
jboss-user mailing list