部署 web-ear 时 sun.reflect.annotation.TypeNotPresentExceptionProxy 错误

发布于 2024-11-18 06:26:55 字数 4859 浏览 5 评论 0原文

当我尝试将 ejd-ear、web-ear 部署到 glassfish 服务器上时。 我在 Web 项目中添加了 ejb 客户端依赖项。 ejb-ear 部署成功。但是当我尝试部署 web-ear 时,它抛出异常。

sun.reflect.annotation.TypeNotPresentExceptionProxy
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
    at java.lang.Class.getAnnotations(Class.java:3050)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:285)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:195)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:606)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:459)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:432)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:408)
    at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:383)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:246)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:255)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:216)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:165)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:180)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:93)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:826)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:768)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

有什么想法吗?

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-ear, it throws an exception .

sun.reflect.annotation.TypeNotPresentExceptionProxy
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
    at java.lang.Class.getAnnotations(Class.java:3050)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:285)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:195)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:606)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:459)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:432)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:408)
    at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:383)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:246)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:255)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:216)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:165)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:180)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:93)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:826)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:768)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

隐诗 2024-11-25 06:26:55

我认为最好的方法是在 java.lang.TypeNotPresentException 的构造函数中放置一个断点,并检查 Throwable 类型的第二个参数以了解根本原因

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

横笛休吹塞上声 2024-11-25 06:26:55

最近 JUnit 也出现了同样的异常。
情况是这样的:

@SuiteClasses({MyTestClass.class})
public class MySuite {
    ...
}

问题是 JVM 无法处理 MyTestClass,因为它在类路径中缺少依赖项(缺少另一个 JAR 文件)。但该异常没有提供有关缺少哪个类的信息。

解决方案是暂时向 MySuite 添加一个静态初始化块,实例化 MyTestClass:

@SuiteClasses({MyTestClass.class})
public class MySuite {
    static {
        new MyTestClass();
    }
}

这会导致 JVM 首先运行静态块,尝试实例化 MyTestClass,找出丢失的类并报告正确的异常。然后您可以添加缺少的依赖项并删除临时静态块。

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.

小瓶盖 2024-11-25 06:26:55

我们实际上刚刚遇到了同样的异常。我们目前有一个项目从 Java 转移到 Kotlin。在项目中,所有测试类都是用 Kotlin 编写的,因此我们将文件夹命名为 src/test/kotlin。我们还根据 Kotlin 文档中的“编译 Kotlin 和 Java 源代码”部分配置了 pom

我们忘记的是“仅编译 Kotlin 源代码”部分中描述的测试目录定义:

;
${project.basedir}/src/test/kotlin

令人困惑的是,IntelliJ 自动编译按要求编译了所有测试类,然后 Maven 构建也成功了。仅在 mvn clean test 之后,才会发生 TypeNotPresentExceptionProxy

We actually just ran into the same Exception. We have a project that we currently transfer from Java to Kotlin. In the project, all test classes were written in Kotlin and therefore we named the folder src/test/kotlin. We also configured our pom according to the 'Compiling Kotlin and Java sources' section in the Kotlin documentation.

What we had forgotten was the test directory definition described in the ' Compiling Kotlin only source code' section:

<build>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
</build>

It has also been a bit confusing that the IntelliJ auto compilation compiled all test classes as required and afterwards also the maven build was successful. Only after a mvn clean test the TypeNotPresentExceptionProxy occurred.

无风消散 2024-11-25 06:26:55

解决方案:

  1. 通过调试连接到 Glassfish 服务器
  2. 将断点放入行中
    • java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
  3. 部署您的应用程序。

部署时,您将在此断点处多次停止。请参阅参考并记住出现部署错误之前的最后一个参考。比检查最后一个“this”类中的注释。
您还可以在 AnnotationParser.parseClassArray 方法中放置断点,但它是编译代码,在该方法上断点非常慢。 (在我的情况下,使用方法断点,我最终无法部署应用程序)。

Solution:

  1. Connect with debug to Glassfish server
  2. Put break point into line
    • java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
  3. Deploy your application.

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).

若沐 2024-11-25 06:26:55

这种情况也可能发生在以下情况:

项目 A 是某个库,是 Eclipse 中的一个 Maven 项目。
它有一个名为 org.exmaple.Foo 的类,位于 src/test/java/ 目录中。

在发生错误的项目 B 中,您尝试访问此类。但这是不可能的。

Eclipse 不会抱怨,因为它“知道”这两个类。
如果您在不起作用的项目上运行mvn clean install,maven 会给您一条正确的错误消息。

我认为这个错误可能会在开普勒之后发生,但我不确定。至少它仍然存在于 Luna :)

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 :)

扛刀软妹 2024-11-25 06:26:55

该问题与 Jar 文件冲突。验证 war 文件 lib 文件夹内的 jar 文件列表。删除不必要的和冲突的 jar 文件。然后部署就成功了。

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.

冬天旳寂寞 2024-11-25 06:26:55

TypeNotPresentExceptionProxy 错误并不特定于特定依赖项,而是取决于每个项目的类路径。
因此,请验证您的 Maven 依赖关系树。
例如,有一次我遇到了这个错误,当时我有两个 JUnit 依赖项,因此类路径中有两个版本的 JUnit 注释。

您可以在类“java.lang.Class”的某些方法中放置断点:

例如:

java.lang.Class.getAnnotation 
java.lang.Class.getAnnotations 

之后,您将能够发现哪个类导致问题......在类内部搜索注释并检查您的类路径出于歧义。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文