10
respostas

Erro ao inciar projeto.

Ao fazer as alterações conforme a video aula, ao iniciar Jboss apresenta um erro.

14:23:20,156 INFORMAÇÕES [org.jboss.modules] JBoss Modules version 1.1.1.GA
14:23:20,423 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
14:23:20,489 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
14:23:21,507 INFO  [org.xnio] XNIO Version 3.0.3.GA
14:23:21,507 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
14:23:21,519 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
14:23:21,528 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
14:23:21,571 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
14:23:21,576 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
14:23:21,598 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
14:23:21,646 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
14:23:21,665 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
14:23:21,670 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.7.Final
14:23:21,719 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
14:23:21,745 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:23:21,759 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
14:23:21,768 INFO  [org.jboss.as.connector] (MSC service thread 1-4) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
14:23:21,795 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
14:23:21,814 INFO  [org.jboss.as.naming] (MSC service thread 1-3) JBAS011802: Starting Naming Service
14:23:21,817 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:23:21,951 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.2.GA
14:23:22,339 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-2) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080
14:23:22,636 INFO  [org.jboss.as.remoting] (MSC service thread 1-5) JBAS017100: Listening on localhost/127.0.0.1:9999
14:23:22,636 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on localhost/127.0.0.1:4447
14:23:22,640 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) JBAS015012: Started FileSystemDeploymentService for directory C:\Users\dayso\Documents\servidores\jboss-as-7.1.1.Final\standalone\deployments
14:23:22,691 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment livraria.war
14:23:22,702 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found livraria.war in deployment directory. To trigger deployment create a file called livraria.war.dodeploy
14:23:22,931 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
14:23:22,939 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:/livrariads]
14:23:22,971 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990
14:23:22,972 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 3246ms - Started 138 of 214 services (74 services are passive or on-demand)
14:23:22,980 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "livraria.war"
14:23:23,199 ERROR [org.jboss.remoting.remote.connection] (Remoting "desktop-4mgln1q:MANAGEMENT" read-1) JBREM000200: Remote connection failed: java.io.IOException: Uma conexão estabelecida foi anulada pelo software no computador host
14:23:23,329 ERROR [org.jboss.remoting.remote.connection] (Remoting "desktop-4mgln1q:MANAGEMENT" read-1) JBREM000200: Remote connection failed: java.io.IOException: Uma conexão estabelecida foi anulada pelo software no computador host
14:23:24,336 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for livrariads
14:23:24,435 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016002: Processing weld deployment livraria.war
14:23:24,637 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016005: Starting Services for CDI deployment: livraria.war
14:23:24,667 INFO  [org.jboss.weld.Version] (MSC service thread 1-4) WELD-000900 1.1.5 (AS71)
14:23:25,272 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "livraria.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"livraria.war#livrariads\"jboss.naming.context.java.??Missing[jboss.persistenceunit.\"livraria.war#livrariads\"jboss.naming.context.java.??]"]}
14:23:25,325 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment livraria.war in 52ms
14:23:25,329 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.?? (missing) dependents: [service jboss.persistenceunit."livraria.war#livrariads"] 

14:23:25,335 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.\"livraria.war#livrariads\"jboss.naming.context.java.??Missing[jboss.persistenceunit.\"livraria.war#livrariads\"jboss.naming.context.java.??]"]}}}
10 respostas

Opa Dayson, o arquivo persistence.xml está na dentro da pasta src/META-INF ?

Olá, verifiquei e não tinha colocado o nome do datasource, ao colocar apresentou outro erro.

<jta-data-source>livrariads</jta-data-source>
9:54:48,608 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-7) HHH000021: Bytecode provider name : javassist
19:54:48,632 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-7) HHH000204: Processing PersistenceUnitInfo [
    name: livrariads
    ...]
19:54:48,658 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.persistenceunit."livraria.war#livrariads": org.jboss.msc.service.StartException in service jboss.persistenceunit."livraria.war#livrariads": Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: livrariads] class or package not found
    at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1400)
    at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1183)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1047)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:692)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    ... 3 more
Caused by: java.lang.ClassNotFoundException: br.com.caelum.livraria.modelo.Autor from [Module "org.hibernate:main" from local module loader @12feafc (roots: C:\Users\dayso\Documents\servidores\jboss-as-7.1.1.Final\modules)]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
    at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_79]
    at java.lang.Class.forName(Class.java:274) [rt.jar:1.7.0_79]
    at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:170)
    at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1317)
    at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1389)
    ... 11 more

19:54:48,682 INFO  [org.jboss.as] (MSC service thread 1-4) JBAS015951: Admin console listening on http://127.0.0.1:9990
19:54:48,683 ERROR [org.jboss.as] (MSC service thread 1-4) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 13883ms - Started 172 of 273 services (23 services failed or missing dependencies, 76 services are passive or on-demand)
19:54:48,893 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "livraria.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"livraria.war#livrariads\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"livraria.war#livrariads\": Failed to start service"}}
19:54:48,926 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment livraria.war in 35ms
19:54:48,927 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.persistenceunit."livraria.war#livrariads": org.jboss.msc.service.StartException in service jboss.persistenceunit."livraria.war#livrariads": Failed to start service

19:54:48,930 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"livraria.war#livrariads\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"livraria.war#livrariads\": Failed to start service"}}}}

Oi Dayson,

A exception indica que não existe a classe => br.com.caelum.livraria.modelo.Autor. O pacote é esse mesmo?

Sim. só importei o projeto da aula 1 e não consigo colocar ele para rodar.

Olá,

Só importou o projeto no Eclipse, né ?!

Configurou o datasource livrariads no Wildfly ? O nome do datasource no persistence.xml e na configuração do Wildfly devem ser iguais.

Olá, conforme a vídeo aula 3, adicionei as tags e dentro do standlone.xml do jboss AS. criei 2 pastas dentro no servidor Jboss : modules/com/mysql/main e coloquei 2 arquivos dentro desta pasta: module.xml e o jar do mysql.

Olá,

Como disse anteriormente, no standalone.xml, o nome do datasource é "java:/livrariads" mas no persistence.xml o nome do datasource é "livrariads" somente. Devem ser iguais.

Olá está assim meu persistence.xml

<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="livrariads">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <!-- acessando um DataSource que é livrariaDS -->
        <jta-data-source>java:/livrariaDS</jta-data-source> 

        <class>br.com.caelum.livraria.modelo.Autor</class>
        <class>br.com.caelum.livraria.modelo.Livro</class>
        <class>br.com.caelum.livraria.modelo.Usuario</class>

        <properties>

            <!-- Configuracoes especificas do Hibernate -->
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true" />

        </properties>
    </persistence-unit>
</persistence>

Olá,

O nome do datasource é case-sensitive, faz a distinção de maiúsculas e minúsculas. Assim no standalone.xml o nome do datasource deve ser: "java:/livrariaDS" também.

Opa, obrigado pela ajuda. está assim meu código. creio que está correto.

standlone.xml

<datasource jndi-name="java:/livrariaDS" pool-name="livrariaDS"
                    enabled="true" use-java-context="true">

                    <connection-url>jdbc:mysql://localhost:3306/livraria</connection-url>
                    <driver>com.mysql</driver>
                    <pool>
                        <min-pool-size>10</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                        <prefill>true</prefill>
                    </pool>
                    <security>
                        <user-name>root</user-name>
                        <password>root</password>
                    </security>
                </datasource>
<drivers>

                    <!-- Driver Mysql. -->
                    <driver name="com.mysql" module="com.mysql">
                    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>
</drivers>