"An ExceptionInInitializer error occurred - Can you provide more details,

An Issue Has Arisen:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.PoseidonTechnologies.caveworld.level.WoRe.<init>(WoRe.java:46)
    at com.PoseidonTechnologies.caveworld.CaveWorld.start(CaveWorld.java:80)
    at com.PoseidonTechnologies.caveworld.CaveWorld.main(CaveWorld.java:303)
Caused by: java.lang.RuntimeException: !!
    at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:61)
    at com.PoseidonTechnologies.caveworld.level.Ch.<clinit>(Ch.java:20)
    ... 3 more

The Problematic Code Fragment Is Shown Below:

  @SuppressWarnings({ "unchecked", "rawtypes" })
private static HashMap<String, Integer> iM = new HashMap();
  private static int lId = -9999999;

  public static int loT(String path, int m) {
      File file = new File(path);
    try {
      if (iM.containsKey(file)) {
        return ((Integer)iM.get(file)).intValue();
      }
      IntBuffer ib = BufferUtils.createIntBuffer(1);

      GL11.glGenTextures(ib);
      int id = ib.get(0);

      bind(id);

      GL11.glTexParameteri(3553, 10241, m);
      GL11.glTexParameteri(3553, 10240, m);

      BufferedImage bi = ImageIO.read(file);
      int w = bi.getWidth();
      int h = bi.getHeight();

      ByteBuffer ppi = BufferUtils.createByteBuffer(w * h * 4);
      int[] rPs = new int[w * h];
      bi.getRGB(0, 0, w, h, rPs, 0, w);
      for (int i = 0; i < rPs.length; i++)
      {
        int a = rPs[i] >> 24 & 0xFF;
        int r = rPs[i] >> 16 & 0xFF;
        int g = rPs[i] >> 8 & 0xFF;
        int b = rPs[i] & 0xFF;

        rPs[i] = (a << 24 | b << 16 | g << 8 | r);
      }
      ppi.asIntBuffer().put(rPs);
      GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, ppi);

      return id;
    }
    catch (IOException e)
    {
      throw new RuntimeException("!!");
    }
  }

In Particular, Focus on These Lines;

catch (IOException e)
{
  throw new RuntimeException("!!");
}

I Have Attempted to Eliminate the throw new RuntimeException line, but then Eclipse prompts me with a missing return statement error. However, keeping this code results in the aforementioned error and program crashing.

LWJGL is being used within Eclipse. This section of code aims to load a texture file for specific assignments.

Any insight into the issue, its causes, possible fixes, or clarifications are greatly appreciated. Instead of downvoting, please leave a comment if something needs further explanation.

Thank you!

EDIT: Credit to @RobHruska and @dhamibirendra for suggesting using e.printStackTrace().

Updated Error Log Provided Below:

javax.imageio.IIOException: Can't read input file!
    at javax.imageio.ImageIO.read(Unknown Source)
    at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:38)
    at com.PoseidonTechnologies.caveworld.level.Ch.<clinit>(Ch.java:20)
    at com.PoseidonTechnologies.caveworld.level.WoRe.<init>(WoRe.java:46)
    at com.PoseidonTechnologies.caveworld.CaveWorld.start(CaveWorld.java:80)
    at com.PoseidonTechnologies.caveworld.CaveWorld.main(CaveWorld.java:303)
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.PoseidonTechnologies.caveworld.level.WoRe.<init>(WoRe.java:46)
    at com.PoseidonTechnologies.caveworld.CaveWorld.start(CaveWorld.java:80)
    at com.PoseidonTechnologies.caveworld.CaveWorld.main(CaveWorld.java:303)
Caused by: java.lang.RuntimeException: javax.imageio.IIOException: Can't read input file!
    at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:62)
    at com.PoseidonTechnologies.caveworld.level.Ch.<clinit>(Ch.java:20)
    ... 3 more
Caused by: javax.imageio.IIOException: Can't read input file!
    at javax.imageio.ImageIO.read(Unknown Source)
    at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:38)
    ... 4 more

It seems there's an issue reading the picture file.

This Line Appears to be Requesting it (I believe):

private void rebuild(int l) {
    if (rTF == 2) {
      return;
    }
    this.m = false;

    u += 1;

    rTF += 1;

    GL11.glNewList(this.l + l, 4864);
    GL11.glEnable(3553);
    GL11.glBindTexture(3553, tex);
    teb.init();
    @SuppressWarnings("unused")
int tiles = 0;
    for (int x = this.x0; x < this.x1; x++) {
      for (int y = this.y0; y < this.y1; y++) {
        for (int z = this.z0; z < this.z1; z++) {
          if (this.wo.isT(x, y, z)) {
            int tex = y == this.wo.d * 2 / 3 ? 0 : 1;
            tiles++;
            if (tex == 0) {
              Ti.stone.render(teb, this.wo, l, x, y, z);
            }else{
              Ti.grass.render(teb, this.wo, l, x, y, z);
            }
          }
        }
      }
    }
    teb.flush();
    GL11.glDisable(3553);
    GL11.glEndList();
  }

The integer "tex" is defined as follows:

private static int tex = Tea.loT("groundtex.png", 9728);

Answer №1

Your code should be functioning correctly and throwing exceptions as intended. The ExceptionInInitializer indicates that an unexpected exception has occurred during static initialization.

This suggests that there may be an issue at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:61).

Please review the contents of that line as it appears to be causing trouble. You can try the following:

catch (IOException e)
{
  e.printStackTrace();
  throw new RuntimeException("!!");
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Performing mathematical computations through a mixin without relying on inline javascript code

Looking to enhance my web app with a mixin that shows a list of entries, each with a time stamp indicating how long ago it was posted. mixin listTitles(titles) each title in titles article.leaf article a.headline(href=title.URL)= title.t ...

Picture is unavailable for viewing - (Express, Pugjs)

I'm having trouble getting an image to display on my page using a pug template. Despite following the setup and files correctly, the image still isn't showing up. Here is what I have: index.js app.use('/images', express.static(path.r ...

What is the best approach for managing multiple HTTP requests in my specific situation?

I have a query about handling multiple HTTP requests in my code to ultimately get the desired result. Here is an outline of my approach: var customer[]; var url = '/api/project/getCustomer'; getProject(url) .then(function(data){ ...

FullPage.js combines traditional scrolling with a unique horizontal slider feature

Visit this link for the example. Hello, I have a question regarding this example: Is there a way to disable the automatic scrolling that occurs when reaching the middle of a page? Also, I am having trouble with the horizontal slider not responding to ...

Having trouble rendering the response text from the API fetched in Next.js on a webpage

I've written some code to back up a session border controller (SBC) and it seems to be working well based on the output from console.log. The issue I'm facing is that the response comes in as a text/ini file object and I'm unable to display ...

Error encountered when WebDriverIO attempted to connect to Appium due to a lack of compatible capabilities

I'm currently facing an issue while attempting to link my virtual Android Device through Appium with my Webdriverio script for the purpose of automating some testing tasks. Here are the capabilities that I have set: capabilities: [{ // N ...

Modifying properties within child components

Within my parent Vue Page, I have inserted a FormInput component inside my form. new.vue <b-form @submit.prevent="submit"> <FormInput :name="name"/> <b-button @click="submit">Save</b-button> <b-form> <script> i ...

Effortlessly transforming a massive JSON into an Array using ReactJS

I have a large JSON dataset containing information on over 2000 cities. I want to use this data in my React app, but first I need to convert it into an array. A similar question has been asked before, but I couldn't find any answers that fit my specif ...

Error: Attempting to access 'scrollTop' property of null object in Material UI library

After updating from MUI-4 to MUI-5, I encountered this error. Can anyone provide assistance? ...

The process of organizing and arranging the content that appears on a webpage is in

Seeking a solution to achieve a similar effect like this example. Wanting the sections to transition nicely when clicked on. Should I use a Jquery plugin or implement it with CSS? ...

Issue with Three.js failing to display textures

I'm a beginner with three.js and I'm struggling to get my texture to render properly in my scene. Despite following the documentation closely, all I see is a blank canvas with no errors in the console. Can anyone offer any guidance on why my code ...

What is the procedure for closing a snackbar when the close button is clicked?

I am having trouble closing a snackbar when the close button is clicked. The snackbar should initially pop up on page load and only close when manually triggered. I have set the timeout to zero, but the snackbar does not close when the close button is clic ...

Adding jQuery namespace to AngularJS

I'm facing a bit of an issue here. I've implemented RequireJS to manage my modules and dependencies. To prevent cluttering the global namespace, I've set up the following configuration to avoid declaring $ or jQuery globally: require.confi ...

How can I simulate an `Error` without it being displayed in the console or halting the entire file execution in JavaScript?

Is it possible to log an error and continue running the file without interruptions? I would like a way to achieve something similar to throwing an error but keep the file running smoothly like with console.log. Any suggestions on how to accomplish this? ...

Is NextJS Route Handler in Version 13 Really Secure?

Within my forthcoming NextJS 13 web application, I am in the process of integrating an API through route handlers to facilitate functions like user registration and login procedures. Is it considered safe when transmitting sensitive data like a user's ...

By default, the HTML table will highlight the specific column based on the current month using either AngularJS or JavaScript upon loading

I am working with a table of 10 products and their monthly sales data. Using Angular JS, I am looking to highlight the entire column based on the current month and year. Additionally, we will also be incorporating future expected sales data into the table. ...

Discovering the earliest and latest dates within an array of date strings

My data consists of an array filled with objects like this data = [ { mas_name: (...), mas_plan_end: (...) // 'YYYY-MM-DD' eg: '2021-03-19' mas_plan_start: (...) // 'YYYY-MM-DD' eg: '2021-03-19' ... }, { ...

Issue with Passing 'key' Prop to React Component in a Mapped Iteration

I'm struggling with adding a key prop to a React component in a mapped array within a Next.js project. The issue lies in a Slider component and an array of Image components being mapped. Even though I have provided a unique key for each element in the ...

Determine the total hours and minutes elapsed between two specific dates and times

Looking for some assistance here. I have a form where users need to input a start time and end time of an incident. After entering this information, they would manually calculate the duration between the two date times. I am attempting to streamline this p ...

Button component in React remains visible until interacted with

https://i.stack.imgur.com/gTKzT.png I'm dealing with a sign out component in my app that requires me to click on it specifically to unselect any part of the application. This is implemented using React Material UI. <MenuItem onClick={e => this ...