Hi coders, i wrote a library and i wrapped Jserver inside and wrote my server handlers also there. I tried using this library inside a cli program and to my surprise i got error. Please any suggestion?
cuppifyrouter is my server handler inside the library.
Waiting for debugger to connect...
Program started.
2018-11-28 13:42:58.737:INFO::main: Logging initialized @1288ms to org.eclipse.jetty.util.log.StdErrLog
Error occurred on line: 32 (Main)
java.lang.ClassNotFoundException: b4j.example.cuppifyrouter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:165)
at Punchline.Tech.Cuppify.cuppify._start(cuppify.java:316)
at b4j.example.main._appstart(main.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:628)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at b4j.example.main.main(main.java:29)
Program terminated (StartMessageLoop was not called).
Thanks , the above did solve my problem but created another.
Inside my library the handler: CuppifyRouter is not able to call an external sub inside a code module using call sub. I tried adding the external package name like
punchline.myapi.MyModule.MyExternalSub this doesn't work also ..
B4X:
If SubExists("punchline.myapi.MyModule", "MyExternalSub") Then
CallSub3("punchline.myapi.MyModule", "MyExternalSub", "My First Paremeter", "My Second Parameter")
End If
Shouldn't the first parameter of SubExists be an Object and not a String?
B4X:
Dim m As SomeClassModule
' otherCodeModule is a code module in project
…
' class module
If SubExists(m,"someMethod") then
…
' code module
if SubExists(otherCodeModule,"anotherMethod") then
...
Shouldn't the first parameter of SubExists be an Object and not a String?
B4X:
Dim m As SomeClassModule
' otherCodeModule is a code module in project
…
' class module
If SubExists(m,"someMethod") then
…
' code module
if SubExists(otherCodeModule,"anotherMethod") then
...
Actually , i wrote a library for B4J i don't know what package name someone using my library might use
but i would try like what you suggested if it work .. i think i can use this as a temporary solution, i can tell developers to also follow that step for now . But if any solution is available please share
Hi, i tried using same package name. This doesn't solve my problem. I even tried putting my package name in front like this
B4X:
CallSub3("punchline.myapi.MyModule", "MyExternalSub", "My First Paremeter", "My Second Parameter")
same failed result. I think from a server handler one cant call a sub that is external. Because i created another module in the project and tried call my sun then i used in my real app and called that sub and it worked , am i doing something wrong because i need to pass all parameters in the callsub3() dynamically
This is what I was hinting at with my previous post.
CallSub3 requires an object in the first parameter not a string
If you have a class module then you will have