Eclipse STS run Spring Boot locally with subprojects - spring

I have the following project structure:
root project
|-- controller
|-- core
|-- widgets
|-- widgetA
|-- widgetB
These projects all get built into jars except controller. Then the jars are deployed to a class folder and controller uses context.xml to specify their location.
This all works great during deployment (except Tomcat's 'redeploy' doesn't redeploy, I suspect an issue with classloaders, but an unload/deploy works fine). However, we currently cannot run this locally in STS because the controller needs a bean from the 'widgets' project that the system can't locate.
The project begins fine when I execute the controller project as a Spring Boot App. It loads, and discovers the beans defined in the 'core' project. But for some reason the 'widgets' project is not scanned by Spring. Again, when this is deployed, Spring scans them all just fine (I assume because of the context.xml that defines the JarResources to load). But I just can't seem to figure out how to get STS to "see" the project.
Edit: For clarity, here is the error I am getting:
May 22, 2018 2:32:00 PM org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext refresh
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'Controller': Unsatisfied dependency expressed through field 'widgetMap'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.Map<java.lang.String, com.mycompany.project.widgets.WidgetInterface>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
System is shutting down
May 22, 2018 2:32:00 PM org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor shutdown
INFO: Shutting down ExecutorService 'getAsyncExecutor'
May 22, 2018 2:32:00 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service [Tomcat]
May 22, 2018 2:32:00 PM org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener logAutoConfigurationReport
INFO:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
May 22, 2018 2:32:00 PM org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter report
SEVERE:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field widgetMap in com.mycompany.project.controller.Controller required a bean of type 'com.mycompany.project.widgets.WidgetInterface' that could not be found.
Action:
Consider defining a bean of type 'com.mycompany.project.widgets.WidgetInterface' in your configuration.

I resolved the issue.
Turns out I was not adding the individual widgets to my build path, but only the 'widgets' class.
Because I was using an #Autowired Map object, I needed at least one of my WidgetInterface implementations on the build path. Since the widget implementation projects were not present, it could not properly instantiate the map, and was erroring out.

Related

How to Solve DispatcherServlet Class not found Exception

I am trying to run Hello world Spring MVC Program. But I am getting the following errors. I have tried so many times from different website, But I couldn't solve this Problem. So Please can anyone help me to solve this.
Apr 29, 2018 7:32:12 PM
org.springframework.web.context.ContextLoader
initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldService' defined in file
[/home/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/spring-web-gradle-xml/WEB-INF/classes/com/mkyong/helloworld/service/HelloWorldService.class]:
Instantiation of bean failed; nested exception is
java.lang.NoClassDefFoundError:
ch/qos/logback/core/joran/spi/JoranException
INFO: Marking servlet spring as unavailable
Apr 29, 2018 7:32:12 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /SpringMVC-Hibernate threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
Make sure that logback Jar is in your classpath.
You can go through this manual and configure your project accordingly.
In case you use a build tool, feel free to post your build configuration file here for a more detailed answer.

Deployment failure with the RPM built with latest jenkins

We recently upgraded to Jenkins 2.47 for our application. We used Jenkins 1.7 previously for building our applications. I observed a strange issue with the upgrade. The RPMs built with latest Jenkins are failing to deploy with the below error:
<Apr 10, 2017 5:01:43 PM GMT> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name : Bean with name has been injected into other beans in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example..
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name : Bean with name has been injected into other beans in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:568)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
Truncated. see log file for complete stacktrace
>
<Apr 10, 2017 5:01:43 PM GMT> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application .
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1520)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name : Bean with name has been injected into other beans in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
I can build the same code on command line with maven (without running the job in Jenkins) and deploy the RPM without any deployment errors.
I could fix the issue by downgrading jenkins to 2.34
Thanks.

Project runs in older version of IDEA, but not newer

I have a spring boot application that runs and functions just fine in IDEA 15.0.4.
Today I tried running it in the latest release of IDEA 2016.1
and I get the following error
2016-03-17 10:06:17.888 WARN 84730 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configClientBootstrapConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException
and then execution stops.
Is there an additional step I have to do to get this to work in the newer version?
I solved this by simply re-cloning the repository and setting up a new project.

Spring Batch Admin Config Throw ClassNotFoundException

I am unable to configure Spring Batch Admin 1.3.0
I have overridden the data source defaults but I keep getting all kinds of errors.
The last one has to do with ClassNotFoundException.
Caused by: java.lang.ClassNotFoundException: org.springframework.integration.MessagingException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) ~[catalina.jar:7.0.42]
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) ~[catalina.jar:7.0.42]
... 35 more
Sep 30, 2014 5:45:18 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
I have included Spring Messaging 4.0 jar in the pom..
I had similar issues using Spring Batch Admin 1.3.0 with Spring 4.1.4 . Several of the classes have had their names changed or have been moved to different packages. Also, a couple of the previously deprecated "SimpleXxx" classes have been dropped (SimpleJdbcTemplate, for example). The resolution is to use the current classes and packages, and to lose the "simple" from a couple of class names.
I finally resolved all of my issues with spring-batch-admin by downloading the current 1.3.1.RELEASE source from github and building it without any modifications.
Does this help?
You might be missing spring-integration-core jar. Please check and try again.

Can't start application in IDE with <jar-find> error, but 'gradle bootRun' - works fine

So, i have a problem that can't solve.
I have a multi module gradle project with spring boot runners. With Jpa, Elastic, OrientDb and another configurations provided by spring-data and spring-integration. And i try to start my web application! Write web starter, make annotation scan, so when I use task 'gradle bootRun' - everything start perfectly - app works, all contexts up and life is good.BUT, when i try use my favorite IDE like Intellij idea, or colleague use Eclipse - get an error :
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with
name 'org.springframework.integration.config.IdGenerato rConfigurer#0':
BeanPostProcessor before instantiation of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with
name org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration':
Initialization of bean failed; nested exception is java.lang.NoSuchMethodError:
org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration.setBeanFactory(Lo rg/springframework/beans/factory/BeanFactoryV
That cause by (projectName - is fake):
java.lang.RuntimeException: error trying to scan <jar-file>:
file:/home/<user>/project/<projectName>/classes/production/<projectName>-system-webapp/
But i have NO /projectName/classes/production/ folder! Anyway - with gradle it's work fine.
And to be honestly, before this another error catched:
Error creating bean with name 'entityManagerFactory' defined in class com.project.system.jpa.PepperJpaConfiguration: Invocation of init method failed
caused by:
error trying to scan <jar-file>: file:/home/<user>/project/<projectName>/classes/production/<projectName>-system-webapp/
Thank you for advice! Can give additional info.
P.S : Edited
So, the problem was solved:
I do not provide important error stacktrace like:
at org.hibernate.ejb.packaging.NativeScanner.getFilesInJar(NativeScanner.java:195)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:506)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:861)
... 21 more
Caused by: java.io.IOException: invalid constant type: 18 at 50
And this was and JDK8-Hibernate-javassist problem https://hibernate.atlassian.net/browse/HHH-8286
When upgrade javassist version to 3.18.1-GA - all problems was solved(but why run through gradle worked perfectly...)

Resources