部署到Elastic beanstalk的Jboss单个容器无法连接到远程数据库

问题描述 投票:0回答:1

我制作了一个docker映像,下载了我的自定义Jboss和jre 7并执行jsf应用程序。该应用程序连接到远程Postgresql数据库。运行容器时在本地我可以正常访问该应用程序。在Elastic BeanStalk中上传单个容器后,该应用程序不再连接到数据库。由于超时,我收到错误404。如何配置Elastic Beanstalk以允许该数据库连接?

日志:

21:50:30,396 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapp]] (MSC service thread 1-1) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Error looking up myapp-ds, service service jboss.naming.context.java.myapp-ds is not started

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Error looking up myapp-ds, service service jboss.naming.context.java.myapp-ds is not started
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        ... 23 more
    Caused by: javax.naming.NameNotFoundException: Error looking up myapp-ds, service service jboss.naming.context.java.myapp-ds is not started
        at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:126)
        at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:74)
        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
        at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:113)
        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)
        at javax.naming.InitialContext.lookup(Unknown Source) [rt.jar:1.7.0]
        at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        ... 30 more
postgresql amazon-web-services docker jboss amazon-elastic-beanstalk
1个回答
0
投票

在远程数据库正在侦听的任何端口上,在EB实例上启用TCP通信。 AWS默认情况下是安全的,因此默认情况下会阻止所有互联网流量。

© www.soinside.com 2019 - 2024. All rights reserved.