title: java.lang.NoClassDefFoundError: Could not initialize class com.sun.proxy.$Proxy13
body: <p>I am new to jersey I made a website which is mostly static except the contact us part which is using <code>javamail api</code> and <code>recaptcha</code> feature. My project is working fine in eclipse. But when I uploaded it in the production I am facing this issue. It say's the could not initialize class <code>com.sun.proxy.$Proxy13</code> . I tried various solutions but the thing is that my application is working as expected in test environment (eclipse) but giving exception in production environment.
  Here is the stack trace:</p>
  
  <p><img src="https://i.stack.imgur.com/ta1p6.png" alt="Stack trace">
  <img src="https://i.stack.imgur.com/Grnji.png" alt="error from production"></p>
  
  <p>Web.XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- This web.xml file is not required when using Servlet 3.0 container, 
       see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e194 --&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
              &lt;param-value&gt;co.in.****&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; 
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/webresources/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Form </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;form class="form" action="webresources/check/validate" name="contactus" method="get"&gt;
            &lt;input class="name" type="text" placeholder="Name" name = "name" id="name" required="required"&gt;
            &lt;input class="email" type="email" placeholder="Email" name="email" id="email" required="required"&gt;
            &lt;input class="phone" type="text" placeholder="Phone No:" name="phone" id="phone"&gt;
            &lt;textarea class="message" name="message" id="message" cols="30" rows="10" placeholder="Message" required="required"&gt;&lt;/textarea&gt;
            &lt;div class="g-recaptcha" data-sitekey="*************"&gt;&lt;/div&gt;
            &lt;input class="submit-btn" type="submit" value="SUBMIT"&gt;
           &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>POM.XML</p>
  
  <pre><code>&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/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;co.in.******&lt;/groupId&gt;
      &lt;artifactId&gt;meshtechnologies&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;**** Jersey Webapp&lt;/name&gt;
      &lt;build&gt;
          &lt;finalName&gt;*****&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;inherited&gt;true&lt;/inherited&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;!-- Run the application using "mvn embedded-glassfish:run" --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.glassfish&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-embedded-glassfish-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${glassfish.version}&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;goalPrefix&gt;embedded-glassfish&lt;/goalPrefix&gt;
                      &lt;app&gt;D:/Projects/target/${project.build.finalName}.war&lt;/app&gt;
                      &lt;autoDelete&gt;true&lt;/autoDelete&gt;
                      &lt;port&gt;8080&lt;/port&gt;
                  &lt;/configuration&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
                          &lt;artifactId&gt;jersey-servlet&lt;/artifactId&gt;
                          &lt;version&gt;${project.version}&lt;/version&gt;
                      &lt;/dependency&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
                          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
                          &lt;version&gt;3.0.1&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-servlet&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.8.2&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
              &lt;version&gt;${jersey.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.extras&lt;/groupId&gt;
              &lt;artifactId&gt;glassfish-embedded-web&lt;/artifactId&gt;
              &lt;version&gt;${glassfish.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.mail&lt;/groupId&gt;
              &lt;artifactId&gt;javax.mail-api&lt;/artifactId&gt;
              &lt;version&gt;1.5.5&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-collections4&lt;/artifactId&gt;
              &lt;version&gt;4.1&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.octo.captcha&lt;/groupId&gt;
              &lt;artifactId&gt;jcaptcha-all&lt;/artifactId&gt;
              &lt;version&gt;1.0-RC6&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;commons-logging&lt;/groupId&gt;
              &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
  
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish&lt;/groupId&gt;
              &lt;artifactId&gt;javax.json&lt;/artifactId&gt;
              &lt;version&gt;1.0.4&lt;/version&gt;
          &lt;/dependency&gt;
  
           &lt;dependency&gt;
              &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
              &lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt;
              &lt;version&gt;2.0.1&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
              &lt;version&gt;2.22.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.connectors&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-apache-connector&lt;/artifactId&gt;
              &lt;version&gt;2.22.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-jdk-http&lt;/artifactId&gt;
              &lt;version&gt;2.22.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.mail&lt;/groupId&gt;
              &lt;artifactId&gt;mail&lt;/artifactId&gt;
              &lt;version&gt;1.4.7&lt;/version&gt;
          &lt;/dependency&gt;
  
  
      &lt;/dependencies&gt;
      &lt;properties&gt;
          &lt;jersey.version&gt;1.19&lt;/jersey.version&gt;
          &lt;glassfish.version&gt;3.1.1&lt;/glassfish.version&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Class</p>
  
  <pre><code>package co.in.******;
  
  import java.io.IOException;
  import java.net.URI;
  import java.net.URISyntaxException;
  import java.net.URL;
  import java.util.Date;
  import java.util.Properties;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.QueryParam;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  import javax.mail.*;
  import javax.mail.internet.*;
  
  /** Example resource class hosted at the URI path "/myresource"
   */
  
  @Path("/check")
  public class MyResource {
  
      @GET
      @Produces(MediaType.TEXT_HTML)
      @Path("/validate")
      public Response getData(@QueryParam("name") String name,@QueryParam("email") String email,
              @QueryParam("message") String msg, @QueryParam("phone") String mob
              ,@QueryParam("g-recaptcha-response") String gRecaptchaResponse) throws IOException, URISyntaxException
      {
  
          // get reCAPTCHA request param
  
          System.out.println(gRecaptchaResponse);
          boolean verify = VerifyRecaptcha.verify(gRecaptchaResponse);
          if(verify)
          {
              System.out.println("VALID");
  
              try
              {
                String smtpServer="smtp.gmail.com";
                String to="**********";
                String from= "***************";
                String subject="Contact Request "+email;
                String body= name+" : "+mob+" : "+msg;
                send(smtpServer, to, from, subject, body);
              }
              catch (Exception ex)
              {
                System.out.println("Usage: java com.lotontech.mail.SimpleSender"
                 +" smtpServer toAddress fromAddress subjectText bodyText");
              }
  
              URI u = new URI("*************");
  
             return Response.temporaryRedirect(u).build();
  
          }
          else
          {
  
              URI u = new URI("*******");
             return Response.temporaryRedirect(u).build();
  
  
          }
  
  
      }
  
      protected static void send(String smtpServer, String to, String from
                 , String subject, String body)
                {
                  try
                  {
                    Properties props = System.getProperties();
                    // -- Attaching to default Session, or we could start a new one --
                   props.put("mail.smtp.host", smtpServer);
                    Session session = Session.getDefaultInstance(props, null);
                    // -- Create a new message --
                    Message msg = new MimeMessage(session);
                    // -- Set the FROM and TO fields --
                    msg.setFrom(new InternetAddress(from));
                    msg.setRecipients(Message.RecipientType.TO,
                      InternetAddress.parse(to, false));
                    // -- We could include CC recipients too --
                    // if (cc != null)
                    // msg.setRecipients(Message.RecipientType.CC
                    // ,InternetAddress.parse(cc, false));
                    // -- Set the subject and body text --
                    msg.setSubject(subject);
                    msg.setText(body);
                    // -- Set some other header information --
                    msg.setHeader("X-Mailer", "LOTONtechEmail");
                    msg.setSentDate(new Date());
                    // -- Send the message --
                  //  Transport.send(msg);
  
                    Transport transport = session.getTransport("smtps");
                    transport.connect(smtpServer, 465, "******","*******");
  
                    transport.sendMessage(msg, msg.getAllRecipients());
                    transport.close();
                    System.out.println("Message sent OK.");
                  }
                  catch (Exception ex)
                  {
                    ex.printStackTrace();
                  }
                }
  
  }
  </code></pre>
  
  <p>Please help me with this. Thanks</p>