tchart Well-Known Member Licensed User Longtime User Aug 29, 2017 #1 Im not sure if this is related to 5.9 Beta 1 or not. I am compiling a project to a library. I have two variables defined in Process_Globals in a code module. Code: Sub Process_Globals Dim SQLDirectory As String = File.DirApp Dim SQLFileName As String = "esri_patches.sqlite" End Sub However Im getting a file not found exception when I try to access the sqlite file. I tried to log the variables but the variables dont show in the Log. I reviewed the derived Java code and the resulting JAR and the global variables are set to empty! See the attached file.
Im not sure if this is related to 5.9 Beta 1 or not. I am compiling a project to a library. I have two variables defined in Process_Globals in a code module. Code: Sub Process_Globals Dim SQLDirectory As String = File.DirApp Dim SQLFileName As String = "esri_patches.sqlite" End Sub However Im getting a file not found exception when I try to access the sqlite file. I tried to log the variables but the variables dont show in the Log. I reviewed the derived Java code and the resulting JAR and the global variables are set to empty! See the attached file.
tchart Well-Known Member Licensed User Longtime User Aug 29, 2017 #2 Ah actually I do see at the end of the class code the variables are set but for some reason they are empty when I try to access them. Code: public static String _process_globals() throws Exception { _sqldirectory = File.getDirApp(); _sqlfilename = "esri_patches.sqlite"; return ""; } Upvote 0
Ah actually I do see at the end of the class code the variables are set but for some reason they are empty when I try to access them. Code: public static String _process_globals() throws Exception { _sqldirectory = File.getDirApp(); _sqlfilename = "esri_patches.sqlite"; return ""; }
Erel B4X founder Staff member Licensed User Longtime User Aug 30, 2017 #3 Can you upload the library? Upvote 0
tchart Well-Known Member Licensed User Longtime User Sep 5, 2017 #4 Erel said: Can you upload the library? Click to expand... @Erel here you go, sorry about the delay. To explain, the web server project loads a Jar (b4j library) at run time and creates a background worker thread. The background worker calls a sub in a code module and its that process globals which arent being set. Attachments test_for_erel.zip test_for_erel.zip 8 KB · Views: 510 Upvote 0
Erel said: Can you upload the library? Click to expand... @Erel here you go, sorry about the delay. To explain, the web server project loads a Jar (b4j library) at run time and creates a background worker thread. The background worker calls a sub in a code module and its that process globals which arent being set.
Erel B4X founder Staff member Licensed User Longtime User Sep 5, 2017 #5 The bug is in jarLoader library not in B4J. Why aren't you loading the library like any other library? Upvote 0
The bug is in jarLoader library not in B4J. Why aren't you loading the library like any other library?
tchart Well-Known Member Licensed User Longtime User Sep 5, 2017 #6 @Erel, I've split my web server project into separate b4j libraries that I load at runtime (when the server starts). I've done this to make it easier to maintain the code and be able to deploy individual updates to the libraries rather than a 100mb jar file (like I used to). The jarLoader works as far as I can tell as the library/jar is loaded and I can add the background thread class, handler classes, filters etc. I suspect the issue may be a limitation of the approach. I dont know the lifecycle of Process Globals. Maybe because there is no process there is no Process Globals for the loaded library or the class path is wrong - but I can call DoUpdate just fine so I dont know. I've got a work around for now but it would be good to know either if its a bug or limitation of the way Im doing things. Upvote 0
@Erel, I've split my web server project into separate b4j libraries that I load at runtime (when the server starts). I've done this to make it easier to maintain the code and be able to deploy individual updates to the libraries rather than a 100mb jar file (like I used to). The jarLoader works as far as I can tell as the library/jar is loaded and I can add the background thread class, handler classes, filters etc. I suspect the issue may be a limitation of the approach. I dont know the lifecycle of Process Globals. Maybe because there is no process there is no Process Globals for the loaded library or the class path is wrong - but I can call DoUpdate just fine so I dont know. I've got a work around for now but it would be good to know either if its a bug or limitation of the way Im doing things.
Erel B4X founder Staff member Licensed User Longtime User Sep 5, 2017 #7 tchart said: I've done this to make it easier to maintain the code and be able to deploy individual updates to the libraries rather than a 100mb jar file (like I used to). Click to expand... This is not the correct solution. The correct solution is to set #MergeLibraries to False and then upload the libraries. This allows you to update whichever library you like separately. Upvote 0
tchart said: I've done this to make it easier to maintain the code and be able to deploy individual updates to the libraries rather than a 100mb jar file (like I used to). Click to expand... This is not the correct solution. The correct solution is to set #MergeLibraries to False and then upload the libraries. This allows you to update whichever library you like separately.
tchart Well-Known Member Licensed User Longtime User Sep 5, 2017 #8 Erel said: This is not the correct solution. The correct solution is to set #MergeLibraries to False and then upload the libraries. This allows you to update whichever library you like separately. Click to expand... Thanks Erel, just to point out the libraries Im referring to are not classic b4j libraries per se (not like jdbc etc). The project that becomes the library Im referring to is just an empty main with a collection of web Server Handlers, Server Filters and Standard Classes (for background threads). It does not add functionality like a normal library it just separates my main web server project from the handlers and makes it easy to update the handlers in isolation. As far as I can see there isn't a way to do this with normal b4j libraries, hence the solution to load the jars at runtime. If there is another way to do this I'd happily listen to any advice. Upvote 0
Erel said: This is not the correct solution. The correct solution is to set #MergeLibraries to False and then upload the libraries. This allows you to update whichever library you like separately. Click to expand... Thanks Erel, just to point out the libraries Im referring to are not classic b4j libraries per se (not like jdbc etc). The project that becomes the library Im referring to is just an empty main with a collection of web Server Handlers, Server Filters and Standard Classes (for background threads). It does not add functionality like a normal library it just separates my main web server project from the handlers and makes it easy to update the handlers in isolation. As far as I can see there isn't a way to do this with normal b4j libraries, hence the solution to load the jars at runtime. If there is another way to do this I'd happily listen to any advice.
Erel B4X founder Staff member Licensed User Longtime User Sep 5, 2017 #9 I've moved the thread to the questions forum. Unless I'm missing something I don't understand why do you need to do anything special to load the libraries. Compile the relevant project to a library and then reference that library in the server project. That's all. Make sure that #MergeLibraries is set to False if you want to be able to update each jar separately. Upvote 0
I've moved the thread to the questions forum. Unless I'm missing something I don't understand why do you need to do anything special to load the libraries. Compile the relevant project to a library and then reference that library in the server project. That's all. Make sure that #MergeLibraries is set to False if you want to be able to update each jar separately.
tchart Well-Known Member Licensed User Longtime User Sep 5, 2017 #10 @Erel, thanks I modified the project I posted to load the library as you suggested and you the process globals can be accessed! I will change my approach. As an aside, do you know why one method would work and not the other? The behaviour seems specific to process globals as I can access other functions in the classes from the loaded library. So its a bit odd. Upvote 0
@Erel, thanks I modified the project I posted to load the library as you suggested and you the process globals can be accessed! I will change my approach. As an aside, do you know why one method would work and not the other? The behaviour seems specific to process globals as I can access other functions in the classes from the loaded library. So its a bit odd.
Erel B4X founder Staff member Licensed User Longtime User Sep 5, 2017 #11 B4J compiler does all kinds of things with referenced libraries. Upvote 0
tchart Well-Known Member Licensed User Longtime User Sep 5, 2017 #12 Oh I see it now, the main class is calling initializeProcessGlobals() which is calling my_code_module._process_globals(); So yes a limitation of what Im doing... Upvote 0
Oh I see it now, the main class is calling initializeProcessGlobals() which is calling my_code_module._process_globals(); So yes a limitation of what Im doing...