Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Application error - DEPLOY

Minha aplicação está com dando erro após o deploy.

https://carlosreisspringmvc.herokuapp.com/

https://github.com/CarlosEReis/SpringMVCII

carlos@carlos-S400CA:~/workspace/casadocodigo$ heroku logs
2016-12-28T20:34:37.134956+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1947)
2016-12-28T20:34:37.134957+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1913)
2016-12-28T20:34:37.134958+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1898)
2016-12-28T20:34:37.134975+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1330)
2016-12-28T20:34:37.134976+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
2016-12-28T20:34:37.134977+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
2016-12-28T20:34:37.134978+00:00 app[web.1]:     at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
2016-12-28T20:34:37.134978+00:00 app[web.1]:     at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
2016-12-28T20:34:37.134979+00:00 app[web.1]:     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5380)
2016-12-28T20:34:37.134980+00:00 app[web.1]:     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
2016-12-28T20:34:37.134981+00:00 app[web.1]:     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
2016-12-28T20:34:37.134981+00:00 app[web.1]:     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
2016-12-28T20:34:37.134983+00:00 app[web.1]:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2016-12-28T20:34:37.134984+00:00 app[web.1]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
2016-12-28T20:34:37.134984+00:00 app[web.1]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
2016-12-28T20:34:37.134986+00:00 app[web.1]:     at java.lang.Thread.run(Thread.java:745)
2016-12-28T20:34:37.288709+00:00 app[web.1]: Dec 28, 2016 8:34:37 PM org.apache.catalina.startup.ContextConfig processAnnotationsJar
2016-12-28T20:34:37.134987+00:00 app[web.1]: 
2016-12-28T20:34:37.288714+00:00 app[web.1]: SEVERE: Unable to process Jar entry [org/hibernate/internal/jaxb/mapping/orm/JaxbJoinTable.class] from Jar [jar:jndi:/localhost/WEB-INF/lib/hibernate-core-4.3.0.Final.jar!/] for annotations
2016-12-28T20:34:37.288715+00:00 app[web.1]: java.io.EOFException
2016-12-28T20:34:37.288716+00:00 app[web.1]:     at org.apache.tomcat.util.bcel.classfile.FastDataInputStream.readInt(FastDataInputStream.java:145)
2016-12-28T20:34:37.288716+00:00 app[web.1]:     at org.apache.tomcat.util.bcel.classfile.ClassParser.readID(ClassParser.java:200)
2016-12-28T20:34:37.288717+00:00 app[web.1]:     at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:78)
2016-12-28T20:34:37.288717+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2071)
2016-12-28T20:34:37.288718+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1947)
2016-12-28T20:34:37.288719+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1913)
2016-12-28T20:34:37.288719+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1898)
2016-12-28T20:34:37.288720+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1330)
2016-12-28T20:34:37.288720+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
2016-12-28T20:34:37.288721+00:00 app[web.1]:     at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
2016-12-28T20:34:37.288722+00:00 app[web.1]:     at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
2016-12-28T20:34:37.288722+00:00 app[web.1]:     at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
2016-12-28T20:34:37.288723+00:00 app[web.1]:     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5380)
2016-12-28T20:34:37.288724+00:00 app[web.1]:     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
2016-12-28T20:34:37.288724+00:00 app[web.1]:     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
2016-12-28T20:34:37.288725+00:00 app[web.1]:     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
2016-12-28T20:34:37.288726+00:00 app[web.1]:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2016-12-28T20:34:37.288726+00:00 app[web.1]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
2016-12-28T20:34:37.288727+00:00 app[web.1]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
2016-12-28T20:34:37.288728+00:00 app[web.1]:     at java.lang.Thread.run(Thread.java:745)
2016-12-28T20:34:37.288729+00:00 app[web.1]: 
2016-12-28T20:34:41.935718+00:00 app[web.1]: Dec 28, 2016 8:34:41 PM org.apache.catalina.core.ApplicationContext log
2016-12-28T20:34:42.053995+00:00 app[web.1]: log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
2016-12-28T20:34:42.054040+00:00 app[web.1]: log4j:WARN Please initialize the log4j system properly.
2016-12-28T20:34:41.935729+00:00 app[web.1]: INFO: Spring WebApplicationInitializers detected on classpath: [br.com.casadocodigo.loja.configurantion.SpringSecurityFilterConfiguration@6b021e3f, br.com.casadocodigo.loja.configurantion.ServletSpringMVC@1f6ffbb1]
2016-12-28T20:34:42.054106+00:00 app[web.1]: log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2016-12-28T20:34:42.131888+00:00 app[web.1]: Dec 28, 2016 8:34:42 PM org.apache.catalina.core.ApplicationContext log
2016-12-28T20:34:42.131891+00:00 app[web.1]: INFO: Initializing Spring root WebApplicationContext
2016-12-28T20:34:43.527861+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.catalina.core.StandardContext listenerStart
2016-12-28T20:34:43.527876+00:00 app[web.1]: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
2016-12-28T20:34:43.527881+00:00 app[web.1]: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBean' defined in class br.com.casadocodigo.loja.configurantion.JPAConfiguration: Unsatisfied dependency expressed through constructor argument with index 1 of type [java.util.Properties]: : No qualifying bean of type [java.util.Properties] is defined: expected single matching bean but found 2: aditionalProperties,systemProperties; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [java.util.Properties] is defined: expected single matching bean but found 2: aditionalProperties,systemProperties
2016-12-28T20:34:43.527883+00:00 app[web.1]:     at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:751)
2016-12-28T20:34:43.527883+00:00 app[web.1]:     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:466)
2016-12-28T20:34:43.527885+00:00 app[web.1]:     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1113)
2016-12-28T20:34:43.527885+00:00 app[web.1]:     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1008)
2016-12-28T20:34:43.527886+00:00 app[web.1]:     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:505)
2016-12-28T20:34:43.527887+00:00 app[web.1]:     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
2016-12-28T20:34:43.527888+00:00 app[web.1]:     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
2016-12-28T20:34:43.527888+00:00 app[web.1]:     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
2016-12-28T20:34:43.527889+00:00 app[web.1]:     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
2016-12-28T20:34:43.527890+00:00 app[web.1]:     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
2016-12-28T20:34:43.527891+00:00 app[web.1]:     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
2016-12-28T20:34:43.527892+00:00 app[web.1]:     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
2016-12-28T20:34:43.527891+00:00 app[web.1]:     at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
2016-12-28T20:34:43.527893+00:00 app[web.1]:     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
2016-12-28T20:34:43.527893+00:00 app[web.1]:     at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
2016-12-28T20:34:43.527894+00:00 app[web.1]:     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
2016-12-28T20:34:43.527896+00:00 app[web.1]:     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
2016-12-28T20:34:43.527896+00:00 app[web.1]:     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
2016-12-28T20:34:43.527898+00:00 app[web.1]:     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
2016-12-28T20:34:43.527899+00:00 app[web.1]:     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
2016-12-28T20:34:43.527897+00:00 app[web.1]:     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
2016-12-28T20:34:43.527901+00:00 app[web.1]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
2016-12-28T20:34:43.527900+00:00 app[web.1]:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2016-12-28T20:34:43.527902+00:00 app[web.1]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
2016-12-28T20:34:43.527903+00:00 app[web.1]:     at java.lang.Thread.run(Thread.java:745)
2016-12-28T20:34:43.527905+00:00 app[web.1]: Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [java.util.Properties] is defined: expected single matching bean but found 2: aditionalProperties,systemProperties
2016-12-28T20:34:43.527906+00:00 app[web.1]:     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1016)
2016-12-28T20:34:43.527907+00:00 app[web.1]:     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:904)
2016-12-28T20:34:43.527912+00:00 app[web.1]:     at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:815)
2016-12-28T20:34:43.527913+00:00 app[web.1]:     at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:743)
2016-12-28T20:34:43.527914+00:00 app[web.1]:     ... 24 more
2016-12-28T20:34:43.527915+00:00 app[web.1]: 
2016-12-28T20:34:43.528461+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.catalina.core.StandardContext startInternal
2016-12-28T20:34:43.528463+00:00 app[web.1]: SEVERE: Error listenerStart
2016-12-28T20:34:43.577093+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.catalina.core.StandardContext startInternal
2016-12-28T20:34:43.577097+00:00 app[web.1]: SEVERE: Context [] startup failed due to previous errors
2016-12-28T20:34:43.578856+00:00 app[web.1]: SEVERE: Context [] failed in [org.apache.catalina.core.StandardContext] lifecycle. Allowing Tomcat to shutdown.
2016-12-28T20:34:43.581777+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.catalina.core.ApplicationContext log
2016-12-28T20:34:43.581779+00:00 app[web.1]: INFO: Closing Spring root WebApplicationContext
2016-12-28T20:34:43.593828+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
2016-12-28T20:34:43.593831+00:00 app[web.1]: SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2016-12-28T20:34:43.594341+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
2016-12-28T20:34:43.605571+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.coyote.AbstractProtocol start
2016-12-28T20:34:43.594343+00:00 app[web.1]: SEVERE: The web application [] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2016-12-28T20:34:43.605573+00:00 app[web.1]: INFO: Starting ProtocolHandler ["http-nio-46945"]
2016-12-28T20:34:43.637654+00:00 app[web.1]: Dec 28, 2016 8:34:43 PM org.apache.coyote.AbstractProtocol pause
2016-12-28T20:34:43.637657+00:00 app[web.1]: INFO: Pausing ProtocolHandler ["http-nio-46945"]
2016-12-28T20:34:44.249418+00:00 heroku[web.1]: State changed from up to crashed
2016-12-28T20:34:44.278397+00:00 heroku[web.1]: Process exited with status 0
2016-12-28T20:35:38.134887+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=carlosreisspringmvc.herokuapp.com request_id=84ef991f-2a19-459a-877b-7c6de46f53e7 fwd="187.108.225.198" dyno= connect= service= status=503 bytes=
3 respostas

Ele ta dizendo que vc tem dois métodos que produzem um properties => aditionalProperties,systemProperties E aí ele não sabe qual injetar no método que cria o entityManagerFactory.

solução!

systemProperties estranho, não lembro de ter criado este método, apenas 2 aditionalProperties

1 @Profile("dev")

1@Profile("Prod")

De onde pode ser esse systemProperties?

package br.com.casadocodigo.loja.configurantion;

import java.util.Properties;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableTransactionManagement
public class JPAConfiguration {

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(DataSource dataSource,
            Properties additionalProperties) {
        LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
        JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();

        factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
        factoryBean.setDataSource(dataSource);

        factoryBean.setJpaProperties(additionalProperties);
        factoryBean.setPackagesToScan("br.com.casadocodigo.loja.model");

        return factoryBean;

    }

    @Bean
    @Profile("dev")
    public Properties additionalProperties() {
        Properties jpaProperties = new Properties();
        jpaProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
        jpaProperties.setProperty("hibernate.show_sql", "true");
        jpaProperties.setProperty("hibernate.hbm2ddl.auto", "update");
        return jpaProperties;
    }

    @Bean
    @Profile("dev")
    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setUsername("root");
        dataSource.setPassword("");
        dataSource.setUrl("jdbc:mysql://localhost:3306/casadocodigo");
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        return dataSource;
    }

    @Bean
    public JpaTransactionManager jpaTransactionManager(EntityManagerFactory emf) {
        return new JpaTransactionManager(emf);
    }

}
package br.com.casadocodigo.loja.configurantion;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Properties;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

@Profile("prod")
public class JPAProductionConfiguration {

    @Autowired
    private Environment enviroment;

    @Bean
    public Properties aditionalProperties() {
        Properties jpaProperties = new Properties();
        jpaProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
        jpaProperties.setProperty("hibernate.show_sql", "true");
        jpaProperties.setProperty("hibernate.hbm2ddl.auto", "update");
        return jpaProperties;
    }

    @Bean
    public DataSource dataSource() throws URISyntaxException {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();

        dataSource.setDriverClassName("org.postgresql.Driver");
        URI dbUrl = new URI(enviroment.getProperty("DATABASE_URL"));

        dataSource.setUrl("jdbc:postgresql://" + dbUrl.getHost() + ":" + dbUrl.getPort() + dbUrl.getPath());
        dataSource.setUsername(dbUrl.getUserInfo().split(":")[0]);
        dataSource.setPassword(dbUrl.getUserInfo().split(":")[1]);
        return dataSource;
    }

}

Estava com o mesmo problema. O erro estava acontecendo, mas depois de um tempo a aplicação acabou subindo. Espere uns 2 minutos e teste se aplicação está no ar.