1

I have a problem with my API. For one of my school project, I needed to send my project in a Eclipse workspace. But i coded it on IntelliJ because I prefer it. When I want to pass my code on Eclipse, the project doens't work so I maked a new project and put my code inside. But at the moment, I cannot acces on this API because I have a nullPointerException. The nullPointerException is on my DAO and on IntelliJ it's working. so the error is:

Servlet.service() for servlet access.RestApplication threw exception
java.lang.NullPointerException
at model.dao.DaoComment.getAll(DaoComment.java:150)
at access.CommentAPI.getAll(CommentAPI.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

The DAO is like that:

@Override
public List<User> getAll() {
CallableStatement stmt = null;
List<User> users = new ArrayList<>();
ResultSet resultSet = null;
try {
  stmt = connect.prepareCall("{? = call USERPACKAGE.getAll}");
  stmt.registerOutParameter(1, OracleTypes.CURSOR);
  stmt.execute();
  resultSet = (ResultSet) stmt.getObject(1);
  if (resultSet != null) {
    while (resultSet.next()) {
      User u = new User();
      u.setId(resultSet.getInt(1));
      u.setEmail(resultSet.getString(2));
      u.setPassword(resultSet.getString(3));
      u.setFirstname(resultSet.getString(4));
      u.setLastname(resultSet.getString(5));
      u.setAddress(resultSet.getString(6));
      u.setBirthday(resultSet.getTimestamp(7));
      u.setRegisterDate(resultSet.getTimestamp(8));
      u.setRelationship(resultSet.getInt(9) == 1);
      u.setPhoneNumber(resultSet.getInt(10));
      u.setGender(resultSet.getInt(11) == 1);
      u.setInterestedIn(resultSet.getInt(12) == 1);
      users.add(u);
    }
  }

} catch (SQLException e) {
  e.printStackTrace();
  return null;
} finally {
  if (stmt != null) {
    try {
      stmt.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
  if (resultSet != null) {
    try {
      resultSet.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
}
return users;

Normally after it I take the data and send it by json but here it's not working. the exception stack trace is:

java.util.MissingResourceException: Can't find bundle for base name sun.util.logging.resources.logging, locale en_US
at java.base/java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.base/java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.base/java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.base/java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.base/java.util.ResourceBundle.getBundle(Unknown Source)
at org.eclipse.glassfish.tools.log.LevelResolver.getLocalized(LevelResolver.java:49)
at org.eclipse.glassfish.tools.log.LevelResolver.<init>(LevelResolver.java:31)
at org.eclipse.glassfish.tools.log.AbstractLogFilter.<init>(AbstractLogFilter.java:36)
at org.eclipse.glassfish.tools.log.PatternLogFilterV4.<init>(PatternLogFilterV4.java:32)
at org.eclipse.glassfish.tools.log.AbstractLogFilter.createFilter(AbstractLogFilter.java:75)
at org.eclipse.glassfish.tools.log.GlassfishConsoleManager.getStandardConsole(GlassfishConsoleManager.java:53)
at org.eclipse.glassfish.tools.GlassfishServerLaunchDelegate$2.run(GlassfishServerLaunchDelegate.java:390)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3906)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3537)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1170)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1059)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:667)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:597)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:656)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:592)
at org.eclipse.equinox.launcher.Main.run(Main.java:1498)
at org.eclipse.equinox.launcher.Main.main(Main.java:1471)
thelittlewozniak
  • 368
  • 1
  • 8
  • 21

1 Answers1

1

MissingResourceException points out that you are missing a resourcebundle.
Just add a file sun/util/logging/resources/logging_en_US.properties to your project.
The content should look like this:

# Localizations for Level names.  For the US locale
# these are the same as the non-localized level name.

# The following ALL CAPS words should be translated.
ALL=All
# The following ALL CAPS words should be translated.
SEVERE=Severe
# The following ALL CAPS words should be translated.
WARNING=Warning
# The following ALL CAPS words should be translated.
INFO=Info
# The following ALL CAPS words should be translated.
CONFIG= Config
# The following ALL CAPS words should be translated.
FINE=Fine
# The following ALL CAPS words should be translated.
FINER=Finer
# The following ALL CAPS words should be translated.
FINEST=Finest
# The following ALL CAPS words should be translated.
OFF=Off

See also this stackoverflow answer

hce
  • 1,107
  • 9
  • 25