升级到Netbeans 8.0.1和Glassfish 4,1后,软件包不存在 [英] Package does not exist after upgrading to Netbeans 8.0.1 and Glassfish 4,1

查看:336
本文介绍了升级到Netbeans 8.0.1和Glassfish 4,1后,软件包不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习JavaEE CDI,并使用NetBeans 8.0 + Glassfish 4创建了一个小型应用程序。
升级到NetBeans 8.0.1和Glassfish 4.1后,我收到很多错误,报告某些软件包没有存在。
例如,我不能使用以下代码,因为我收到包javax.enterprise.event不存在的消息。

  package jlacerda; 

import javax.inject.Inject;
import javax.enterprise.event.Event;

public class CMensagem
{
@Inject
private Event< Evento> gerarEvento;

public String getMensagem()
{
returnHello world!;
}

public void gerarEvento()
{
Evento evento = new Evento();
evento.setMensagem(Objeto criado a partir da classe CMensagem);

gerarEvento.fire(evento);






这种情况也发生在软件包中:

  import javax.enterprise.inject.Alternative; 
import javax.decorator.Decorator;
import javax.decorator.Delegate;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;

如果我将服务器更改为Glassfish 4.0,则相同的代码将按预期运行,并且所有软件包都会正确导入。

我在NetBeans和Glassfish论坛上搜索过,但没有发现任何类似的情况。



GlassFish 4.1将其CDI版本更新为1.2(Glassfish 4.0)使用CDI 1.1)。由于您没有提供关于您的应用程序如何打包的信息,因此我会为您提供所有要查看的要点:


  1. 检查你的战争中没有 cdi-api.jar 文件


  2. 检查你是否在你的战争中没有任何 weld 相关的罐子


  3. 使用版本1.2的CDI Api编译你的代码。检查网站
    规范
    以下载文件或更改您的Maven配置






 < dependency> ; 
< groupId> javax.enterprise< / groupId>
< artifactId> cdi-api< / artifactId>
< version> 1.2< / version>
< scope>提供< / scope>
< /依赖关系>






1.1和1.2但所有的OSGi配置已经改变,所以你可能会遇到这些变化的问题。


I'm learning JavaEE CDI and I created a small application with NetBeans 8.0+Glassfish 4. After upgrading to NetBeans 8.0.1 and Glassfish 4.1 I'm getting a lot of errors reporting that some packages does not exist. For example, I cannot use the following code because I'm getting the message that package javax.enterprise.event does not exist.

package jlacerda;

import javax.inject.Inject;
import javax.enterprise.event.Event;

public class CMensagem 
{
    @Inject
    private Event<Evento> gerarEvento;

    public String getMensagem()
    {
        return "Hello world!";
    }

    public void gerarEvento()
    {
        Evento evento = new Evento();
        evento.setMensagem("Objeto criado a partir da classe CMensagem");

        gerarEvento.fire(evento);
    }
}

This situation also occurs with packages:

import javax.enterprise.inject.Alternative;
import javax.decorator.Decorator;
import javax.decorator.Delegate;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;

If I change the server to Glassfish 4.0 the same code runs as expected and all the packages are correctly imported.

I searched in the NetBeans and Glassfish forums but I did not found any situation like this one.

Thanks in advance for any sugestion that might help me solving this situation.

解决方案

Glassfish 4.1 updated its CDI version to 1.2 (Glassfish 4.0 used CDI 1.1). As you don't give info on how your application is packaged, I'll give you all the points to check:

  1. Check that don't have a cdi-api.jar file in your war

  2. Check you don't have any weld related jar in your war as well

  3. Use version 1.2 of CDI Api to compile your code. Check on the site spec to download the file or change your Maven config like this


<dependency>
    <groupId>javax.enterprise</groupId>
    <artifactId>cdi-api</artifactId>
    <version>1.2</version>
    <scope>provided</scope>
</dependency>


There are no change in the API between 1.1 and 1.2 but all the OSGi config has changed so you might encounter an issue with those changes.

这篇关于升级到Netbeans 8.0.1和Glassfish 4,1后,软件包不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆