B4J Question [SOLVED][ABMaterial] Mini Template - should it run as-is?

Andris

Active Member
Licensed User
Longtime User
I followed the instructions exactly as described in the ABMaterial Mini template tutorial and although it says it's for absolute beginners, I can't make it run as-is :rolleyes:. All the necessary libraries are where they should be. What I get in the log is:

2020-05-17 21:14:19.519:INFO::main: Logging initialized @315ms to org.eclipse.jetty.util.log.StdErrLog
Start B4J Analyse!
When an error occurs, check the B4JAnalyse.log file in the Objects folder to see the last B4J line it was working on.
Collecting data from B4J source files... (1/2)
ABMCacheV3.bas
ABMPageTemplate.bas
Template.b4j
Analysing data from B4J source files... (2/2)
loading C:\MINDSP~1\B4J\TEMPLA~1.30\TEMPLA~1.30\Objects: copymewithjar.needs...
Using cache system: 3.0
Needs material/awesome icons
Building C:\MINDSP~1\B4J\TEMPLA~1.30\TEMPLA~1.30\Objects\copymewithjar.js.needs
Building core.min.1589764459374.css...
2020-05-17 21:14:19.766:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 11.0.1+13
2020-05-17 21:14:19.804:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2020-05-17 21:14:19.804:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2020-05-17 21:14:19.806:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2020-05-17 21:14:19.824:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@49dc7102{/,file:///C:/Mindspark/B4J/TemplateMiniV4.30/TemplateMiniV4.30/Objects/www/,AVAILABLE}
2020-05-17 21:14:19.826:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Mindspark\B4J\TemplateMiniV4.30\TemplateMiniV4.30\Objects\logs\b4j-2020_05_18.request.log
abmapplication._startserver (java line: 387)
java.net.BindException: Address already in use: bind
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:461)
at java.base/sun.nio.ch.Net.bind(Net.java:453)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at com.ab.template.abmapplication._startserver(abmapplication.java:387)
at com.ab.template.abmserver._startserver(abmserver.java:413)
at com.ab.template.main._appstart(main.java:79)
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:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at com.ab.template.main.main(main.java:28)
main.main (java line: 28)
java.lang.RuntimeException: java.net.BindException: Address already in use: bind
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at com.ab.template.main.main(main.java:28)
Caused by: java.net.BindException: Address already in use: bind
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:461)
at java.base/sun.nio.ch.Net.bind(Net.java:453)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at com.ab.template.abmapplication._startserver(abmapplication.java:387)
at com.ab.template.abmserver._startserver(abmserver.java:413)
at com.ab.template.main._appstart(main.java:79)
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:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
... 2 more

... and when I go to http://localhost:51042/template, I get an HTTP 404 message.

Can someone tell me what I'm missing?
 

Andris

Active Member
Licensed User
Longtime User
java.net.BindException: Address already in use: bind

This is the important bit. It is a B4J error that says there is already one app running on that port 51042

So how would you proceed here? Just change the port to a different number and hope for the best?
B4X:
Sub AppStart (Args() As String)
    ' must be the first line in AppStart. DO NOT DELETE OR CHANGE!
    ' ------------------------------------------------------------
    ABM.SessionCacheControlV3 = "ABMCacheV3"
    ' ------------------------------------------------------------
   
    Dim DonatorKey As String = ""
    Server.Initialize("", DonatorKey, "template") ' Application = ' the handler that will be used in the url e.g. http://localhost:51042/template
    ' some parameters
    Server.Port = 51042
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
and hope for the best?
Well, I don't know your computer of course and what ports you do use. The point is this not even an ABM problem, as you wouldn't be able to run any B4J jServer app (or any app in any language for that matter) running on port 51042 because it is already in use by something.

I would use a tool like TCPView (https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview) and try to find out what is already running on this port. If it is something that you don't know, it may be some Trojan using that port.
 
Upvote 0

Andris

Active Member
Licensed User
Longtime User
Well, I don't know your computer of course and what ports you do use. The point is this not even an ABM problem, as you wouldn't be able to run any B4J jServer app (or any app in any language for that matter) running on port 51042 because it is already in use by something.

I would use a tool like TCPView (https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview) and try to find out what is already running on this port. If it is something that you don't know, it may be some Trojan using that port.

Happy to report success. I had in fact used a tool and discovered that something else was occupying 51042. Restarting my laptop removed it and now Mini Template executes as it should. My theory is that in trying to get it to work, I had already an instance of it running, but incorrectly, and it remained even after restarting B4J. Would that make sense?
 
Upvote 0
Top