title: how to resolve java.lang.reflect.InvocationTargetException struts2 with hibernate
body: <p><strong>how to resolve java.lang.reflect.InvocationTargetException struts2 with hibernate
  i used struts2 with hibernate when i call the hibenate method it displaying error please help me. this code is not working on tomcat server 7.0 when i tested it in main class its working fine</strong></p>
  
  <p>my action method code is here</p>
  
  <pre><code>public string add()
  {
    Session session=null;
      try
      {
    SessionFactory sessionFactory = new  
  
     Configuration().configure().buildSessionFactory();
    session =sessionFactory.openSession();
  
      Contact contact=new Contact();
     contact.setFirstName("sanjeev");
    contact.setLastName("kumar");
      contact.setEmailId("pr@gmail.com");
     contact.setCellNo("4664564564");
      contact.setWebsite("www.roseindia.com");
    session.save(contact);
      session.beginTransaction().commit();
  
  
  
      }catch(Exception e)
      {
      System.out.println(e);
      }
  
  
    return SUCCESS;
  }
  </code></pre>
  
  <p>exception </p>
  
  <pre><code>    java.lang.reflect.InvocationTargetException
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  java.lang.reflect.Method.invoke(Method.java:597)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
  com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
  org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
  org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
  org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
  </code></pre>
  
  <p>root cause </p>
  
  <pre><code> java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(Z)V
  net.sf.cglib.core.DebuggingClassWriter.&lt;init&gt;(DebuggingClassWriter.java:47)
  net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
  net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
  net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
  net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
  net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
  net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
  net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
  net.sf.cglib.proxy.Enhancer.&lt;clinit&gt;(Enhancer.java:69)
  org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
  org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
  org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
  org.hibernate.tuple.entity.AbstractEntityTuplizer.&lt;init&gt;(AbstractEntityTuplizer.java:135)
  org.hibernate.tuple.entity.PojoEntityTuplizer.&lt;init&gt;(PojoEntityTuplizer.java:55)
  org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.&lt;init&gt;(EntityEntityModeToTuplizerMapping.java:56)
  org.hibernate.tuple.entity.EntityMetamodel.&lt;init&gt;(EntityMetamodel.java:295)
  org.hibernate.persister.entity.AbstractEntityPersister.&lt;init&gt;(AbstractEntityPersister.java:434)
  org.hibernate.persister.entity.SingleTableEntityPersister.&lt;init&gt;(SingleTableEntityPersister.java:109)
  org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
  org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:226)
  org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
  strutsaction.ContactAction.add(ContactAction.java:67)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  java.lang.reflect.Method.invoke(Method.java:597)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
  com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
  org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
  org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
  org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
  </code></pre>