my server is rooted in the public_html folder instead of www
but I get error on this routine
below the generated error
thanks for the support
(sorry for my english I used google translate)
B4X:
public Sub StartServer(srvr As Server, srvrName As String, srvrPort As Int
srvr.Initialize(srvrName)
srvr.StaticFilesFolder = File.Combine(File.DirApp, "public_html")
' uncomment this if you want to directly access the app in the url without having to add the app name
' e.g. 192.168.1.105:51042 or 192.168.1.105 if you are using port 80
srvr.AddFilter( "/", "ABMRootFilter", False )
' NEW V3 Cache Control
srvr.AddFilter("/*", "ABMCacheControl", False)
' NEW 4.00 custom error pages (optional) Needs the ABMErrorHandler class
srvr.SetCustomErrorPages(CreateMap("org.eclipse.jetty.server.error_page.global": "/" & ABMShared.AppName & "/error")) ' OPTIONAL
srvr.AddHandler("/" & ABMShared.AppName & "/error", "ABMErrorHandler", False) ' OPTIONAL
srvr.AddWebSocket("/ws/" & ABMShared.AppName, "ABMApplication")
For i =0 To Pages.Size - 1
srvr.AddWebSocket("/ws/" & ABMShared.AppName & "/" & Pages.Get(i) , Pages.Get(i))
If PageNeedsUpload.Get(i) Then
srvr.AddHandler("/" & ABMShared.AppName & "/" & Pages.Get(i) & "/abmuploadhandler", "ABMUploadHandler", False)
End If
Next
srvr.AddBackgroundWorker("ABMCacheScavenger")
srvr.Port = srvrPort
#If RELEASE
srvr.SetStaticFilesOptions(CreateMap("gzip":True,"dirAllowed":False))
#Else
srvr.SetStaticFilesOptions(CreateMap("gzip":False,"dirAllowed":False))
#End If
srvr.Start
Dim joServer As JavaObject = srvr
joServer.GetFieldJO("server").RunMethod("stop", Null)
joServer.GetFieldJO("context").RunMethodJO("getSessionHandler", Null).RunMethodJO("getSessionCookieConfig", Null).RunMethod("setMaxAge", Array(31536000)) ' 1 year
' NEW FEATURE! Each App has its own Session Cookie
joServer.GetFieldJO("context").RunMethodJO("getSessionHandler", Null).RunMethodJO("getSessionCookieConfig", Null).RunMethod("setName", Array(ABMShared.AppName.ToUpperCase))
joServer.GetFieldJO("server").RunMethod("start", Null)
Dim secs As Long = ABMShared.CacheScavengePeriodSeconds ' must be defined as a long, else you get a 'java.lang.RuntimeException: Method: setIntervalSec not matched.' error
joServer.GetFieldJO("context").RunMethodJO("getSessionHandler", Null).RunMethodJO("getSessionIdManager", Null).RunMethodJO("getSessionHouseKeeper", Null).RunMethod("setIntervalSec", Array As Object(secs))
Dim jo As JavaObject = srvr
Dim connectors() As Object = jo.GetFieldJO("server").RunMethod("getConnectors", Null)
Dim timeout As Long = ABMShared.SessionMaxInactiveIntervalSeconds*1000
For Each c As JavaObject In connectors
c.RunMethod("setIdleTimeout", Array(timeout))
Next
ABMShared.CachedPages = srvr.CreateThreadSafeMap
but I get error on this routine
B4X:
public Sub AddPage(Page As ABMPage)
Pages.Add(Page.Name)
PageNeedsUpload.Add(ABM.WritePageToDisk(Page, File.DirApp & "/public_html/" & ABMShared.AppName & "/" & Page.Name & "/", Page.PageHTMLName, ABMShared.NeedsAuthorization)) 'public_html 'www
End Sub
below the generated error
B4X:
Error occurred on line: 134 (ABMApplication)
java.lang.NullPointerException
at java.base/java.io.File.<init>(File.java:279)
at com.ab.abmaterial.ABMPage.WritePageToDiskPerTheme(ABMPage.java:4739)
at com.ab.abmaterial.ABMPage.WritePageToDisk(ABMPage.java:4433)
at com.ab.abmaterial.ABMaterial.WritePageToDisk(ABMaterial.java:3570)
at com.ab.template.abmapplication._addpage(abmapplication.java:101)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at com.ab.template.main.main(main.java:29)
thanks for the support
(sorry for my english I used google translate)