微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么glassfish服务器重启后才加载bean?

如何解决为什么glassfish服务器重启后才加载bean?

当 rtu.smallview.xhtml 动作事件被触发时,它从 java bean 请求信息,从数据库选择并将其交还给 xhtml。

xhtml 没有显示数据库中的数据,所以我在 java bean 中添加了断点以找出发生了什么问题,但是当程序加载时,它从未命中 bean 中的断点。

加载程序时服务器输出是这样说的:

Info:   WELD-000119: Not generating any bean deFinitions from Beans.RTU.RTU_SmallView_Bean because of underlying class loading error: Type pojo.rtu.RTU_unit not found.  If this is unexpected,enable DEBUG logging to see the full error.

所以我停止了服务器,清理并再次构建了项目,当它第一次运行时它加载了 bean,信息被检索和显示。但是,如果我再次清理并构建项目,当它第二次运行时,它会显示相同的 WELD-000119 错误

我只复制并粘贴了使 RTU 部分运行到新项目的代码,服务器永远不会抛出此错误,并且每次请求 bean 和每次启动服务器时它都会工作。

>

编辑1: 当我在启动后重新启动 NetBeans 并清理并构建项目时,它会说:

Note: C:\Users\Administrator\Documents\NetBeansprojects\OIUSA_1\src\java\Beans\RTU\RTU_SmallView_Bean.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

这是它唯一说明的 Java 类,所以这是我用于该类的代码

package Beans.RTU;

import Database.RTU.RTU_SmallView_Select;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import pojo.rtu.RTU_unit;

/**
 *
 * @author Administrator
 */
@Named(value = "rtu_SmallView_Bean")
@RequestScoped
public class RTU_SmallView_Bean {

    public RTU_SmallView_Bean() {
        try {
            RTU_SmallView_Select selectData;
            selectData = new RTU_SmallView_Select();
            this.smallViewList = selectData.getData();
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }

    List<RTU_unit> smallViewList = new ArrayList();
    String unit_type;
    int unit_number;
    String rig_name;
    String location_name;

    public List<RTU_unit> getSmallViewList() {
        return smallViewList;
    }

    public void setSmallViewList(List<RTU_unit> smallViewList) {
        this.smallViewList = smallViewList;
    }

    public String getUnit_type() {
        return unit_type;
    }

    public void setUnit_type(String unit_type) {
        this.unit_type = unit_type;
    }

    public int getUnit_number() {
        return unit_number;
    }

    public void setUnit_number(int unit_number) {
        this.unit_number = unit_number;
    }

    public String getRig_name() {
        return rig_name;
    }

    public void setRig_name(String rig_name) {
        this.rig_name = rig_name;
    }

    public String getLocation_name() {
        return location_name;
    }

    public void setLocation_name(String location_name) {
        this.location_name = location_name;
    }
}

我的项目结构如下:

来源:

  1. Beans.RTU.RTU_SmallView_Bean.java
  2. Database.RTU.RTU_SmallView_Select.java
  3. pojo.rtu.RTU_unit.java

网页:

  1. rtu.rtu_smallview.xhtml

我认为它与实际服务器有关,但我不确定从哪里开始查找此错误。如果您想查看 bean 的实际代码以及其他内容,请告诉我,我将使用所有代码编辑问题。谢谢

解决方法

问题已解决,文件 RTU_Unit.java 位于名为 pojo.rtu 的文件夹中。我删除了该文件夹,重新使用新名称 pojo.rtus,重构了新文件夹的文件 RTU_Unit.java,问题就消失了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?