How to Solve Error Message SpringApplication – Application run failed java.lang.IllegalArgumentException: Unable to create WebResourceSet when running Spring Boot Application

Posted on

Introduction

This is an article where the main focus is just how to solve the error message. The error message is ‘SpringApplication – Application run failed java.lang.IllegalArgumentException: Unable to create WebResourceSet’ in general. That error message itself appears when executing or running the Spring Boot application.The following is the exact and the complete error message for executing or running the Spring Boot application :

C:\application>mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.github.adminfaces:app-starter >-----------------
[INFO] Building app-starter 0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.0.6.RELEASE:run (default-cli) > test-compile @ app-starter >>>
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce-versions) @ app-starter ---
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ app-starter ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] skip non existing resourceDirectory C:\application\src\main\docs
[INFO] Copying 36 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ app-starter ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ app-starter ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\application\src\test\resources
[INFO] skip non existing resourceDirectory C:\application\src\test\java
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ app-starter ---
[INFO] No sources to compile
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.0.6.RELEASE:run (default-cli) < test-compile @ app-starter <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.6.RELEASE:run (default-cli) @ app-starter ---
[INFO] Attaching agents: []

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.6.RELEASE)

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/m2/org/springframework/spring-core/5.0.10.RELEASE/spring-core-5.0.10.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[ERROR] 24-06-2021 06:39:36.095 AM [restartedMain] SpringApplication - Application run failed
java.lang.IllegalArgumentException: Unable to create WebResourceSet from [C:\Users\Mark%20Stuart\.m2\repository\org\glassfish\javax.faces\2.3.4\javax.faces-2.3.4.jar]
        at org.apache.catalina.webresources.StandardRoot.createWebResourceSet(StandardRoot.java:419) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
        at org.joinfaces.autoconfigure.tomcat.JsfTomcatApplicationListener.addClasspathResourceSets(JsfTomcatApplicationListener.java:194) ~[joinfaces-autoconfigure-3.2.6.jar:3.2.6]
        at org.joinfaces.autoconfigure.tomcat.JsfTomcatApplicationListener.onApplicationEvent(JsfTomcatApplicationListener.java:163) ~[joinfaces-autoconfigure-3.2.6.jar:3.2.6]
        at org.joinfaces.autoconfigure.tomcat.JsfTomcatApplicationListener.onApplicationEvent(JsfTomcatApplicationListener.java:41) ~[joinfaces-autoconfigure-3.2.6.jar:3.2.6]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
        at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:103) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
        at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:78) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:323) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
        at com.github.adminfaces.starter.AdminBootMain.main(AdminBootMain.java:37) [classes/:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.6.RELEASE.jar:2.0.6.RELEASE]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  31.066 s
[INFO] Finished at: 2021-06-24T06:39:36+07:00
[INFO] ------------------------------------------------------------------------

C:\application>

Basically, the error message exist in the following line :

[ERROR] 24-06-2021 06:39:36.095 AM [restartedMain] SpringApplication - Application run failed java.lang.IllegalArgumentException: Unable to create WebResourceSet from [C:\Users\Mark%20Stuart\.m2\repository\org\glassfish\javax.faces\2.3.4\javax.faces-2.3.4.jar]

In the first place, the failing process for creating the WebResourceSet exist in the path above.

Solution

In this context, there are several attempts to execute the solution for solving the problem. The first attempt is to try to execute it as an administrator account. The second attempt is to try to solve it by changing the location of the Maven repository folder.

Execute the command as an administrator

This is the first attempt for solving the problem. In this an example, the execution of the command is using an administrator account. The following are the steps as an attempt to solve :

  1. Just execute the command prompt as Administrator. Type Ctrl+Run and type cmd. In other way, the execution is also possible by executing right click the Command Prompt Icon and then select the menu Run as Administrator. Following after, this Command Prompt window will also appear :

    How to Solve Error Message SpringApplication - Application run failed java.lang.IllegalArgumentException: Unable to create WebResourceSet when running Spring Boot Application
    How to Solve Error Message SpringApplication – Application run failed java.lang.IllegalArgumentException: Unable to create WebResourceSet when running Spring Boot Application
  2. Type the exact command which is ‘mvn spring-boot:run’ as follows :

    Microsoft Windows [Version 10.0.19042.1052]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\WINDOWS\system32>cd \
    
    C:\>cd application
    
    C:\application>mvn spring-boot:run
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ----------------< com.github.adminfaces:app-starter >-----------------
    [INFO] Building admin-starter 0.1-SNAPSHOT
    [INFO] --------------------------------[ war ]---------------------------------
    [INFO]
    [INFO] >>> spring-boot-maven-plugin:2.0.6.RELEASE:run (default-cli) > test-compile @ app-starter >>>
    [INFO]
    [INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce-versions) @ app-starter ---
    [INFO]
    [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ app-starter ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 4 resources
    [INFO] skip non existing resourceDirectory C:\application\src\main\docs
    [INFO] Copying 36 resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ app-starter ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO]
    [INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ app-starter ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory C:\application\src\test\resources
    [INFO] skip non existing resourceDirectory C:\application\src\test\java
    [INFO]
    [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ app-starter ---
    [INFO] No sources to compile
    [INFO]
    [INFO]
    [INFO] <<< spring-boot-maven-plugin:2.0.6.RELEASE:run (default-cli) < test-compile @ app-starter <<<
    [INFO]
    [INFO]
    [INFO] --- spring-boot-maven-plugin:2.0.6.RELEASE:run (default-cli) @ app-starter ---
    [INFO] Attaching agents: []
    
    . ____ _ __ _ _
    /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    \\/ ___)| |_)| | | | | || (_| | ) ) ) )
    ' |____| .__|_| |_|_| |_\__, | / / / /
    =========|_|==============|___/=/_/_/_/
    :: Spring Boot :: (v2.0.6.RELEASE)
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/Mark%20Stuart/.m2/repository/org/springframework/spring-core/5.0.10.RELEASE/spring-core-5.0.10.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
    WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    [ERROR] 24-06-2021 10:05:47.380 AM [restartedMain] SpringApplication - Application run failed
    java.lang.IllegalArgumentException: Unable to create WebResourceSet from [C:\Users\Hamdi%20Riady\.m2\repository\org\glassfish\javax.faces\2.3.4\javax.faces-2.3.4.jar]
    at org.apache.catalina.webresources.StandardRoot.createWebResourceSet(StandardRoot.java:419) ~[tomcat-embed-core-8.5.34.jar:8.5.34]
    at org.joinfaces.autoconfigure.tomcat.JsfTomcatApplicationListener.addClasspathResourceSets(JsfTomcatApplicationListener.java:194) ~[joinfaces-autoconfigure-3.2.6.jar:3.2.6]
    at org.joinfaces.autoconfigure.tomcat.JsfTomcatApplicationListener.onApplicationEvent(JsfTomcatApplicationListener.java:163) ~[joinfaces-autoconfigure-3.2.6.jar:3.2.6]
    at org.joinfaces.autoconfigure.tomcat.JsfTomcatApplicationListener.onApplicationEvent(JsfTomcatApplicationListener.java:41) ~[joinfaces-autoconfigure-3.2.6.jar:3.2.6]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:103) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:78) ~[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:323) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at com.github.adminfaces.starter.AdminBootMain.main(AdminBootMain.java:37) [classes/:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 57.537 s
    [INFO] Finished at: 2021-06-24T10:05:48+07:00
    [INFO] ------------------------------------------------------------------------
    
    C:\application>
    

    Basically, it ends in failure. So, the solution is not possible to achieve just by changing the user executing the command. Even by changing it from a normal standard user to Administrator user.

Execute the command after changing the Maven repository folder

Finally, this is the second attempt for solving the problem. Actually, this is the solution that is working well. It is a solution available just by changing the location of the Maven repository folder. Why moving the folder location ?. It is because the folder location of Apache Maven repository is containing spaces. The default location is in this example is in ‘C:\Users\Mark Stuart\.m2\repository’. So, there is a space between ‘Mark’ and ‘Stuart’. With than mind, the following are the steps to change it and solve the problem :

  1. First of all, just edit the file with the name settings.xml. It is usually exist in the folder of the Apache Maven. Precisely, it is in the ‘conf’ folder available in the root folder of the Apache Maven.  This part is the one defining for the default localRepository :

    <!-- localRepository
    | The path to the local repository maven will use to store artifacts.
    |
    | Default: ${user.home}/.m2/repository
    <localRepository>/path/to/local/repo</localRepository>
    -->
    
  2. Add the following line to move the Apache Maven folder repository from the default location. According to the snippet lines of configuration above, it exist in ‘${user.home}/.m2/repository’. In this context, it is in ‘C:\Users\Mark Stuart\.m2\repository’. So, add the following in the file with the name of ‘settings.xml’ to change it fromt he default path to another path :

    <localRepository>C:\m2</localRepository>
  3. So, the following are the configuration after the editing process :
    <!-- localRepository
    | The path to the local repository maven will use to store artifacts.
    |
    | Default: ${user.home}/.m2/repository
    <localRepository>/path/to/local/repo</localRepository>
    -->
    
  4. Finally, try to execute the command again. The following are the final execution using the modified maven file configuration of ‘settings.xml’ :

    C:\application>mvn spring-boot:run
    [INFO] Scanning for projects...
    Downloading from prime-repo: http://repository.primefaces.org/org/joinfaces/joinfaces-parent/3.2.6/joinfaces-parent-3.2.6.pom
    Downloading from central: https://repo.maven.apache.org/maven2/org/joinfaces/joinfaces-parent/3.2.6/joinfaces-parent-3.2.6.pom
    Downloaded from central: https://repo.maven.apache.org/maven2/org/joinfaces/joinfaces-parent/3.2.6/joinfaces-parent-3.2.6.pom (12 kB at 9.1 kB/s)
    Downloading from prime-repo: http://repository.primefaces.org/org/joinfaces/joinfaces-dependencies/3.2.6/joinfaces-dependencies-3.2.6.pom
    Downloading from icesoft-releases: http://anonsvn.icesoft.org/repo/maven2/releases/org/joinfaces/joinfaces-dependencies/3.2.6/joinfaces-dependencies-3.2.6.pom
    Downloading from central: https://repo.maven.apache.org/maven2/org/joinfaces/joinfaces-dependencies/3.2.6/joinfaces-dependencies-3.2.6.pom
    Downloaded from central: https://repo.maven.apache.org/maven2/org/joinfaces/joinfaces-dependencies/3.2.6/joinfaces-dependencies-3.2.6.pom (36 kB at 60 kB/s)
    Downloading from prime-repo: http://repository.primefaces.org/org/springframework/boot/spring-boot-starter-parent/2.0.6.RELEASE/spring-boot-starter-parent-2.0.6.RELEASE.pom
    Downloading from icesoft-releases: http://anonsvn.icesoft.org/repo/maven2/releases/org/springframework/boot/spring-boot-starter-parent/2.0.6.RELEASE/spring-boot-starter-parent-2.0.6.RELEASE.pom
    Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.0.6.RELEASE/spring-boot-starter-parent-2.0.6.RELEASE.pom
    Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.0.6.RELEASE/spring-boot-starter-parent-2.0.6.RELEASE.pom (12 kB at 28 kB/s)
    Downloading from prime-repo: http://repository.primefaces.org/org/springframework/boot/spring-boot-dependencies/2.0.6.RELEASE/spring-boot-dependencies-2.0.6.RELEASE.pom
    Downloading from icesoft-releases: http://anonsvn.icesoft.org/repo/maven2/releases/org/springframework/boot/spring-boot-dependencies/2.0.6.RELEASE/spring-boot-dependencies-2.0.6.RELEASE.pom
    Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.0.6.RELEASE/spring-boot-dependencies-2.0.6.RELEASE.pom
    Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.0.6.RELEASE/spring-boot-dependencies-2.0.6.RELEASE.pom (141 kB at 137 kB/s)
    ...
    ...
    ...
    [INFO] Attaching agents: []
    
      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v2.0.6.RELEASE)
    
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/m2/org/springframework/spring-core/5.0.10.RELEASE/spring-core-5.0.10.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
    WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    

    Because of the change of the Apache Maven repository location, all of the necessary jar files will be downloaded. The process for downloading the jar files will be going on through according the need specified in the pom.xml file of the project.

    It is exist as in the above output of the command execution that the process for running Spring Boot application is a success.

Leave a Reply