如何解决为什么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;
}
}
我的项目结构如下:
来源:
Beans.RTU.RTU_SmallView_Bean.java
Database.RTU.RTU_SmallView_Select.java
pojo.rtu.RTU_unit.java
网页:
rtu.rtu_smallview.xhtml
我认为它与实际服务器有关,但我不确定从哪里开始查找此错误。如果您想查看 bean 的实际代码以及其他内容,请告诉我,我将使用所有代码编辑问题。谢谢
解决方法
问题已解决,文件 RTU_Unit.java
位于名为 pojo.rtu
的文件夹中。我删除了该文件夹,重新使用新名称 pojo.rtus
,重构了新文件夹的文件 RTU_Unit.java
,问题就消失了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。