B4J Question B4J Server template 404 error only when packaged

CBruce

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:
B4X:
#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...
B4X:
HTTP ERROR 404
Problem accessing /. Reason:
    Not Found
Powered by Jetty:// 9.4.z-SNAPSHOT

Here is the runtime log:
B4X:
10.10.10.88 - - [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.10.10.88 - - [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"
127.0.0.1 - - [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.10.10.88 - - [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.10.10.88 - - [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:
B4X:
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
Done!

Here is the B4J compile window output:
B4X:
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:
B4X:
C:\dodo>B4JServerTest.exe
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 o.e.j.s.ServletContextHandler@32eebfca{/,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 ServerConnector@1efee8e7{HTTP/1.1,[http/1.1]}{0.0.0.0:80}
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?!?!

Thanks,
CBruce
 

CBruce

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):
"C:\B4J\test_2021-09-10_1419\Objects\temp\build\bin"
"C:\B4J\test_2021-09-10_1419\Objects\temp\build\conf"
"C:\B4J\test_2021-09-10_1419\Objects\temp\build\legal"
"C:\B4J\test_2021-09-10_1419\Objects\temp\build\lib"
"C:\B4J\test_2021-09-10_1419\Objects\temp\build\B4JServerTest.exe"

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.

CBruce
 
Last edited:
Upvote 0
Top