0

I'm quite new to Javalite and have coded my first application.

My first question is about Java package names to use - all examples I've found have top-level package name as 'app'. Can I define and use my own package names assuming that package names below follow the structure recommended?

My second question is about class names used - are the names fixed or I can use my own names but follow certain conventions? Where these conventions can be found?

I have create application with my own packages and class names. When I run it under Eclipse the process started but failed - see the partial log below Jan 25, 2023 8:49:28 PM org.javalite.activeweb.RequestDispatcher initAppConfig SEVERE: Failed to create and init a new instance of class: app.config.AppBootstrap. Application failed to start, so it will not run. java.lang.ClassNotFoundException: app.config.AppBootstrap at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:315) at org.javalite.activeweb.RequestDispatcher.initAppConfig(RequestDispatcher.java:126) at org.javalite.activeweb.RequestDispatcher.initApp(RequestDispatcher.java:74) at org.javalite.activeweb.RequestDispatcher.init(RequestDispatcher.java:68) at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:133) at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$2(ServletHandler.java:725) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:749) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:392) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1304) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:900) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:306) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:532) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171) at org.eclipse.jetty.server.Server.start(Server.java:470) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:89) at org.eclipse.jetty.server.Server.doStart(Server.java:415) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) at org.ns.tools.bcweb.BCWJServer.webSetup(BCWJServer.java:24) at org.ns.tools.bcweb.BCWJServer.main(BCWJServer.java:11) Class app.config.AppBootstrap is not present in my application but I have class named BCWServerBootstrap that implements the similar functionality.

Regards Nick Sorokin e-mail: Nick.Sorokin at gmail.com

Nick S
  • 11
  • 2

1 Answers1

0

To answer your question quickly, the only two requirements for packages and class names are for configuration classes and for controllers. Any other classes, including filters, models, services, etc. can be located in any package and have their preferred name.

Here is the page you need to look at:

https://javalite.io/structure_of_activeweb_project

As you can see, controllers need to be in the app.controllers package:

app.controllers.MyController

The config classes are in the app.config package:

app.config.AppBootstrap
app.config.AppControllerConfig
app.config.DbConfig
app.config.RouteConfig
app.config.FreemarkerConfig

Any other classes can b wherever you want them to be.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46