When I try to deploy ejd-ear, web-ear on to glassfish server. I added an ejb client dependency in web project. The ejb-ear deploys successfully. But when I try to deploy web
Solution:
While deploying you will stop several times at this break point. See this reference and remember the last before deployment error arise. Than check Annotations in last "this" class. You can also put break point into AnnotationParser.parseClassArray method, but it is compiled code and break point on the method is very slow. (In my case with method break point I could not depoy application at last).
This can also happen in the following situation:
project A is some library, a maven project in your eclipse.
It has a class named org.exmaple.Foo
which is in the src/test/java/
directory.
in your project B where the error occurs you are try to access this class. But this isn't possible.
Eclipse won't complain because it "knows" both classes.
If you are running mvn clean install
on the project that does not work maven will give you a proper error message.
I think this erro can occur since Kepler but I am not sure. At least it is still present in Luna :)
I think the best way is to put a break point in the constructor of java.lang.TypeNotPresentException and check the second argument of type Throwable to know the root cause
Had the same exception recently with JUnit. The situation was like this:
@SuiteClasses({MyTestClass.class})
public class MySuite {
...
}
Problem is that JVM was unable to process MyTestClass because it was missing dependencies in the classpath (another JAR file was missing). But the exception provided no information on which class was missing.
Solution was to temporarily add a static initialization block to MySuite, that instantiates MyTestClass:
@SuiteClasses({MyTestClass.class})
public class MySuite {
static {
new MyTestClass();
}
}
this causes JVM to run the static block first, try to instantiate MyTestClass, find out the missing class and report a proper exception. Then you can add the missing dependency and remove the temporary static block.
The issue is conflicting with Jar file. Verify the list of jar files inside war file lib folder. Remove unnecessary and conflicting jar files. Then the deployment will be successful.
TypeNotPresentExceptionProxy error is not specific to a particular dependency and depends on each project's classpath. So verify your maven dependencies tree. For example, I fell into this error one time when I had two dependencies of JUnit so there were two versions of JUnit annotations in the classpath.
You can put a breakpoint in some of the methods of class "java.lang.Class":
For example:
java.lang.Class.getAnnotation
java.lang.Class.getAnnotations
After that, you will be able to discover which class cause the problem... search inside the class for annotations and check your classpath for ambiguities.