Share My Creation [Project Template] [Web] API Server

Nick McCulloch

Member
Licensed User
Hi,

Just tried to set this up but I get a bunch of errors in the creation of the sqlite db as follows:

Waiting for debugger to connect...
Program started.
Reading file (E:\Projects\B4J\WAFolder\WebApi\Objects\config.ini)...
Reading file (E:\Projects\B4J\WAFolder\WebApi\Objects\queries-sqlite.ini)...
2022-03-06 15:52:14.422:INFO::main: Logging initialized @625ms to org.eclipse.jetty.util.log.StdErrLog
Checking database...
Database not found!
Creating database...
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near ",": syntax error)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.throwex(DB.java:374)
at org.sqlite.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.PrepStmt.<init>(PrepStmt.java:42)
at org.sqlite.Conn.prepareStatement(Conn.java:404)
at org.sqlite.Conn.prepareStatement(Conn.java:399)
at org.sqlite.Conn.prepareStatement(Conn.java:383)
at anywheresoftware.b4j.objects.SQL$2.run(SQL.java:264)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
2022-03-06 15:52:26.385:INFOejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 11.0.1+13
2022-03-06 15:52:26.408:INFOejs.session:main: DefaultSessionIdManager workerName=node0
2022-03-06 15:52:26.408:INFOejs.session:main: No SessionScavenger set, using defaults
2022-03-06 15:52:26.409:INFOejs.session:main: node0 Scavenging every 660000ms
2022-03-06 15:52:26.413:INFOejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@482bce4f{/,file:///E:/Projects/B4J/WAFolder/WebApi/Objects/www/,AVAILABLE}
2022-03-06 15:52:26.416:INFOejs.AbstractNCSARequestLog:main: Opened E:\Projects\B4J\WAFolder\WebApi\Objects\logs\b4j-2022_03_06.request.log
2022-03-06 15:52:26.561:INFOejs.AbstractConnector:main: Started ServerConnector@32b260fa{HTTP/1.1,[http/1.1]}{0.0.0.0:19800}
2022-03-06 15:52:26.561:INFOejs.Server:main: Started @12767ms
Emulated network latency: 100ms
Web API server (version = 1.11) is running on port 19800
Open the following URL from your web browser
Database creation failed!


This is using sqlite-jdbc-3.7.2 , can anyone help?

Nick
 

rasaliad

Member
Licensed User
Longtime User
Hi,

I'm try to compile a project with Web API Template and get this error:

B4J Version: 9.30
Parsing code. (0.02s)
Java Version: 11
Building folders structure. (0.01s)
Compiling code. (0.02s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
src\b4j\webapi\corsfilter.java:6: error: package jakarta.servlet does not exist
import jakarta.servlet.DispatcherType;
^
1 error

javac 11.0.1


Thanks in advanced


Rafael
 

rasaliad

Member
Licensed User
Longtime User
Thanks rosippc64a

I downloaded the jar from the link you give to me, but the error persist.

I download and put in (I put in the Libraries folder first, but not work):



where i have to copy the .jar file?

Thanks
 

aeric

Expert
Licensed User
Longtime User
Edit: Sorry, I forgot to mention about I updated to new jServer 4. I update the first post.
 
Last edited:

rasaliad

Member
Licensed User
Longtime User
thanks aeric

Yes I begin to use Web API Template today. I'm using the last version



And I'm using the jServer V4.0



The Web API compile Ok if I comment the jakarta import lines and uncomment the javax importe lines in the CorsFilter file.



the error reported using the jakarta import when compiling is:


B4J Version: 9.30
Parsing code. (0.02s)
Java Version: 11
Building folders structure. (0.01s)
Compiling code. (0.02s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
src\b4j\webapi\corsfilter.java:6: error: package jakarta.servlet does not exist
import jakarta.servlet.DispatcherType;
^
1 error

javac 11.0.1

What i'm doing wrong?

Thanks again.

Rafael
 

aeric

Expert
Licensed User
Longtime User
I need to double check. At the meantime, can you try find previous version β€œweb api.b4xtemplate” from GitHub v1.11 and use jServer v3.0 ?
 

rasaliad

Member
Licensed User
Longtime User
I need to double check. At the meantime, can you try find previous version β€œweb api.b4xtemplate” from GitHub v1.11 and use jServer v3.0 ?
thanks aeirc

For now i'm using your web api commenting the import in the CorsFilter file, like this:

import javax.servlet.DispatcherType;
import javax.servlet.Filter;
//import jakarta.servlet.DispatcherType;
//import jakarta.servlet.Filter;

and it is working. Is there any problem doing that?

thanks
 

aeric

Expert
Licensed User
Longtime User
If it is working with this workaround, then you can treat it as a solution. jServer 4.0 is consider a beta so it is optional to upgrade. In case there is an issue, just fall back to the stable version. It is my mistake before go through more testing. You also can exclude the Cors module as it is an additional feature. The Web API can work without this piece.
 

aeric

Expert
Licensed User
Longtime User
Thanks rosippc64a

I downloaded the jar from the link you give to me, but the error persist.

I download and put in (I put in the Libraries folder first, but not work):

View attachment 130532

where i have to copy the .jar file?

Thanks
By the way, I don’t recommend to download the library from different source.
Please download the library provided by Erel in the jServer v4.0 link.
 

rasaliad

Member
Licensed User
Longtime User
By the way, I don’t recommend to download the library from different source.
Please download the library provided by Erel in the jServer v4.0 link.
Hi

Yes i download from Erel post. Thansk for the advice.
 

aeric

Expert
Licensed User
Longtime User
It seems your jServer folder is different from mine.

 

aeric

Expert
Licensed User
Longtime User
I am unable to reproduce your error. I noticed you are still using B4J version 9.30. Maybe that is the issue. I am using B4J version 9.50 and version 9.80 will be released very soon. You should use more recent version.

I also mentioned that your jServer files also different from mine. Please try to use the new jServer.jar from here or wait for B4J version 9.80.
 

aeric

Expert
Licensed User
Longtime User
Updates:
25/08/2022
- Web API Server - v1.13
- Home page with Add, Edit and Delete Product (using Bootstrap modal and jQuery Validate)
- Help or API documentation page improvements
- Many variables and SQL commands are renamed!
- SQLite version point to sqlite-jdbc-3.39.2.0
- Separate Category and Product handlers
- FindHandler added for more search endpoints
- Endpoints structure changed!
- Warning: This version is not compatible with Web API Client v1.0.3 and below
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…