question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileNotFoundException: ServletContext resource [/classpath*:dozer/*dozer.xml] cannot be resolved to URL because it does not exist

See original GitHub issue

Springcloud projects start error reporting.

Whats your runtime?

  • Dozer version: 6.4.0_
  • OS version: __mac os 10.13.4 ___
  • JDK version: 8_
  • SpringBoot version: 2.0.0.RELEASE
  • SpringCloud version: Finchley.M8

Whats the problem?

1, pom

        <dependency>
            <groupId>com.github.dozermapper</groupId>
            <artifactId>dozer-core</artifactId>
            <version>6.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.github.dozermapper</groupId>
            <artifactId>dozer-spring-boot-starter</artifactId>
            <version>6.4.0</version>
        </dependency>

2 application.yml,

dozer:
  mappingFiles: classpath*:dozer/*.dozer.xml

3, mapping file :

 src/main/resources/dozer/global.dozer.xml

Observed Results:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.dozermapper.spring.DozerBeanMapperFactoryBean]: Factory method 'dozerMapper' threw exception; nested exception is java.io.FileNotFoundException: ServletContext resource [/classpath*:dozer/*dozer.xml] cannot be resolved to URL because it does not exist
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
	... 45 common frames omitted
Caused by: java.io.FileNotFoundException: ServletContext resource [/classpath*:dozer/*dozer.xml] cannot be resolved to URL because it does not exist
	at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:174)
	at com.github.dozermapper.spring.DozerBeanMapperFactoryBean.setMappingFiles(DozerBeanMapperFactoryBean.java:81)
	at com.github.dozermapper.springboot.autoconfigure.DozerAutoConfiguration.dozerMapper(DozerAutoConfiguration.java:58)
	at com.github.dozermapper.springboot.autoconfigure.DozerAutoConfiguration$$EnhancerBySpringCGLIB$$c8b0337d.CGLIB$dozerMapper$0(<generated>)
	at com.github.dozermapper.springboot.autoconfigure.DozerAutoConfiguration$$EnhancerBySpringCGLIB$$c8b0337d$$FastClassBySpringCGLIB$$2d9afb47.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
	at com.github.dozermapper.springboot.autoconfigure.DozerAutoConfiguration$$EnhancerBySpringCGLIB$$c8b0337d.dozerMapper(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 46 common frames omitted

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tryIdeacommented, Oct 22, 2018

I also have the problem.why

0reactions
wjn0918commented, May 13, 2020

you can use this way to reduce it error

  1. create applicationContext.xml to assign where is your dozer xml location
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2005-2019 Dozer Project
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
         http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="implicitMapper" class="com.github.dozermapper.core.DozerBeanMapperBuilder" factory-method="buildDefault"/>

    <!-- Provided Spring Integration -->
    <bean id="byFactory" class="com.github.dozermapper.spring.DozerBeanMapperFactoryBean">
        <!--this value is your dozer xml -->
        <property name="mappingFiles" value="classpath*:dozer/*.xml"/>
    </bean>

</beans>
  1. config your application.yml
server:
  port: 80

spring:
  config:
    location: classpath:applicationContext.xml
Read more comments on GitHub >

github_iconTop Results From Across the Web

class path resource cannot be resolved to URL because it ...
FileNotFoundException : class path resource [com/mycompany/context-B.xml] cannot be resolved to URL because it does not exist.
Read more >
Unable To Edit Element After Patch: java.io ... - Oracle Support
FileNotFoundException : ServletContext resource [/Xcelerate/OMTree. ... cannot be resolved to URL because it does not exist (Doc ID 2697377.1).
Read more >
FileNotFoundException « Exception « Spring Q&A - Java2s.com
FileNotFoundException : class path resource cannot be opened because it does not exist stackoverflow.com. I want to pick up a property file app.properties ......
Read more >
Search - appsloveworld.com
[Solved]-Java.io.FileNotFoundException: class path resource [../ProductDao.class] cannot be opened because it does not exist-Spring MVC.
Read more >
Spring Mvc - Unexpected Exception Parsing Xml Document ...
FileNotFoundException : Could not open ServletContext resource. ... dozer: mappingFiles: classpath:dozer/.dozer.xml to URL because it does not exist at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found