FAIL - 无法启动上下文路径/ mycompany中的应用程序

时间:2014-11-14 10:21:03

标签: java eclipse spring-mvc tomcat jdbc

我将admin.war文件部署到tomcat管理器后出现此错误。我也无法从管理器启动该站点。 现在我在尝试启动catalina时看到了这个错误

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blMergedDataSources' defined in resource loaded from byte array: Cannot resolve reference to bean 'webDS' while setting bean property 'sourceMap' with key [TypedStringValue: value [jdbc/web], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webDS': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:384)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:165)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:445)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:419)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:547)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:155)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:304)
    ... 47 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webDS': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ... 64 more
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
    at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
    ... 71 more
Nov 14, 2014 3:13:10 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Nov 14, 2014 3:13:10 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/mycompany] startup failed due to previous errors

这是我的web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID">

<display-name>mycompany</display-name>

<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>site.root</param-value>
</context-param>

<context-param>
    <param-name>patchConfigLocation</param-name>
    <param-value>
        classpath:/bl-open-admin-contentClient-applicationContext.xml
        classpath:/bl-cms-contentClient-applicationContext.xml
        classpath:/applicationContext.xml
        classpath:/applicationContext-email.xml
        /WEB-INF/applicationContext-datasource.xml
        /WEB-INF/applicationContext-email.xml
        /WEB-INF/applicationContext-security.xml
        /WEB-INF/applicationContext-filter.xml
        /WEB-INF/applicationContext-workflow.xml
        /WEB-INF/applicationContext.xml
    </param-value>
</context-param>

<context-param>
    <param-name>shutdownHookMethod</param-name>
    <param-value>forceFlush</param-value>
</context-param>

<listener>
    <listener-class>
         org.springframework.web.context.request.RequestContextListener
    </listener-class>
</listener>

<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- enable configured logging -->
<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
    <listener-class>org.broadleafcommerce.common.web.extensibility.MergeContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>

<!-- Note: The applicationContext-servlet-cms-contentClient.xml file is used to load static assets
     from the Broadleaf CMS such as images. It will match on any URL that contains the static asset
     prefix URL in any depth of it. -->
<servlet>
    <servlet-name>mycompany</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:/applicationContext-servlet-cms-contentClient.xml
            /WEB-INF/applicationContext-servlet.xml
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>mycompany</servlet-name>
    <url-pattern>/mycompany</url-pattern>
</servlet-mapping>

<!-- The RESTApiServlet can be disabled, but doesn't have to be. It will throw an exception if 
     it is accessed when no endpoints have been registered via Spring. Add /WEB-INF/applicationContext-rest-api.xml 
     to the merge patchConfigLocation ABOVE applicationContext-security.xml to activate and begin using REST services. 
     Alternately, this servlet and servlet mapping can be commented out entirely. -->
<servlet>
    <servlet-name>RESTApiServlet</servlet-name>
    <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>org.codehaus.jackson.jaxrs</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>RESTApiServlet</servlet-name>
    <url-pattern>/api/v1/*</url-pattern>
</servlet-mapping>

<env-entry>
    <env-entry-name>mycompany</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>mycompanySite</env-entry-value>
</env-entry>

和context.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:task="http://www.springframework.org/schema/task"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/task
    http://www.springframework.org/schema/task/spring-task-3.2.xsd">

<task:annotation-driven />

<bean id="blConfiguration" class="org.broadleafcommerce.common.config.RuntimeEnvironmentPropertiesConfigurer" />

<!-- Set up Broadleaf messaging -->
<bean id="messageSource" class="org.broadleafcommerce.common.util.BroadleafMergeResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>classpath:messages</value>
        </list>
    </property>
</bean>

<!-- Set up custom entity overrides. These are defined in core/src/main/resources -->
<bean id="blMergedEntityContexts" class="org.springframework.beans.factory.config.ListFactoryBean">
    <property name="sourceList">
        <list>
            <value>classpath:applicationContext-entity.xml</value>
        </list>
    </property>
</bean>

<!-- Delete this bean to enable caching - leaving it on for development is recommended -->
<!-- as it will allow changes made in the admin or directly on the database to be reflected -->
<!-- immediately. However, caching is obviously beneficial in production. -->
<bean id="blMergedCacheConfigLocations" class="org.springframework.beans.factory.config.ListFactoryBean">
    <property name="sourceList">
        <list>
            <value>classpath:bl-override-ehcache.xml</value>
        </list>
    </property>
</bean>

<!-- Delete this section to disable the embedded solr search service. Although this will result in a smaller -->
<!-- application footprint, it will default the search service to use the database implementation, which  -->
<!-- is slower and less full-featured. Broadleaf suggests maintaining this solr implementation in the vast -->
<!-- majority of cases. -->
<bean id="solrEmbedded" class="java.lang.String">
    <constructor-arg value="solrhome"/>
</bean>

<!--A simple quartz jobs for enabling cart and customer purge functionality. Uncomment the following quartz configurations-->
<!--to activate this functionality (Also, uncomment the 'purgeCartTrigger' and 'purgeCustomerTrigger' configured under SchedulerFactoryBean.-->
<!--Note, you can edit the configuration to customize the functionality. Take a look-->
<!--at PurgeCartVariableNames and PurgeCustomerVariableNames for a list of available params and ResourcePurgeService for additional information. Also,-->
<!--for custom resource retrieval beyond the scope of the existing implementation, ResourcePurgeServiceImpl can be subclassed-->
<!--to provide custom resource retrieval functionality. Please see Quartz documentation for more advanced configuration,-->
<!--such as clustering.-->

<!--<bean id="purgeCartConfig" class="org.springframework.beans.factory.config.MapFactoryBean">-->
    <!--<property name="sourceMap">-->
        <!--<map>-->
            <!--<entry key="SECONDS_OLD" value="2592000"/>-->
            <!--<entry key="STATUS" value="IN_PROCESS"/>-->
        <!--</map>-->
    <!--</property>-->
<!--</bean>-->

<!--<bean id="purgeCartJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">-->
    <!--<property name="targetObject" ref="blResourcePurgeService" />-->
    <!--<property name="targetMethod" value="purgeCarts" />-->
    <!--<property name="arguments">-->
        <!--<list>-->
            <!--<ref bean="purgeCartConfig"/>-->
        <!--</list>-->
    <!--</property>-->
<!--</bean>-->

<!--<bean id="purgeCartTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">-->
    <!--<property name="jobDetail" ref="purgeCartJobDetail" />-->
    <!--<property name="startDelay" value="30000" />-->
    <!--<property name="repeatInterval" value="86400000" />-->
<!--</bean>-->

<!--<bean id="purgeCustomerConfig" class="org.springframework.beans.factory.config.MapFactoryBean">-->
    <!--<property name="sourceMap">-->
        <!--<map>-->
            <!--<entry key="SECONDS_OLD" value="2592000"/>-->
            <!--<entry key="IS_REGISTERED" value="false"/>-->
        <!--</map>-->
    <!--</property>-->
<!--</bean>-->

<!--<bean id="purgeCustomerJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">-->
    <!--<property name="targetObject" ref="blResourcePurgeService" />-->
    <!--<property name="targetMethod" value="purgeCustomers" />-->
    <!--<property name="arguments">-->
        <!--<list>-->
            <!--<ref bean="purgeCustomerConfig"/>-->
        <!--</list>-->
    <!--</property>-->
<!--</bean>-->

<!--<bean id="purgeCustomerTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">-->
    <!--<property name="jobDetail" ref="purgeCustomerJobDetail" />-->
    <!--<property name="startDelay" value="30000" />-->
    <!--<property name="repeatInterval" value="86400000" />-->
<!--</bean>-->

<!-- If you want to use a standalone solr server for at least one environment, uncomment the following -->
<!-- three beans and set solr.source.primary, solr.source.reindex, and solr.source.admin in the property file -->
<!-- to be solrServer, solrReindexServer, and solrAdminServer, respectively: -->
<!-- solr.souce.primary=solrServer-->
<!-- solr.souce.reindex=solrReindexServer-->
<!-- solr.souce.admin=solrAdminServer-->
<!-- Then, ensure that the three beans that you just uncommented, below, have their constructor arguments -->
<!-- pointing to the correct URLs of the stand alone server(s) -->
<!-- NOTE this assumes you are using Solr 4.4. -->
<!-- solr.url.admin should point to the ROOT of the server, for example: http://localhost:8983/solr. -->
<!-- solr.url.reindex should point to the reindex core, for example: http://localhost:8983/solr/reindex. -->
<!-- solr.url.primary should point to the primary core, for example, http://localhost:8983/solr/primary.  -->
<!-- In version 4.4 and higher of Solr, there is no need to configure the cores or defaultCoreName elements -->
<!-- in solr.xml, as Solr cores are auto discoverable as of 4.4 (see Solr documentation).-->
<!-- So, for Solr 4.4, in stand-alone mode, you should configure the following 3 HttpSolrServer configurations: -->
<!--     <bean id="solrServer" class="org.apache.solr.client.solrj.impl.HttpSolrServer"> -->
<!--         <constructor-arg value="${solr.url.primary}"/> -->
<!--     </bean> -->
<!--     <bean id="solrReindexServer" class="org.apache.solr.client.solrj.impl.HttpSolrServer"> -->
<!--         <constructor-arg value="${solr.url.reindex}"/> -->
<!--     </bean> -->
<!--     <bean id="solrAdminServer" class="org.apache.solr.client.solrj.impl.HttpSolrServer"> -->
<!--         <constructor-arg value="${solr.url.admin}"/> -->
<!--     </bean> -->
<bean id="blSearchService" class="org.broadleafcommerce.core.search.service.solr.SolrSearchServiceImpl">
    <constructor-arg name="solrServer" ref="${solr.source.primary}" />
    <constructor-arg name="reindexServer" ref="${solr.source.reindex}" />
    <constructor-arg name="adminServer" ref="${solr.source.admin}" />
</bean>
<bean id="rebuildIndexJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="blSearchService" />
    <property name="targetMethod" value="rebuildIndex" />
</bean> 
<bean id="rebuildIndexTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
    <property name="jobDetail" ref="rebuildIndexJobDetail" />
    <property name="startDelay" value="${solr.index.start.delay}" />
    <property name="repeatInterval" value="${solr.index.repeat.interval}" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
        <list>
            <ref bean="rebuildIndexTrigger" />
            <!--<ref bean="purgeCartTrigger" />-->
            <!--<ref bean="purgeCustomerTrigger" />-->
        </list>
    </property>
</bean>

<!--  Broaldeaf Commerce comes with an Image Server that allows you to manipulate images.   For example, the 
      demo includes a high resolution image for each product that is reduced in size for browsing operations -->
<bean id="blStaticMapNamedOperationComponent" class="org.broadleafcommerce.cms.file.service.operation.StaticMapNamedOperationComponent">
    <property name="namedOperations">
        <map>
            <entry key="browse">
                <map>
                    <entry key="resize-width-amount" value="400"/>
                    <entry key="resize-height-amount" value="400"/>
                    <entry key="resize-high-quality" value="false"/>
                    <entry key="resize-maintain-aspect-ratio" value="true"/>
                    <entry key="resize-reduce-only" value="true"/>
                </map>
            </entry> 
            <entry key="thumbnail">
                <map>
                    <entry key="resize-width-amount" value="60"/>
                    <entry key="resize-height-amount" value="60"/>
                    <entry key="resize-high-quality" value="false"/>
                    <entry key="resize-maintain-aspect-ratio" value="true"/>
                    <entry key="resize-reduce-only" value="true"/>
                </map>
            </entry>  
        </map>
    </property>
</bean>    

<!-- This is an example of a custom dialect definition that uses a custom processor -->
<!-- The second bean registers the dialct to the blWebTemplateEngine -->
<!-- Note that the same thing could be done for the blEmailTemplateEngine -->
<!-- 
<bean id="myDialect" class="com.mycompany.common.web.dialect.MyDialect">
    <property name="processors">
      <set>
        <bean class="com.mycompany.common.web.processor.MyProcessor" />
      </set>
    </property>     
</bean> 
<bean id="blWebTemplateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
    <property name="dialects">
        <set>
            <ref bean="myDialect" />
        </set>
    </property>
</bean> 
-->

<!-- The following two beans are defined like this in Broadleaf Commerce. However, -->
<!-- you may want to override the bean definitions by uncommenting these two beans -->
<!-- to control whether or not templates are cacheable. This will generally be desireable -->
<!-- in production environments, but likely not in development environments. -->
<!-- 
<bean id="blWebTemplateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
    <property name="prefix" value="/WEB-INF/templates/" />
    <property name="suffix" value=".html" />
    <property name="templateMode" value="HTML5" />
    <property name="cacheable" value="${cache.page.templates}"/>
    <property name="cacheTTLMs" value="${cache.page.templates.ttl}" />
    <property name="characterEncoding" value="UTF-8" />
</bean> 
<bean id="blEmailTemplateResolver" class="org.thymeleaf.templateresolver.ClassLoaderTemplateResolver">
    <property name="prefix" value="emailTemplates/" />
    <property name="suffix" value=".html" />
    <property name="templateMode" value="HTML5" />
    <property name="cacheable" value="${cache.page.templates}"/>
    <property name="cacheTTLMs" value="${cache.page.templates.ttl}" />
    <property name="characterEncoding" value="UTF-8" />
</bean>
-->

<bean id="jsLocations" class="org.springframework.beans.factory.config.ListFactoryBean">
    <property name="sourceList">
        <list>
            <value>/js/</value>
        </list>
    </property>
</bean>
<bean class="org.broadleafcommerce.common.extensibility.context.merge.LateStageMergeBeanPostProcessor">
    <property name="collectionRef" value="jsLocations" />
    <property name="targetRef" value="blJsLocations" />
</bean>

<bean id="cssLocations" class="org.springframework.beans.factory.config.ListFactoryBean">
    <property name="sourceList">
        <list>
            <value>/css/</value>
        </list>
    </property>
</bean>
<bean class="org.broadleafcommerce.common.extensibility.context.merge.LateStageMergeBeanPostProcessor">
    <property name="collectionRef" value="cssLocations" />
    <property name="targetRef" value="blCssLocations" />
</bean>

<bean id="blJsResources" class="org.broadleafcommerce.common.web.resource.BroadleafResourceHttpRequestHandler">
    <property name="locations" ref="blJsLocations"/>
    <property name="handlers" ref="blJsHandlers" />
</bean>

<bean id="blCssResources" class="org.broadleafcommerce.common.web.resource.BroadleafResourceHttpRequestHandler">
    <property name="locations" ref="blCssLocations"/>
    <property name="handlers" ref="blCssHandlers" />
</bean>

2 个答案:

答案 0 :(得分:1)

谢谢@ MateiFlorescu:嘿..我改变了我的mysql默认端口号和配置。它运行在端口8080上,这是apache tomcat.so的默认端口。我将mysql端口号更改为3306.Now程序运行顺利!!

答案 1 :(得分:0)

您需要在web.xml中引用数据源

<resource-ref> 
<description>DB Connection</description> 
<res-ref-name>jdbc/dbname</res-ref-name> 
<res-type>javax.sql.DataSource</res-type> 
<res-auth>Container</res-auth> 
</resource-ref>

此外,您使用的是哪个应用服务器? Tomcat(比如问题标签)或Jetty(就像你在评论中提到的那样)?