Openshift应用程序和ejb"失败的部署./ROOT.war

时间:2015-02-24 19:00:37

标签: jpa jboss ejb openshift

我在openshift上开发了第一个应用程序。它是一个具有数据库连接性的jsf应用程序。 首先,我尝试了一些jsf xhtml页面,没有jpa,所有的工作。 当我插入一个bean来访问数据库时,我收到来自服务器的消息"部署失败./ROOT.waer。准确地说,当我插入此代码时出现问题:

视图意图的类

 @ManagedBean(name="utnavctrl" ,eager=true)
@SessionScoped
public class Utnavctrl {
    boolean newrecord=false;
    @EJB
    private Usersdao usersdao;
public Utnavctrl(){

数据库连接的bean类

    @Stateless
@LocalBean
public class Usersdao {
    @PersistenceContext(unitName = "primary")
    private EntityManager em;

    public Usersdao() {
        // TODO Auto-generated constructor stub
    }
    public List<User> getAllUsers() {
                return em.createNamedQuery("User.findAll", User.class)
                    .getResultList();
            }

我无法理解为什么在添加这两个类之后(不修改视图方面xhtml ecc)程序不再起作用了。

persince.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="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/kitchensink-quickstart-ds.xml, you
         can find it in the source at src/main/webapp/WEB-INF/kitchensink-quickstart-ds.xml -->
      <jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>
      <class>com.antoiovi.gestcars.model.Automobili</class>
      <class>com.antoiovi.gestcars.model.Group</class>
      <class>com.antoiovi.gestcars.model.Prenotazioniauto</class>
      <class>com.antoiovi.gestcars.model.Proglav</class>
      <class>com.antoiovi.gestcars.model.Role</class>
      <class>com.antoiovi.gestcars.model.User</class>
      <class>com.antoiovi.gestcars.model.UserData</class>

      <properties>
         <!-- Properties for Hibernate -->
         <property name="hibernate.hbm2ddl.auto" value="create-drop" />
         <property name="hibernate.show_sql" value="false" />
      </properties>
   </persistence-unit>
</persistence>

bean.xml是

    <?xml version="1.0" encoding="UTF-8"?>
<!-- This file can be an empty text file (0 bytes) -->
<!-- We're declaring the schema to save you time if you do have to configure 
   this in the future -->
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</bean

有人能帮助我吗?

1 个答案:

答案 0 :(得分:0)

删除eager = true,因为这会给OpenShift带来问题......我不知道为什么,但我已经看到了。