title: how to run a war file in maven application?
body: <p>I'm trying to run a war file in a maven aplication.</p>
  
  <p>Since I need the oauth2 b2c from azure I found this usefull <a href="https://github.com/Pytry/azure-b2c-oauth2" rel="nofollow noreferrer">code</a></p>
  
  <p>I've never tried Spring before so I'm new about it</p>
  
  <p>I tried to compile with <code>mvn compile</code> and JDK 1.7 as it says in github</p>
  
  <p>but I got an error instead:</p>
  
  <blockquote>
    <p>Cannot find symbol : Base64</p>
  </blockquote>
  
  <p>Searching on internet I found it was supported by Jdk 1.8 + and by importing error so I did the import and that did the trick. </p>
  
  <p>After that I did <code>mvn package</code> and it also did the package generating the war files and target folder.</p>
  
  <p>I ran the war file <code>java -jar azure-b2c-oauth2.war</code></p>
  
  <p>But got this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:62)
          at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
          ... 1 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
          at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
          at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
          at com.dogjaw.services.authentication.AzureB2CApplication.main(AzureB2CApplication.java:37)
          ... 6 more
  Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
          ... 26 more
  Caused by: org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built
          at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:44)
          at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain(WebSecurityConfiguration.java:105)
          at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$e0fe7e73.CGLIB$springSecurityFilterChain$5(&lt;generated&gt;)
          at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$e0fe7e73$$FastClassBySpringCGLIB$$6961afff.invoke(&lt;generated&gt;)
          at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
          at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355)
          at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$e0fe7e73.springSecurityFilterChain(&lt;generated&gt;)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
          ... 27 more
  </code></pre>
  
  <p>This is the pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.dogjaw.services.authentication&lt;/groupId&gt;
      &lt;artifactId&gt;azure-b2c-oauth2&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;Oauth2-PRoxy-Authenticator&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.3.2.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;java.version&gt;1.7&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.hateoas&lt;/groupId&gt;
              &lt;artifactId&gt;spring-hateoas&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
              &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security.oauth&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-oauth2&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-crypto&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-jwt&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.webjars&lt;/groupId&gt;
              &lt;artifactId&gt;angularjs&lt;/artifactId&gt;
              &lt;version&gt;1.5.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.webjars&lt;/groupId&gt;
              &lt;artifactId&gt;jquery&lt;/artifactId&gt;
              &lt;version&gt;2.1.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.webjars&lt;/groupId&gt;
              &lt;artifactId&gt;bootstrap&lt;/artifactId&gt;
              &lt;version&gt;3.2.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.webjars&lt;/groupId&gt;
              &lt;artifactId&gt;webjars-locator&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt;
                      &lt;executable&gt;false&lt;/executable&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;!-- By naming the war file in each plugin (boot and war), it ensures
                  that only one war file will be produced. --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;warName&gt;${project.artifactId}&lt;/warName&gt;
                      &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Any help would be apreciate thanks!</p>