Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 827203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:32:11+00:00 2026-05-15T03:32:11+00:00

I am trying to create instance of class javax.servlet.ServletException with following code public class

  • 0

I am trying to create instance of class javax.servlet.ServletException with following code

public class MyTroubleViewer {
 public static void main(String[] args) {
  javax.servlet.ServletException servletException = new javax.servlet.ServletException("Hello");
  System.out.println(servletException.getMessage());
 }
}

But I get exception on creating:

Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException
...

Maven helps me with dependecies:

<dependency>
 <groupId>javax</groupId>
 <artifactId>javaee-api</artifactId>
 <version>6.0</version>
 <type>jar</type>
 <scope>compile</scope>
</dependency>

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:32:12+00:00Added an answer on May 15, 2026 at 3:32 am

    As mentioned by @user353852, your current dependency contains only the Java EE 6 APIs and does not contain any method bodies. So you can’t run code against it. To run your code outside a container, you need to get a “concrete” dependency (from GlassFish repository):

    <repositories>
      <repository>
        <id>glassfish-repository</id>
        <url>http://download.java.net/maven/glassfish</url>
      </repository>
      ...
    </repositories>
    
    <dependencies>
      <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.servlet</artifactId>
        <version>3.0</version>
        <scope>test</scope>
      </dependency>
      ...
    </dependencies>
    

    Note that such dependencies shouldn’t be declared with a compile scope, you don’t want to bundle it (it should be provided or maybe test, but not compile or runtime).


    I wonder does the provider of the javaee implementation important? Generally I use Apache servers, so it will be great to have the same javaee implementation as it is on the server.

    In theory, no. But in practice, I would recommend to use the implementation JARs from the server you are going to use (or from the Java EE Reference Implementation). Since you are using Java EE 6, this actually means JARS from GlassFish v3 in both cases .

    The second question is much more vital. javax.servlet is only one part of javaee-api implementation, where can I find the others. Now I need “javax/validation/Validation”.

    For the Bean Validation API, you’ll need the following (Hibernate Validator being the RI):

    <repositories>
      <!-- For Hibernate Validator -->
      <repository>
        <id>jboss</id>
        <name>JBoss repository</name>
        <url>http://repository.jboss.org/maven2</url>
      </repository>
      ...
    </repositories>
    
    <dependencies>
      <!-- Bean Validation API and RI -->
      <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.0.2.GA</version>
        <scope>runtime</scope>
      </dependency>
      ...
    </dependencies>
    

    How can I determine which artifact implements each aspect of javaee. Maybe there is some kind of a “map” somewhere?

    Nothing official but this nice answer from BalusC will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an instance of a class at run time. The classes
I am trying to create an instance of a class using Linq and XML.
I’m trying to create an instance of: java.awt.geom.Point2D.Double in ColdFusion. Point2D.Double is a nested
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a list to return some JSON data to a view. Following
I am trying to use the Spring Framework IoC Container to create an instance
I'm trying to initialize an instance of class consoleDroid with consoleDroid console = new
I'm trying to run the following code but unfortunately facing Error problems package jskypeexample;
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a user account in a test. But getting a Object reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.