hibernate - Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -


i'm developing spring mvc security hibernate example taking reference http://www.mkyong.com/spring-security/spring-security-hibernate-annotation-example/. in example, updated maven dependencies latest versions

<properties>         <jdk.version>1.8</jdk.version>         <spring.version>4.2.4.release</spring.version>         <spring.security.version>3.2.9.release</spring.security.version>         <jstl.version>1.2</jstl.version>         <mysql.connector.version>5.1.38</mysql.connector.version>         <logback.version>1.1.2</logback.version>         <slf4j.version>1.7.6</slf4j.version>         <hibernate.version>4.2.11.final</hibernate.version>         <dbcp.version>1.4</dbcp.version>     </properties> 

the compilation error reference:

[error] failed execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project spring-security-hibernate-annotation: error assembling war: webxml attribute required (or pre-existing web-inf/web.xml if executing in update mode) -> [help 1] org.apache.maven.lifecycle.lifecycleexecutionexception: failed execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project spring-security-hibernate-annotation: error assembling war: webxml attribute required (or pre-existing web-inf/web.xml if executing in update mode)         @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:216)         @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:153)         @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:145)         @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:116)         @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:80)         @ org.apache.maven.lifecycle.internal.builder.singlethreaded.singlethreadedbuilder.build(singlethreadedbuilder.java:51)         @ org.apache.maven.lifecycle.internal.lifecyclestarter.execute(lifecyclestarter.java:120)         @ org.apache.maven.defaultmaven.doexecute(defaultmaven.java:355)         @ org.apache.maven.defaultmaven.execute(defaultmaven.java:155)         @ org.apache.maven.cli.mavencli.execute(mavencli.java:584)         @ org.apache.maven.cli.mavencli.domain(mavencli.java:216)         @ org.apache.maven.cli.mavencli.main(mavencli.java:160)         @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)         @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)         @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)         @ java.lang.reflect.method.invoke(method.java:497)         @ org.codehaus.plexus.classworlds.launcher.launcher.launchenhanced(launcher.java:289)         @ org.codehaus.plexus.classworlds.launcher.launcher.launch(launcher.java:229)         @ org.codehaus.plexus.classworlds.launcher.launcher.mainwithexitcode(launcher.java:415)         @ org.codehaus.plexus.classworlds.launcher.launcher.main(launcher.java:356) caused by: org.apache.maven.plugin.mojoexecutionexception: error assembling war: webxml attribute required (or pre-existing web-inf/web.xml if executing in update mode)         @ org.apache.maven.plugin.war.warmojo.execute(warmojo.java:193)         @ org.apache.maven.plugin.defaultbuildpluginmanager.executemojo(defaultbuildpluginmanager.java:132)         @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:208)         ... 19 more caused by: org.codehaus.plexus.archiver.archiverexception: webxml attribute required (or pre-existing web-inf/web.xml if executing in update mode)         @ org.codehaus.plexus.archiver.war.wararchiver.initzipoutputstream(wararchiver.java:148)         @ org.codehaus.plexus.archiver.zip.abstractziparchiver.createarchivemain(abstractziparchiver.java:309)         @ org.codehaus.plexus.archiver.zip.abstractziparchiver.execute(abstractziparchiver.java:211)         @ org.codehaus.plexus.archiver.abstractarchiver.createarchive(abstractarchiver.java:897)         @ org.apache.maven.archiver.mavenarchiver.createarchive(mavenarchiver.java:582)         @ org.apache.maven.plugin.war.warmojo.performpackaging(warmojo.java:243)         @ org.apache.maven.plugin.war.warmojo.execute(warmojo.java:177)         ... 21 more [error] [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/mojoexecutionexception 

not sure wrong here. pls help. securityconfig.java

@configuration @enablewebsecurity public class securityconfig extends websecurityconfigureradapter {      @autowired     @qualifier("userdetailsservice")     private userdetailsservice userdetailsservice;      @autowired     public void configureglobal(authenticationmanagerbuilder auth) throws exception {         auth.userdetailsservice(userdetailsservice).passwordencoder(passwordencoder());     }      @override     protected void configure(httpsecurity http) throws exception {          http.authorizerequests().antmatchers("/admin/**")         .access("hasrole('role_admin')").and().formlogin()         .loginpage("/login").failureurl("/login?error")         .usernameparameter("username")         .passwordparameter("password")         .and().logout().logoutsuccessurl("/login?logout")         .and().csrf()         .and().exceptionhandling().accessdeniedpage("/403");     }      @bean     public passwordencoder passwordencoder(){         passwordencoder encoder = new bcryptpasswordencoder();         return encoder;     } } 

appconfig.java

@enablewebmvc @configuration @componentscan({ "com.mkyong.*" }) @enabletransactionmanagement @import({ securityconfig.class }) public class appconfig {      @bean     public sessionfactory sessionfactory() {         localsessionfactorybuilder builder = new localsessionfactorybuilder(datasource());         builder         .scanpackages("com.mkyong.users.model")         .addproperties(gethibernateproperties());          return builder.buildsessionfactory();     }      private properties gethibernateproperties() {         properties prop = new properties();         prop.put("hibernate.format_sql", "true");         prop.put("hibernate.show_sql", "true");         prop.put("hibernate.dialect", "org.hibernate.dialect.mysql5dialect");         return prop;     }      @bean(name = "datasource")     public basicdatasource datasource() {         basicdatasource ds = new basicdatasource();         ds.setdriverclassname("com.mysql.jdbc.driver");         ds.seturl("jdbc:mysql://localhost:3306/test");         ds.setusername("root");         ds.setpassword("root");          return ds;     }      @bean     public hibernatetransactionmanager txmanager() {         return new hibernatetransactionmanager(sessionfactory());     }      @bean     public internalresourceviewresolver viewresolver() {         internalresourceviewresolver viewresolver = new internalresourceviewresolver();         viewresolver.setviewclass(jstlview.class);         viewresolver.setprefix("/web-inf/pages/");         viewresolver.setsuffix(".jsp");          return viewresolver;     } } 

userdao.java

public interface userdao {     user findbyusername(string username); } 

springmvcinitializer.java

public class springmvcinitializer extends abstractannotationconfigdispatcherservletinitializer {      @override     protected class<?>[] getrootconfigclasses() {         return new class[] { appconfig.class };     }      @override     protected class<?>[] getservletconfigclasses() {         return null;     }      @override     protected string[] getservletmappings() {         return new string[] { "/" };     } } 

springsecurityinitializer.java

public class springsecurityinitializer extends abstractsecuritywebapplicationinitializer {  } 

userdaoimpl.java

@repository public class userdaoimpl implements userdao {      @autowired     private sessionfactory sessionfactory;      @suppresswarnings("unchecked")     public user findbyusername(string username) {          list<user> users = new arraylist<user>();          users = sessionfactory.getcurrentsession()                 .createquery("from user username=?")                 .setparameter(0, username).list();          if (users.size() > 0) {             return users.get(0);         } else {             return null;         }     } } 

project build:

<build>         <finalname>springsecurity</finalname>         <plugins>              <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-compiler-plugin</artifactid>                 <version>2.3.2</version>                 <configuration>                     <source>${jdk.version}</source>                     <target>${jdk.version}</target>                 </configuration>             </plugin>              <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-eclipse-plugin</artifactid>                 <version>2.9</version>                 <configuration>                     <downloadsources>true</downloadsources>                     <downloadjavadocs>false</downloadjavadocs>                     <wtpversion>2.0</wtpversion>                 </configuration>             </plugin>         </plugins>     </build> 

as per: https://maven.apache.org/plugins/maven-war-plugin/dependency-info.html. need add following plugins:

<plugin>     <artifactid>maven-war-plugin</artifactid>     <version>2.6</version>     <configuration>         <failonmissingwebxml>false</failonmissingwebxml>     </configuration> </plugin> 

this solve issue.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -