【发布时间】:2021-07-02 10:44:08
【问题描述】:
当触发 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;
}
}
我的项目结构如下:
来源:
Beans.RTU.RTU_SmallView_Bean.javaDatabase.RTU.RTU_SmallView_Select.javapojo.rtu.RTU_unit.java
网页:
rtu.rtu_smallview.xhtml
我认为它与实际服务器有关,但我不确定从哪里开始查找此错误。如果您想查看 bean 的实际代码以及其他内容,请告诉我,我将使用所有代码编辑问题。谢谢
【问题讨论】:
标签: java java-ee-7 glassfish-4 glassfish-4.1