I have been working on some some J2EE 7 fun projects, and suddenly I run into some problems during deployments on my project with NetBeans 8.0.2 and glassfish 4. As you can see below, the server writes some reflect output stack trace:
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.reflect.Executable.declaredAnnotations(Executable.java:546)
at java.lang.reflect.Executable.getAnnotation(Executable.java:520)
at java.lang.reflect.Method.getAnnotation(Method.java:607)
This ArrayStoreException came wrapped in another exceptions, by reading the stack and taking consideration the moment in which the Exception actually happens we can get some thoughts of what might be going on:
- The server does not deploy the application, could be due to missing libs or bad configuration.
- The ArrayStoreException with the TypeNotPresentExceptionProxy, tells me that something is missing, but since there is no java.lang.NoClassDefFoundError, it means is not a classpath's path.
- The java.lang.reflect.Method.getAnnotation() method, it tells is something to do with annotations.
Its time to look at the Exception wrapper. So it may give some clues where to look for more information:
Severe: sun.reflect.annotation.TypeNotPresentExceptionProxy
Severe: Exception while deploying the app [ProjectEulerAnswers]
Severe: Exception during lifecycle processing
java.lang.IllegalStateException: sun.reflect.annotation.TypeNotPresentExceptionProxy. Related annotation information: annotation [@javax.ejb.Stateless(name=, description=, mappedName=)] on annotated element [class com.euler._25Beans.q11UPBean] of type [TYPE]
The log provided by GlassFish is very clear and confirms all I have learned so far ,and actually prints the name project ProjectEulerAnswer, the culprit for failing deployment and provides the name of a bad Bean (q11UPBean).
/**
+ This EJBeuler.jar module is being locally injected from my PorjectEulerAnswers.war Web module
**/
@Stateless
@LocalBean
public class q11UPBean extends prop11Gen{
@javax.interceptor.Interceptors(LoggingInterceptor.class) //this annotation is from a external module EJBintercept.jar**
private Map<String, String[]> walkingleft(String[] lineArray) {
//some code here
}
//some code here
}
As we can notice, it's the usual Stateless local EJB declaration, which we could call EJBeuler, in which should not give any trouble. Then there is an interceptor's annotation, and in this case this Interceptor is living on a different EJB module, we could call EJBintercept. Checking the Libraries on NetBeans and as expected my my EJBeuler does have reference to my EJBintercept, if there weren't it would give me a compile exception.
But accordingly is the ProjectEulerAnswers the one failing, which means the Web Project possible needs the library reference to EJBintercept. Which proven to be true and the solution to my ArrayStoreExcpeiton; Which means that at compile time the container is not capable to check all the second hand annotations references, and throws some Exceptions which is very hard to identify the real issue.
Therefore, when programing with annotation from different modules, we must check if the following example is true:
EJBeuler ---- uses compiles Libraries ----> EJBintercep;
ProjectEulerAnswers ---- uses compiles Libraries ----> EJBintercep;
ProjectEulerAnswers ---- uses compiles Libraries ----> EJBeuler;
No comments:
Post a Comment