ObjectDB ObjectDB

Filename.odb$ Persisting Issue

#1

Hi,

I seem to have a frequent issue with my Filename.odb$ remaining in my /db directory after my program terminates which prevents me from running my program again due to a persistence error thrown by Eclipse. I can't seem to manually terminate the file either. I usually have to fully close Eclipse and wait a bit for it to remove itself. Any ideas why this happens?

Thanks,
Dragon

edit
delete
#2

This may happen if the EntityManagerFactory (or PersistenceManagerFactory if you use JDO) is not closed before exiting the application.

ObjectDB Support
edit
delete
#3

I'm programming this in JavaFX and have a main function that looks like this...

public static void main(String[] args)
{
  launch(args); 
  departmentDB.close();
  employeeDB.close();
  paygradeDB.close();
  programDB.close();
  supervisorDB.close();
  programImportDB.close();
  shiftImportDB.close();
  emf.close();
}

I create the EMF and EM's as globals to my class - so I assume this should work?

Termination of the application is handled by using the standard 'x' on the scene window.

To my understanding this should terminate the hold on launch(args) and begin closing the EM's and EMF, no?

edit
delete
#4

If emf this is the only EntityManagerFactory instance in your application verify that emf.close is indeed reached and executed (e.g. using a debugger or printing to log o console). It will not be reached and executed if the application is terminated with System.exit.

ObjectDB Support
edit
delete
#5

Sorry for the delay in response time - been busy with other projects.

I've tested this out now and all the EM's and the EMF close according to my test (below)

public static void main(String[] args)
{
  launch(args);
  departmentDB.close();
  employeeDB.close();
  paygradeDB.close();
  programDB.close();
  supervisorDB.close();
  programImportDB.close();
  shiftImportDB.close();
  emf.close();
 
  System.out.println("   departmentDB CLOSED: " + !departmentDB.isOpen());
  System.out.println("     employeeDB CLOSED: " + !employeeDB.isOpen());
  System.out.println("     paygradeDB CLOSED: " + !paygradeDB.isOpen());
  System.out.println("   supervisorDB CLOSED: " + !supervisorDB.isOpen());
  System.out.println("programImportDB CLOSED: " + !programImportDB.isOpen());
  System.out.println("  shiftImportDB CLOSED: " + !shiftImportDB.isOpen());
  System.out.println("            emf CLOSED: " + !emf.isOpen());
}

Output is true for all of those.

So i'm still a bit confused on why this file lingers and why I can't delete it without waiting for it to kill itself?

edit
delete
#6

Please try to isolate the issue and post a small runnable program (with no external dependencies) that can demonstrate it.

ObjectDB Support
edit
delete
#7

This is as simple as I can make it.

public class Main extends Application
{
 private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("$objectdb/db/payrollDB - Copy0.odb");
 public  static EntityManager departmentDB = emf.createEntityManager();
 public  static EntityManager employeeDB = emf.createEntityManager();
 public  static EntityManager paygradeDB = emf.createEntityManager();
 public  static EntityManager programDB = emf.createEntityManager();
 public  static EntityManager supervisorDB = emf.createEntityManager();
 public  static EntityManager programImportDB = emf.createEntityManager();
 public  static EntityManager shiftImportDB = emf.createEntityManager();

 private static Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();

 private static Stage dialogStage = new Stage();

 private static Stage primaryStage;
 private static BorderPane rootLayout;
 
 @Override
 public void start(Stage stage)
 {
  primaryStage = stage;
  primaryStage.setResizable(false);
 
  initRootLayout();
 
  showMainMenu();
 }

 private void initRootLayout()
 {
  try
  {
   FXMLLoader loader = new FXMLLoader();
   loader.setLocation(Main.class.getResource("view/RootLayout.fxml"));
   rootLayout = (BorderPane) loader.load();

   Scene scene = new Scene(rootLayout);
   primaryStage.setScene(scene);
   primaryStage.show();
  }
  catch (IOException e)
   {e.printStackTrace();}
 }

 public static void showMainMenu()
 {
  try
  {
   if(dialogStage.isShowing())
   dialogStage.close();
  
   FXMLLoader loader = new FXMLLoader();
   loader.setLocation(Main.class.getResource("view/MainMenu.fxml"));
   GridPane mainMenu = (GridPane) loader.load();

   rootLayout.setCenter(mainMenu);
   primaryStage.setHeight(rootLayout.getMinHeight() + mainMenu.getMinHeight());
   if(mainMenu.getMinWidth() > rootLayout.getMinWidth())
    primaryStage.setWidth(mainMenu.getMinWidth());
   else
    primaryStage.setWidth(rootLayout.getMinWidth());

   primaryStage.setX((screenBounds.getWidth() - primaryStage.getWidth()) / 2);
   primaryStage.setY((screenBounds.getHeight() - primaryStage.getHeight()) / 2);
  }
  catch (IOException e)
   {e.printStackTrace();}
 }

 public static void main(String[] args)
 {
  launch(args);
  departmentDB.close();
  employeeDB.close();
  paygradeDB.close();
  programDB.close();
  supervisorDB.close();
  programImportDB.close();
  shiftImportDB.close();
  emf.close();
 }
}

I cannot/don't know how to remove external dependencies at this point since I use FXML files for all my UI.

The problem I'm describing can happen just by starting and stopping the program in quick succession or after running it for extended time, stopping the program, and modifying code for extended time and all variations in between. There is no way to isolate the issue directly as there is no consistent pattern or trigger. I can provide you the stack trace when it happens, but it's ultimately all related to the fact that this [filename].odb$ file exists for some reason (unknown to me) and doesn't always get removed when the application is terminated.

At no point do I use System.exit() nor do I use hard termination from my Eclipse IDE. Each time the application is terminated it is done so by using the 'X' on the window produced.

edit
delete
#8

This test case is neither runnable (cannot compile due to missing import statements) nor minimal (are 7 database connections really required to demonstrate the issue?).

> but it's ultimately all related to the fact that this [filename].odb$ file exists for some reason (unknown to me) and doesn't always get removed when the application is terminated.

This is the recovery file and you can disable recovery if you want, although not recommended, and then you will not have this file at all.

The recovery file is removed when the EntityManagerFactory is closed, but apparently your application occasionally exits without closing the EntityManagerFactory (or completing the main method). Unfortunately this is not something that we can solve or help with. Check the ObjectDB log file to see if every database opening is followed by closing it.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.