2015-04-05 2 views
0

У меня возникла следующая ошибка при развертывании в Glassfish на Netbeans. Это первый раз, когда я пытаюсь CDI. Я прочитал все сообщения по этому вопросу без всякой помощи.WELD-001408: Невыполненные зависимости для типа Сотрудник с квалификаторами @Default

Log:

Info: visiting unvisited references 
Info: visiting unvisited references 
Info: visiting unvisited references 
Info: visiting unvisited references 
Info: Enity.Test.Employee actually got transformed 
Info: EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd 
Info: file:/C:/Users/Bala/Documents/NetBeansProjects/TestAppl/dist/gfdeploy/TestAppl/TestAppl-ejb_jar/_TestAppl-ejbPU login successful 
Info: Portable JNDI names for EJB EmployeeEJB: [java:global/TestAppl/TestAppl-ejb/EmployeeEJB, java:global/TestAppl/TestAppl-ejb/EmployeeEJB!SessionlessEmployee.EmployeeEJB] 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
Severe: Exception during lifecycle processing 
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Employee with qualifiers @Default 
    at injection point [BackedAnnotatedField] @Inject private Managedbean.Testapp.employeeController.employee 
    at Managedbean.Testapp.employeeController.employee(employeeController.java:0) 
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:234) 
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131) 
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:496) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) 
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:356) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:356) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722) 
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534) 
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224) 
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Employee with qualifiers @Default 
    at injection point [BackedAnnotatedField] @Inject private Managedbean.Testapp.employeeController.employee 
    at Managedbean.Testapp.employeeController.employee(employeeController.java:0) 
    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370) 
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291) 
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134) 
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165) 
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529) 
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:515) 
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:490) 
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:419) 
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90) 
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:225) 
    ... 41 more 

Severe: Exception while loading the app 
Severe: Undeployment failed for context /TestAppl-war 
Info: file:/C:/Users/Bala/Documents/NetBeansProjects/TestAppl/dist/gfdeploy/TestAppl/TestAppl-ejb_jar/_TestAppl-ejbPU logout successful 
Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Employee with qualifiers @Default 
    at injection point [BackedAnnotatedField] @Inject private Managedbean.Testapp.employeeController.employee 
    at Managedbean.Testapp.employeeController.employee(employeeController.java:0) 
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Employee with qualifiers @Default 
    at injection point [BackedAnnotatedField] @Inject private Managedbean.Testapp.employeeController.employee 
    at Managedbean.Testapp.employeeController.employee(employeeController.java:0) 
    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370) 
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291) 
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134) 
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165) 
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529) 
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:515) 
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:490) 
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:419) 
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90) 
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:225) 
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131) 
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:496) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) 
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:356) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:356) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722) 
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534) 
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224) 
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) 
    at java.lang.Thread.run(Thread.java:745) 

Моя программа Код:

TestAppl войны

index.xhtml

<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:h="http://xmlns.jcp.org/jsf/html" 
     xmlns:f="http://xmlns.jcp.org/jsf/core"> 
    <h:head> 
     <title>Facelet Title</title> 
    </h:head> 
    <h:body> 

     <h:form> 
     <h:panelGrid columns="2" > 
     <h:outputLabel value="First Name : "/> 
     <h:inputText value="#{employeeController.employee.firstname}" /> 
     <h:outputLabel value="Last Name : "/> 
     <h:inputText value="#{employeeController.employee.lastName}"/> 
     <h:outputLabel value="Date of Birth : "/> 
     <h:inputText value="#{employeeController.employee.dob}"> 
       <f:convertDateTime pattern="dd/mm/yyyy"/> 
     </h:inputText> 
     <h:outputLabel value="Phone : "/> 
     <h:inputText value="#{employeeController.employee.phone}"/> 
     <h:outputLabel value="Email : "/> 
     <h:inputText value="#{employeeController.employee.email}"/> 
     </h:panelGrid> 
     <h:commandButton value="Add New Employee"         
         action="#{employeeController.addNewEmployee()}"/>    
     </h:form> 
    </h:body> 
</html> 

employeeController.java

package Managedbean.Testapp; 

import Enity.Test.Employee; 
import SessionlessEmployee.EmployeeEJB; 
import java.io.Serializable; 
import java.util.Date; 
import javax.enterprise.context.RequestScoped; 
import javax.inject.Inject; 


import javax.inject.Named; 

/** 
* 
* @author Bala 
*/ 
@Named(value = "employeeController") 
@RequestScoped 
public class employeeController implements Serializable { 
    private Employee employee = new Employee(); 
    @Inject private EmployeeEJB employeeEJB; 

    /** 
    * Creates a new instance of employeeController 
    */ 
    private static final long serialVersionUID = 1L; 

    private String firstname; 

    private String middlename; 

    private String lastname; 

    private Date dob; 

    private String phone; 

    private String email; 

    public employeeController() { 


    } 


    public void setFirstname(String firstname) { 
     this.firstname = firstname; 
    } 



    public void setMiddlename(String middlename) { 
     this.middlename = middlename; 
    } 



    public void setLastname(String lastname) { 
     this.lastname = lastname; 
    } 



    public void setDob(Date dob) { 
     this.dob = dob; 
    } 



    public void setPhone(String phone) { 
     this.phone = phone; 
    } 


    public void setEmail(String email) { 
     this.email = email; 
    } 

    public void addNewEmployee() { 
     employee = employeeEJB.addNew(employee); 

    } 



} 

EmployeeEJB

package SessionlessEmployee; 

import Enity.Test.Employee; 
import java.util.List; 
import javax.ejb.Stateless; 
import javax.ejb.LocalBean; 
import javax.persistence.EntityManager; 
import javax.persistence.PersistenceContext; 
import javax.persistence.TypedQuery; 


@Stateless 
@LocalBean 
public class EmployeeEJB { 
    @PersistenceContext(unitName = "TestAppl-ejbPU") 
    private EntityManager entityManager; 

     public List<Employee> findEmployees(){ 
       TypedQuery<Employee> query = entityManager.createNamedQuery("findAllEmployees", Employee.class);   
       return query.getResultList(); 
     } 

     public Employee addNew(Employee employee) { 
       entityManager.persist(employee); 
       return employee; 
     } 

} 

Сотрудник

package Enity.Test; 

import java.io.Serializable; 
import java.util.Date; 
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.persistence.Temporal; 
import javax.persistence.TemporalType; 
import javax.validation.constraints.NotNull; 
import javax.validation.constraints.Size; 
import javax.xml.bind.annotation.XmlRootElement; 


@Entity 
@Table(name = "EMPLOYEE") 
@XmlRootElement 
@NamedQueries({ 
    @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"), 
    @NamedQuery(name = "Employee.findById", query = "SELECT e FROM Employee e WHERE e.id = :id"), 
    @NamedQuery(name = "Employee.findByFirstname", query = "SELECT e FROM Employee e WHERE e.firstname = :firstname"), 
    @NamedQuery(name = "Employee.findByMiddlename", query = "SELECT e FROM Employee e WHERE e.middlename = :middlename"), 
    @NamedQuery(name = "Employee.findByLastname", query = "SELECT e FROM Employee e WHERE e.lastname = :lastname"), 
    @NamedQuery(name = "Employee.findByDob", query = "SELECT e FROM Employee e WHERE e.dob = :dob"), 
    @NamedQuery(name = "Employee.findByPhone", query = "SELECT e FROM Employee e WHERE e.phone = :phone"), 
    @NamedQuery(name = "Employee.findByEmail", query = "SELECT e FROM Employee e WHERE e.email = :email")}) 
public class Employee implements Serializable { 
    private static final long serialVersionUID = 1L; 
    @Id 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "ID") 
    private Integer id; 
    @Size(max = 100) 
    @Column(name = "FIRSTNAME") 
    private String firstname; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 100) 
    @Column(name = "MIDDLENAME") 
    private String middlename; 
    @Size(max = 100) 
    @Column(name = "LASTNAME") 
    private String lastname; 
    @Column(name = "DOB") 
    @Temporal(TemporalType.DATE) 
    private Date dob; 
    // @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 = 10) 
    @Column(name = "PHONE") 
    private String phone; 
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation 
    @Size(max = 100) 
    @Column(name = "EMAIL") 
    private String email; 

    public Employee() { 
    } 

    public Employee(Integer id) { 
     this.id = id; 
    } 

    public Employee(Integer id, String middlename) { 
     this.id = id; 
     this.middlename = middlename; 
    } 

    public Integer getId() { 
     return id; 
    } 

    public void setId(Integer id) { 
     this.id = id; 
    } 

    public String getFirstname() { 
     return firstname; 
    } 

    public void setFirstname(String firstname) { 
     this.firstname = firstname; 
    } 

    public String getMiddlename() { 
     return middlename; 
    } 

    public void setMiddlename(String middlename) { 
     this.middlename = middlename; 
    } 

    public String getLastname() { 
     return lastname; 
    } 

    public void setLastname(String lastname) { 
     this.lastname = lastname; 
    } 

    public Date getDob() { 
     return dob; 
    } 

    public void setDob(Date dob) { 
     this.dob = dob; 
    } 

    public String getPhone() { 
     return phone; 
    } 

    public void setPhone(String phone) { 
     this.phone = phone; 
    } 

    public String getEmail() { 
     return email; 
    } 

    public void setEmail(String email) { 
     this.email = email; 
    } 

    @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 Employee)) { 
      return false; 
     } 
     Employee other = (Employee) 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 "Enity.Test.Employee[ id=" + id + " ]"; 
    } 

} 

Таблица

create table "Database".EMPLOYEE 
(
    ID INTEGER not null primary key, 
    FIRSTNAME VARCHAR(100), 
    MIDDLENAME VARCHAR(100) not null, 
    LASTNAME VARCHAR(100), 
    DOB DATE, 
    PHONE VARCHAR(10), 
    EMAIL VARCHAR(100) 
) 

beans.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" 
     bean-discovery-mode="all"> 
</beans> 

Это автоматический г источник enerated при развертывании

Employee_.java

package Enity.Test; 

import java.util.Date; 
import javax.annotation.Generated; 
import javax.persistence.metamodel.SingularAttribute; 
import javax.persistence.metamodel.StaticMetamodel; 

@Generated(value="EclipseLink-2.5.2.v20140319-rNA", date="2015-04-06T09:18:49") 
@StaticMetamodel(Employee.class) 
public class Employee_ { 

    public static volatile SingularAttribute<Employee, Integer> id; 
    public static volatile SingularAttribute<Employee, String> phone; 
    public static volatile SingularAttribute<Employee, String> middlename; 
    public static volatile SingularAttribute<Employee, String> email; 
    public static volatile SingularAttribute<Employee, Date> dob; 
    public static volatile SingularAttribute<Employee, String> lastname; 
    public static volatile SingularAttribute<Employee, String> firstname; 

} 

Любые идеи?

+0

Этого имя класса 'employeeController' не в соответствии с основными конвенциями Java именования. Это должно быть написано на верблюжьем корпусе, например 'EmployeeController'. (В JSF существует, по существу, только один контроллер, который является «FacesServlet». Все остальные управляемые компоненты, которые вы должны проектировать в своем приложении, по существу являются моделями, а не контроллерами, как вы, кажется, взяли на себя из самого имени - «EmployeeController») , – Tiny

ответ

2

Эта строка кода в EmployeeController вызывает исключение для исключения private @Inject Employee employee = new Employee();. Вы пытаетесь ввести Employee, но это не тот компонент, который CDI может вводить. Если вы отбросите аннотацию @Inject, она должна решить проблему.

В качестве примечания private @Inject EmployeeEJB employeeEJB; следует аннотация @EJB, а не @Inject

+3

Он также импортирует неправильную аннотацию 'javax.faces.bean.RequestScoped' (родной JSF) вместо импорта из' javax.enterprise.context.RequestScoped' (артефакт CDI). ('@ Inject' в основном предпочтительнее, чем' @ EJB' (локальный). Поскольку 'EmployEJB' является автономным локальным EJB, вполне законно его вводить с помощью' @ Inject' в управляемых бинами CDI. Эта строка (объект JPA - виновник) 'private @Inject Employee employee = new Employee();' полностью не требуется в управляемых компонентах. Внедрение интерфейса 'java.io.Serializable' в управляемом компоненте, обработанном запросом, совершенно излишне). – Tiny

+0

Спасибо вам обоим. Я смог добиться прогресса :) больше ошибок. и я получил лучшее понимание. Мне пришлось загрузить библиотеку cdi и добавить ее. Можете ли вы дать более подробную информацию о «Внедрение интерфейса java.io.Serializable в обработанном запросом управляемом компоненте, является излишне лишним».??Я обновил employeeController, но мой следующий шаг - выяснить, почему данные не были записаны в таблицу :) – workingman

+0

Ваш ответ решает проблему @ рабочего, но узнайте, что CDI может вводить POJO ([ссылка] (http: //www.adam -bien.com/roller/abien/entry/simplest_possible_pojo_injection_example)). Он мог бы просто удалить «новый Employee()», и контейнер должен его обработать. – DavidS