我有一个bean应该从数据库中检索人员,然后将它们放在网页上显示的列表中。我不断收到托管bean注入失败,这似乎是由数据库和服务器之间的某种联系搞砸了。
这是堆栈跟踪。 https://gist.github.com/blaxened/85a6861faf2373c26506
这是服务器日志的最后一部分,虽然它看起来与堆栈跟踪非常相似。 https://gist.github.com/blaxened/f0bc6028d27cabcbd325
我知道数据库/表存在
这一事实这是我的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="com.jsfprohtml5_AIM_war_1.0PU" transaction-type="JTA">
<jta-data-source>jdbc/__default</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
这是连接数据库的java类
package com.jsfprohtml5.firstapplication.model;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
*
* @author Black
*/
@Entity
@Table(name = "MYTABLE")
@NamedQueries({
@NamedQuery(name = "AimStaff.findAll", query = "SELECT a FROM AimStaff a"),
@NamedQuery(name = "AimStaff.findById", query = "SELECT a FROM AimStaff a WHERE a.id = :id"),
@NamedQuery(name = "AimStaff.findBySname", query = "SELECT a FROM AimStaff a WHERE a.sname = :sname"),
@NamedQuery(name = "AimStaff.findByDatejoined", query = "SELECT a FROM AimStaff a WHERE a.datejoined = :datejoined"),
@NamedQuery(name = "AimStaff.findByLocale", query = "SELECT a FROM AimStaff a WHERE a.locale = :locale"),
@NamedQuery(name = "AimStaff.findByPhone", query = "SELECT a FROM AimStaff a WHERE a.phone = :phone")})
public class AimStaff implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "ID")
private Integer id;
@Size(max = 255)
@Column(name = "SNAME")
private String sname;
@Size(max = 255)
@Column(name = "DATEJOINED")
private String datejoined;
@Size(max = 255)
@Column(name = "LOCALE")
private String locale;
// @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
@Size(max = 100)
@Column(name = "PHONE")
private String phone;
public AimStaff() {
}
public AimStaff(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getDatejoined() {
return datejoined;
}
public void setDatejoined(String datejoined) {
this.datejoined = datejoined;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof AimStaff)) {
return false;
}
AimStaff other = (AimStaff) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.jsfprohtml5.firstapplication.model.AimStaff[ id=" + id + " ]";
}
}
所以我不确定是什么问题。如果有的话,请告诉我其他文件需要上传的内容。
答案 0 :(得分:0)
Applicationserver无法找到您的表MYTABLE
。您是否可以验证服务器是否能够连接并在配置的数据源中找到Table?
您可以发布persistence.xml
吗?