2

Test、TestEJB、TestWebの3つのプロジェクトでEclipseを使用してエンタープライズアプリケーションプロジェクトを作成し、TestEJBでPerson.java、IPerson.java、PersonBean.javaを作成しました。

IPerson.java

package com.aminpy.test;

import javax.ejb.Local;

@Local
public interface IPerson {
    void createPerson(Person person);
}

Person.java

package com.aminpy.test;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class Person implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String firstName;
    private String lastName;

    public Long getId() {
        return id;
    }

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

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @Override
    public String toString() {
        return firstName + " " + lastName;
    }
}

PersonBeen.javaパッケージcom.aminpy.test;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class PersonBean implements IPerson {
    @PersistenceContext(unitName = "manager1")
    private EntityManager em;

    public PersonBean() {
    }

    @Override
    public void createPerson(Person person) {
        em.persist(person);
    }
}

TestWeb/srcにあるmanageを作成しました

PersonPage.java

package com.aminpy.test;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class PersonPage {
    private Person person;
    @EJB
    IPerson personBeen;

    public Person getPerson() {
        if (person == null) {
            person = new Person();
        }
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public String btnCreate() {
        personBeen.createPerson(person);
        return null;
    }
}

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
    version="2.0">

    <persistence-unit name="manager1">
        <jta-data-source>java:/PostgresSD</jta-data-source>
        <properties>
            <property name="eclipselink.jdbc.driver" value="org.postgresql.Driver" />
            <property name="eclipselink.jdbc.url" value="jdbc:postgresql://localhost:5432/person_db" />
            <property name="eclipselink.jdbc.user" value="aminpy" />
            <property name="eclipselink.jdbc.password" value="postgres" />
            <property name="eclipselink.ddl-generation" value="create-tables" />
            <property name="eclipselink.ddl-generation.output-mode"
                value="database" />
        </properties>
    </persistence-unit>

</persistence>

プロジェクト構造

/Test
    META-INF
    META-INF/application.xml
    META-INF/MANIFEST.MF
/TestEJB
    src
        com.aminpy.test
            IPerson.java
            Person.java
            PersonBean.java
        META-INF
            MANIFEST.MF
            persistence.xml
/TestWeb
    src
        com.aminpy.test
            PersonPage.java
    WebRoot
        META-INF
            MANIFEST.MF
        WEB-INF
            lib
            faces-config.xml
            web.xml
        index.xhtml

プロジェクトを実行すると、この問題が発生します

WARNING: -logmodule is deprecated. Please use the system property 'java.util.logging.manager' or the 'java.util.logging.LogManager' service loader.
15:02:17,988 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
15:02:18,110 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
15:02:18,145 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
15:02:18,686 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
15:02:18,686 INFO  [org.xnio] XNIO Version 3.0.3.GA
15:02:18,696 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
15:02:18,704 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
15:02:18,710 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
15:02:18,712 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
15:02:18,715 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
15:02:18,729 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
15:02:18,729 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
15:02:18,732 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
15:02:18,751 INFO  [org.jboss.as.security] (MSC service thread 1-10) JBAS013100: Current PicketBox version=4.0.7.Final
15:02:18,764 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
15:02:18,771 INFO  [org.jboss.as.connector] (MSC service thread 1-8) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
15:02:18,773 INFO  [org.jboss.as.naming] (MSC service thread 1-4) JBAS011802: Starting Naming Service
15:02:18,779 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-12) JBAS015400: Bound mail session [java:jboss/mail/Default]
15:02:18,813 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
15:02:18,883 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.2.GA
15:02:18,891 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-7) Starting Coyote HTTP/1.1 on http--0_0_0_0_0_0_0_0-8080
15:02:19,077 WARN  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015005: Reliable deployment behaviour is not possible when auto-deployment of exploded content is enabled (i.e. deployment without use of ".dodeploy"' marker files). Configuration of auto-deployment of exploded content is not recommended in any situation where reliability is desired. Configuring the deployment scanner's auto-deploy-exploded setting to "false" is recommended.
15:02:19,079 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory /home/aminpy/Workspaces/jboss-as-7.1.1.Final/standalone/deployments
15:02:19,081 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:9999
15:02:19,081 INFO  [org.jboss.as.remoting] (MSC service thread 1-11) JBAS017100: Listening on /0:0:0:0:0:0:0:0:4447
15:02:19,092 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
15:02:19,343 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
        service jboss.jdbc-driver.postgresql-9_1-902_jdbc4_jar (missing) dependents: [service jboss.data-source.java:/PostgresDS] 

15:02:19,356 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-14) JBAS015876: Starting deployment of "postgresql-9.1-902.jdbc4.jar"
15:02:19,356 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "Test.ear"
15:02:19,396 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "TestWeb.war"
15:02:19,397 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-13) JBAS015876: Starting deployment of "TestEJB.jar"
15:02:19,431 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011401: Read persistence.xml for manager1
15:02:19,469 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-12) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.1)
15:02:19,482 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-13) JBAS010400: Bound data source [java:/PostgresDS]
15:02:19,491 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named PersonBean in deployment unit subdeployment "TestEJB.jar" of deployment "Test.ear" are as follows:

    java:global/Test/TestEJB/PersonBean!com.aminpy.test.IPerson
    java:app/TestEJB/PersonBean!com.aminpy.test.IPerson
    java:module/PersonBean!com.aminpy.test.IPerson
    java:global/Test/TestEJB/PersonBean
    java:app/TestEJB/PersonBean
    java:module/PersonBean

15:02:19,601 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-6) Initializing Mojarra 2.1.7-jbossorg-1 (20120227-1401) for context '/TestWeb'
15:02:20,077 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-6) Hibernate Validator 4.2.0.Final
15:02:20,172 INFO  [org.jboss.web] (MSC service thread 1-6) JBAS018210: Registering web context: /TestWeb
15:02:20,173 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990
15:02:20,174 ERROR [org.jboss.as] (MSC service thread 1-2) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 2339ms - Started 248 of 336 services (4 services failed or missing dependencies, 82 services are passive or on-demand)
15:02:20,374 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015871: Deploy of deployment "postgresql-9.1-902.jdbc4.jar" was rolled back with no failure message
15:02:20,376 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "Test.ear" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"Test.ear/TestEJB.jar#manager1\"jboss.naming.context.java.PostgresSDMissing[jboss.persistenceunit.\"Test.ear/TestEJB.jar#manager1\"jboss.naming.context.java.PostgresSD]"]}
15:02:20,399 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-9) JBAS015877: Stopped deployment postgresql-9.1-902.jdbc4.jar in 23ms
15:02:20,402 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-15) JBAS015877: Stopped deployment TestEJB.jar in 26ms
15:02:20,402 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-13) JBAS015877: Stopped deployment TestWeb.war in 26ms
15:02:20,403 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-13) JBAS015877: Stopped deployment Test.ear in 27ms
15:02:20,404 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
        service jboss.naming.context.java.PostgresSD (missing) dependents: [service jboss.persistenceunit."Test.ear/TestEJB.jar#manager1"] 
JBAS014776:    Newly corrected services:
        service jboss.jdbc-driver.postgresql-9_1-902_jdbc4_jar (no longer required)

15:02:20,405 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"Test.ear/TestEJB.jar#manager1\"jboss.naming.context.java.PostgresSDMissing[jboss.persistenceunit.\"Test.ear/TestEJB.jar#manager1\"jboss.naming.context.java.PostgresSD]"]}}}
15:02:20,407 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS014654: Composite operation was rolled back

事前に感謝し、私の貧弱な言語スキルを失礼します:)

4

2 に答える 2

1

私の問題はPostgreSQLデータソースの名前でした。PostgresDSJNDI名でデータソースを作成しましたが、PostgresSDをpersistence.xmlに入れました。PostgresDS!= PostgresSD:D

于 2012-08-13T12:17:36.420 に答える
0

これは、jarが欠落しているというエラーを明示的に示しています。

service jboss.jdbc-driver.postgresql-9_1-902_jdbc4_jar (missing) dependents: [service jboss.data-source.java:/PostgresDS] 

このjdbc-connectorjarをlibフォルダーに含めます。

于 2012-08-13T11:26:37.483 に答える