Code Monkey home page Code Monkey logo

bring's Issues

Error when you start tomcat (ClassNotFoundException: org.apache.jasper.servlet.JspServlet)

Step to reproduce:

  • start BringStarterApplication via a run method
  • monitor the logs
    actual result:
  • The application started but we had some error
    java.lang.ClassNotFoundException: org.apache.jasper.servlet.JspServlet at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1437) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1245) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:491) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:473) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:143) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:865) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:805) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4601) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4894) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:918) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485) at com.bobocode.bring.web.embeddedTomcat.TomcatWebServer.initialize(TomcatWebServer.java:32) at com.bobocode.bring.web.embeddedTomcat.TomcatWebServer.<init>(TomcatWebServer.java:21) at com.bobocode.bring.web.embeddedTomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:40) at com.bobocode.bring.web.BringStarterApplication.run(BringStarterApplication.java:17) at com.bobocode.bringplayground.BringPlaygroundApplication.main(BringPlaygroundApplication.java:10)
    expected result:
  • The application started no errors

Configure logging in core

add logging dependencies

  • slf4j-api, logback
    add logback.xml and logback-test.xml

added a few appenders:

  • file
  • async
  • console

Add PostConstruct annotation and BPP

Create BPP that implements BeanPostProcessor and add logic to handle PostConstract annotation.

Add java doc
Add MD file with feature
Add tests

Should throw exception when we have two dependencies for one interface

If we have one interface and two dependencies and the inject param does not match any dependency. We should have an exception.

No qualifying bean of type 'interface com.levik.bringplayground.feature.di.Drink' available: expected single matching bean but found 2: [Latte, Espresso]

Property injection field that not defined in application.properties

  • If a client forgets to include a value in the application properties file but utilizes the @value annotation, it's crucial to handle this scenario by throwing an exception indicating the inability to resolve the value. This handling should encompass the constructor, field, and setter methods.

Add the possibility to override Profile annotation via -Dbring.active.profile=dev

add tests to handle these cases BringValueInjectionTest & update Value.md with negative cases.

This is one of the negative examples that need to be handle

@Disabled("Need to throw exception when we cannot find value and do the same for constructor, setter and field injection")
@DisplayName("Should found profile bean and read application properties and do field injection but value not found")
@Test
void shouldFoundProfileBeanAndReadApplicationPropertiesAndSetNullValueToFieldInjectionIfNotFound() {
    //when
    var bringApplicationContext = BringApplication.run(TEST_DATA_NEGATIVE_PACKAGE + ".fieldproperties");
    NotFoundValue notFoundValue = bringApplicationContext.getBean(NotFoundValue.class);
}

Notes:

  • PropertyFieldValueTypeInjector, PropertyParameterValueTypeInjector
  • ValuePropertiesPostProcessor

Add PreDestroy annotation and implement logic that handle it

Update BringBeanFactory with new method close

Add implementation of the method in class AnnotationBringBeanRegistry you should go throw all singletonObjects and check if we have a method with PreDestroy if yes call it.

As for the web we need to add this logic to Web listener onDestroy it will called when Tomcat stops. TomcatServletWebServerFactory -> context.addLifecycleListener();

add javadoc
add test
add MD

Properties injection (via @Value)

  • Value injection via field, set, constructor
  • application.properties - default one, can be overridden when you set profile, for instance, qa and you have application-qa.properties. That the value that overridden will be more priority.

Add DI arch diagram for readme.md

DI flow diagram

Image

  1. The BringApplication provides a simple entry point to initialize and run a BringApplicationContext.
    It allows the user to create and configure a BringApplicationContext either by specifying a base package for component scanning or by providing a class that contains configuration information.

  2. The ClassPathScannerFactory is responsible for creating a set of class path scanners, each designed to scan the classpath for specific types of annotated classes relevant to the Bring application. It initializes scanners for components, services, and configuration classes etc.

  3. The BeanPostProcessorDefinitionFactory is responsible for creating and managing a list of BeanFactoryPostProcessor instances. It initializes the list with default post-processors, such as the ConfigurationClassPostProcessor etc. In this step we create Bean definitions for classes annotated with annotations from ClassPathScanner

  4. The BeanPostProcessorFactory is responsible for creating and managing a list BeanPostProcessor instances. It initializes the list with default post-processors such as the ScheduleBeanPostProcessor and add addition loginc to them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.