B4J Question B4J Server template 404 error only when packaged


New Member
Note: I'm brand new to B4X and Java

I'm starting simple... downloaded, installed, launched, and setup B4J.exe (with B4X OpenJDK)... and chose a [New][Server] project.

The only two changes I made:
#PackagerProperty: ExeName = B4JServerTest
    'srvr.Port = 51042
    srvr.Port = 80

Everything works fine if I run the server inside the IDE - no problem to connect with a local or remote web browser and play "Guess My Number".

And I am able to successfully package the project with no errors.

But the packaged version of the project fails when I try to connect from a browser...
Problem accessing /. Reason:
    Not Found
Powered by Jetty:// 9.4.z-SNAPSHOT

Here is the runtime log:
B4X: - - [10/Sep/2021:20:38:43 +0000] "GET / HTTP/1.1" 404 315 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0" - - [10/Sep/2021:20:38:48 +0000] "GET / HTTP/1.1" 404 315 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0" - - [10/Sep/2021:20:38:58 +0000] "GET / HTTP/1.1" 404 315 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0" - - [10/Sep/2021:23:22:52 +0000] "GET / HTTP/1.1" 404 315 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0" - - [10/Sep/2021:23:38:05 +0000] "GET / HTTP/1.1" 404 315 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"

Here is the B4J packaging log:
B4JPackager11 Version 1.40
Exe name: B4JServerTest.exe
build folder: C:\B4J\TEST_2~1\Objects\temp\build
InputJar: C:\B4J\test_2021-09-10_1419\Objects\result.jar
Running: C:\B4J\TEST_2~1\Objects\temp\FindDosPath.exe
Running: C:\Java\jdk-11.0.1\bin\jar
Non-UI program
Package name: b4j.test_20210910_1419
Running: C:\Java\jdk-11.0.1\bin\jdeps
Explicitly excluded modules: [javafx.web]
Included modules: [java.base, java.desktop, java.instrument, java.logging, java.management, java.management.rmi, java.naming, java.rmi, java.security.jgss, java.sql, java.xml, javafx.base, javafx.graphics, java.scripting, jdk.unsupported, java.datatransfer, jdk.unsupported.desktop, javafx.controls, javafx.media, jdk.jsobject, jdk.xml.dom]
Running: C:\Java\jdk-11.0.1\bin\javac
Running: C:\Java\jdk-11.0.1\bin\jar
Running: C:\Java\jdk-11.0.1\bin\jlink
Running: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe
Running: explorer.exe

Here is the B4J compile window output:
B4J Version: 9.10
Parsing code.    (0.00s)
    Java Version: 11
Building folders structure.    (0.02s)
Compiling code.    (0.01s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    (2.11s)
Building jar file.    (1.85s)
    Jar file created: C:\B4J\test_2021-09-10_1419\Objects\result.jar
Building package. Check logs for more information.    (24.77s)
Completed successfully.

Here is the command window output when starting the packaged server:
C:\dodo>2021-09-10 18:22:45.668:INFO::main: Logging initialized @594ms to org.eclipse.jetty.util.log.StdErrLog
2021-09-10 18:22:45.883:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 11.0.1+13
2021-09-10 18:22:45.912:WARN:oejh.MimeTypes:main: Missing mime-type resource: org/eclipse/jetty/http/mime.properties
2021-09-10 18:22:45.913:WARN:oejh.MimeTypes:main: Missing encoding resource: org/eclipse/jetty/http/encoding.properties
2021-09-10 18:22:45.966:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2021-09-10 18:22:45.966:INFO:oejs.session:main: No SessionScavenger set, using defaults
2021-09-10 18:22:45.969:INFO:oejs.session:main: node0 Scavenging every 600000ms
2021-09-10 18:22:45.997:INFO:oejsh.ContextHandler:main: Started [email protected]{/,file:///C:/dodo/bin/www,AVAILABLE}
2021-09-10 18:22:46.009:INFO:oejs.AbstractNCSARequestLog:main: Opened C:\dodo\bin\logs\b4j-2021_09_10.request.log
2021-09-10 18:22:46.113:INFO:oejs.AbstractConnector:main: Started [email protected]{HTTP/1.1,[http/1.1]}{}
2021-09-10 18:22:46.117:INFO:oejs.Server:main: Started @1054ms

I'm obviously hitting the packaged Jetty web server - but I have no idea where to start troubleshooting the 404 error... help?!?!



New Member
I don't see a way to edit my OP subject title to say [Solved?] - (maybe limited because I'm a newbie here), but it is sort of solved...

I originally just copied these folders and file to "C:\dodo" folder to run the server (per the packager instructions in the forum):

I've been playing around with this and I just found I can make it work if I also copy the generated "C:\B4J\test_2021-09-10_1419\Objects\www" folder to the "C:\dodo\bin" folder.

I didn't see that anywhere in any of the directions, so I don't know if this is the correct solution, a good/bad practice, or if I am only having to do this because I made a mistake somewhere else.

Last edited:
Upvote 0