Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jpa DeploymentException:WELD-001408[EntityManagerFactory]类型的未满足依赖项_Jpa_Jboss_Cdi - Fatal编程技术网

Jpa DeploymentException:WELD-001408[EntityManagerFactory]类型的未满足依赖项

Jpa DeploymentException:WELD-001408[EntityManagerFactory]类型的未满足依赖项,jpa,jboss,cdi,Jpa,Jboss,Cdi,我对JBOSS有个问题。我设计了一个名为Login.jsp的jsp页面。当我运行它时,它一开始工作正常。但当我添加会话bean和实体时,会出现如下错误: 21:28:53,762 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) HHH000389: Unsuccessful: drop table order if exists 21:28:53,763 ERROR [org.hi

我对JBOSS有个问题。我设计了一个名为Login.jsp的jsp页面。当我运行它时,它一开始工作正常。但当我添加会话bean和实体时,会出现如下错误:

21:28:53,762 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) HHH000389: Unsuccessful: drop table order if exists
21:28:53,763 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) Syntax error in SQL statement "DROP TABLE ORDER[*] IF EXISTS "; expected "identifier"; SQL statement:
drop table order if exists [42001-168]
21:28:53,763 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) HHH000389: Unsuccessful: drop sequence hibernate_sequence
21:28:53,763 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) Sequence "HIBERNATE_SEQUENCE" not found; SQL statement:
drop sequence hibernate_sequence [90036-168]
21:28:53,766 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) HHH000389: Unsuccessful: create table order (O_ID integer not null, B_ID integer, C_ID integer, QUANTITY integer not null, primary key (O_ID))
21:28:53,766 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) Syntax error in SQL statement "CREATE TABLE ORDER[*] (O_ID INTEGER NOT NULL, B_ID INTEGER, C_ID INTEGER, QUANTITY INTEGER NOT NULL, PRIMARY KEY (O_ID)) "; expected "identifier"; SQL statement:
create table order (O_ID integer not null, B_ID integer, C_ID integer, QUANTITY integer not null, primary key (O_ID)) [42001-168]
21:28:53,771 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 48) HHH000230: Schema export complete
21:28:54,471 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."jboss-as-greeter.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."jboss-as-greeter.war".WeldStartService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_22]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_22]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_22]
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [EntityManagerFactory] with qualifiers [@Default] at injection point [[field] @Inject protected org.jboss.as.quickstarts.greeter.domain.SessionBean.emf]
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:311)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:64)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
    ... 3 more

21:28:54,767 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "jboss-as-greeter.war" (runtime-name : "jboss-as-greeter.war")
21:28:54,774 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."jboss-as-greeter.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."jboss-as-greeter.war".WeldStartService: Failed to start service


21:28:54,854 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) started (with errors) in 47829ms - Started 184 of 262 services (21 services failed or missing dependencies, 56 services are passive or on-demand)
有人能帮我吗


这是我的会话bean代码:

package org.jboss.as.quickstarts.greeter.domain;
import java.util.HashMap;
import java.util.Map;
import javax.ejb.Stateful;
import javax.enterprise.inject.Alternative;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;

@Stateful
public class SessionBean implements DAO {

public SessionBean() {
}

@Inject

protected EntityManagerFactory emf;

String customerName;  
Integer bookID;
int quantity;
Map<Integer,Integer> shoppingCart = new HashMap<Integer,Integer>();  

public void initialize(String person) throws BookException {  
    if (person == null) {  
        throw new BookException  
        ("Null person not allowed.");  
    } else {  
        customerName = person;  
    }    
}  

public String addBook(int bookID, int quantity){
    shoppingCart.put(bookID, quantity);
    return "The item has been added to your cart succesfully";
}
public String removeBook(int bookID) throws BookException{

    int number = shoppingCart.get(bookID);
    if ( number == 0) {  
        throw new BookException  
        ("The item is not in the cart.");  
    } 
    shoppingCart.remove(bookID);
    return "Selected item has been removed from your cart succesfully";
}
public String updateBook(int bookID, int quantity){
    shoppingCart.put(bookID, quantity);
    return "The item in your cart has been updated succesfully";    
}
public String checkout(Map<Integer, Integer> content){
    Order order = new Order();

    return "You have successfully checked out";
}
public Map<Integer, Integer> getContents(){
    return shoppingCart;    
}
public Customer findByPrimaryKey(int customerID){

    EntityManager em = emf.createEntityManager(); 
    Customer customer = (Customer)em.find(Customer.class, customerID);
    em.close();

    return customer;

}
public BookStore findByName(String name){

    EntityManager em = emf.createEntityManager();
    BookStore book = (BookStore)em.find(BookStore.class, name);
    em.close();

    return book;

}
package org.jboss.as.quickstarts.greeter.domain;
导入java.util.HashMap;
导入java.util.Map;
导入javax.ejb.Stateful;
导入javax.enterprise.inject.Alternative;
导入javax.inject.inject;
导入javax.persistence.EntityManager;
导入javax.persistence.EntityManagerFactory;
导入javax.persistence.NoResultException;
导入javax.persistence.PersistenceUnit;
导入javax.persistence.Query;
@有状态
公共类SessionBean实现DAO{
公共会话bean(){
}
@注入
受保护的实体管理器工厂emf;
字符串客户名称;
整数bookID;
整数;
Map shoppingCart=新建HashMap();
public void initialize(字符串person)引发BookException{
如果(person==null){
抛出新的BookException
(“不允许为空人。”);
}否则{
客户名称=人;
}    
}  
公共字符串addBook(int bookID,int quantity){
shoppingCart.put(图书编号、数量);
return“物品已成功添加到购物车”;
}
公共字符串removeBook(int bookID)引发BookException{
int number=shoppingCart.get(bookID);
如果(数字==0){
抛出新的BookException
(“物品不在购物车中。”);
} 
shoppingCart.remove(bookID);
return“所选项目已成功从购物车中删除”;
}
公共字符串更新电子书(int bookID,int quantity){
shoppingCart.put(图书编号、数量);
return“您购物车中的物品已成功更新”;
}
公共字符串签出(映射内容){
订单=新订单();
返回“您已成功签出”;
}
公共地图getContents(){
返回购物车;
}
公共客户findByPrimaryKey(int customerID){
EntityManager em=emf.createEntityManager();
Customer=(Customer)em.find(Customer.class,customerID);
em.close();
退货客户;
}
公共书店findByName(字符串名称){
EntityManager em=emf.createEntityManager();
bookstorebook=(BookStore)em.find(BookStore.class,name);
em.close();
还书;
}
}

这是我的persistence.xml。我忘了什么吗

<?xml version="1.0" encoding="UTF-8"?>
<!-- JBoss, Home of Professional Open Source Copyright 2012, Red Hat, Inc. 
and/or its affiliates, and individual contributors by the @authors tag. See 
the copyright.txt in the distribution for a full listing of individual contributors. 
Licensed under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance with the License. You may obtain a copy 
of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
by applicable law or agreed to in writing, software distributed under the 
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
OF ANY KIND, either express or implied. See the License for the specific 
language governing permissions and limitations under the License. -->
<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="primary">
    <!-- If you are running in a production environment, add a managed 
        data source, this example data source is just for development and testing! -->
    <!-- The datasource is deployed as WEB-INF/greeter-quickstart-ds.xml, 
        you can find it in the source at src/main/webapp/WEB-INF/greeter-quickstart-ds.xml -->
    <jta-data-source>java:jboss/datasources/GreeterQuickstartDS</jta-data-source>
    <properties>
        <!-- Properties for Hibernate -->
        <property name="hibernate.hbm2ddl.auto" value="create-drop" />
        <property name="hibernate.show_sql" value="false" />
    </properties>
</persistence-unit>
</persistence>