803 words

Filename.odb$ Persisting Issue

#1
2017-09-22 21:07

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

DragonRulerX
DragonRulerX's picture
Joined on 2017-07-26
User Post #11
#2
2017-09-25 08:27

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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,819
#3
2017-09-25 21:46

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?

DragonRulerX
DragonRulerX's picture
Joined on 2017-07-26
User Post #12
#4
2017-09-25 22:40

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,821
#5
2017-10-04 22:13

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?

DragonRulerX
DragonRulerX's picture
Joined on 2017-07-26
User Post #13
#6
2017-10-06 16:36

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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,833
#7
2017-10-06 18:26

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.

DragonRulerX
DragonRulerX's picture
Joined on 2017-07-26
User Post #14
#8
2017-10-08 10:33

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,839

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel