Spring Boot: "Logback configuration error detected" error - java

I am using aan external library (jar file from another project) and I added that Jar file (artifact) from Dependencies tab in the Project Structure ~ Modules section.
However, when I run my project, I get the following error. I am not sure what I am missing, but I think I also need to add some extra reference or library frokm the other project. Any idea?
Note that I created the artifact as mentioned on https://www.jetbrains.com/idea/guide/tutorials/hello-world/packaging-the-application/ . However, as that project is a Java8 project, I just added the module without starter class.
On the other hand, I added jar file to the project as mentioned on https://www.geeksforgeeks.org/how-to-add-external-jar-file-to-an-intellij-idea-project/.
Connected to the target VM, address: '127.0.0.1:59219', transport: 'socket'
Logging system failed to initialize using configuration from 'classpath:logback-default.xml'
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in biz.paluch.logging.gelf.logback.GelfLogbackAppender[GELF_UDP] - Unknown GELF server hostname:udp:LOG_ENDPOINT_IP_IS_UNDEFINED java.net.UnknownHostException: LOG_ENDPOINT_IP_IS_UNDEFINED: nodename nor servname provided, or not known
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:57)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:316)
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:282)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:240)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:374)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:332)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
at nl.gerimedica.documents.GmDocumentsApplication.main(DemoApplication.java:16)
2022-10-03 11:06:42.723 ERROR 21530 --- [ main] o.s.boot.SpringApplication : Application run failed

Related

Spring Actuator Changes Upgrading From Spring Boot 2.4.3 to 2.6.2

We have a Spring Boot web application developed with Spring Boot 2.4.3 and deploys Spring Actuator. I am investigating upgrading to Spring Boot 2.6.2 and have the majority of the issues working. I removed spring actuator starter from the project and war file and it deploys and runs fine. We are running using Java 11 and Wildfly 18.
If I add the spring actuator starter back into to the project pom file and war file pom files, it shows the following warning during deployment:
16:44:28,063 WARN [org.jboss.modules.define] (Thread-115) Failed to define class io.micrometer.core.instrument.binder.jersey.server.MetricsApplicationEventListener in Module "deployment.test.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link io/micrometer/core/instrument/binder/jersey/server/MetricsApplicationEventListener (Module "deployment.test.war" from Service Module Loader): org/glassfish/jersey/server/monitoring/ApplicationEventListener
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1095)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:424)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)
at org.jboss.modules.Module.loadModuleClass(Module.java:731)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.FilteringSpringBootCondition.resolve(FilteringSpringBootCondition.java:108)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.FilteringSpringBootCondition$ClassNameFilter.isPresent(FilteringSpringBootCondition.java:140)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.FilteringSpringBootCondition$ClassNameFilter$2.matches(FilteringSpringBootCondition.java:128)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.OnClassCondition$StandardOutcomesResolver.getOutcome(OnClassCondition.java:227)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.OnClassCondition$StandardOutcomesResolver.getOutcome(OnClassCondition.java:214)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.OnClassCondition$StandardOutcomesResolver.getOutcomes(OnClassCondition.java:201)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.OnClassCondition$StandardOutcomesResolver.resolveOutcomes(OnClassCondition.java:190)
at deployment.test.war//org.springframework.boot.autoconfigure.condition.OnClassCondition$ThreadedOutcomesResolver.lambda$new$0(OnClassCondition.java:150)
at java.base/java.lang.Thread.run(Thread.java:834)
I went down the path of trying to add jar files to the project for the missing class, but the problem adds to another missing class file. I could not find any major changes in Spring Actuator between Spring Boot versions 2.4.2 and 2.6.2 that would cause this problem.
Does anyone have any insight into changes in Spring Boot that might cause the deployment issue?

Spring boot application fails because it tries to load application.xml file

I am trying to add Spring boot to an existing and working Java web application, which uses Spring.
On starting the application such error is thrown:
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:476)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:465)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:386)
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:225)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:195)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.barclays.scp.eps.fullserve.application.Application.main(Application.java:12)
Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXException: Invalid system identifier: http://java.sun.com/dtd/application_1_3.dtd
at java.util.XMLUtils.load(XMLUtils.java:59)
It seems that Spring boot is trying to load application.xml file as it's config file, though I haven't specified anywhere that such file is required and I had previously created Spring boot apps from scratch, no application.xml was required.
The project is quite big, it has many dependencies, maybe that could be caused by some of them?
I have tried adding application.xml to resources folder, a valid empty xml file - the main exception is still the same, though the cause of it is a bit different - Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException: Premature end of file. This means the application.xml was read this time, but for some reason - incorrect.
What could be the issue here, why this application.xml is required at all? As far as I understand, such configuration file should not be required in Spring boot app.
Some info about project configuration - these Spring boot dependencies are added (Spring boot version 1.5.9.RELEASE):
compile('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
Main class launching the project is very basic (I know it will need more configuration, but one step at a time):
#SpringBootApplication
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
Any suggestions would be appreciated. Thank you!
The essayist is to create new Spring Boot project using https://start.spring.io/ and then migrate your code.
Everything else is much more work.
JDK: 1.8
Spring Boot: 2.1.4-RELEASE
#Adomas I met this situation just now. The reason is that I have a dependency jar which includes the file named 'application.xml' in the classpath.
After I remove this file 'application.xml' from this dependency jar, I had solved this problem.
22:20:52.866 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:556)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:502)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:469)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$6(ConfigFileApplicationListener.java:450)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$7(ConfigFileApplicationListener.java:449)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:446)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:334)
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:209)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:192)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:179)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.xxx.Application.main(Application.java:16)
Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 33; 文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"。
at sun.util.xml.PlatformXmlPropertiesProvider.load(PlatformXmlPropertiesProvider.java:80)
at java.util.Properties$XmlSupport.load(Properties.java:1201)
at java.util.Properties.loadFromXML(Properties.java:881)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:137)
at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:122)
at org.springframework.boot.env.PropertiesPropertySourceLoader.loadProperties(PropertiesPropertySourceLoader.java:59)
at org.springframework.boot.env.PropertiesPropertySourceLoader.load(PropertiesPropertySourceLoader.java:47)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:574)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:528)
... 23 common frames omitted
Caused by: org.xml.sax.SAXParseException: 文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"。
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1599)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1877)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:742)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1289)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3132)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:852)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at sun.util.xml.PlatformXmlPropertiesProvider.getLoadingDoc(PlatformXmlPropertiesProvider.java:106)
at sun.util.xml.PlatformXmlPropertiesProvider.load(PlatformXmlPropertiesProvider.java:78)
... 31 common frames omitted
Process finished with exit code 1
The issue was caused by a dependency, which had application.xml in it's resources. In my case that was a legacy dependency and it was not used anywhere so the fix was just to remove it. In case that dependency was required, the solution would probably be to somehow exclude that application.xml loading as Spring boot config file.
I had issue with 1.5.9.RELEASE version
Error: Could not find or load main class ... in Spring Boot 1.5.9 version but not in 1.4.7
I currently use the 1.4.7.RELEASE. I would suggest you to try to update your spring dependency to this version
parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Spring Boot try to load "application.xml", "application.properties" and "application.yml" at "classpath:/". If you want to override the "application.xml", you need to use a valid xml. Like:
<?xml version='1.0' encoding="UTF-8" standalone = "yes"?>
<!DOCTYPE dummy [ <!ELEMENT dummy (dummy?) > ]>
<dummy><dummy></dummy></dummy>

java.lang.ClassNotFoundException: org.hibernate.HibernateException while deploying EAR [duplicate]

This question already has an answer here:
Not able to deploy EAR file
(1 answer)
Closed 6 years ago.
I am developing a web module in struts2 framework and ejb module in eclipse with hibernate as ORM framework.
Every time when I modify my ejb module I have to package it into jar and include it in my web module /WEB-INF/lib folder in order to run my whole application.
Though the application worked fine in this way but it was really time consuming. So I tried to map them in a EAR module. But when I try to run EAR module.
It gives below exceptions
2016-12-24 13:23:43,992 ERROR [org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler] (default task-4) Exception occurred during processing request: WFLYEJB0442: Unexpected Error: javax.ejb.EJBException: WFLYEJB0442: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:184)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException
at com.ebs.persistence.dao.UserDao.<clinit>(UserDao.java:16)
at com.ebs.business.service.UserAuthorisationBusinessService.getUserProfile(UserAuthorisationBusinessService.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException from [Module "deployment.EBS.ear.EBS-ejb.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 179 more
Below is where I suspect to get the exception
private static SessionFactory sessfct = SessionFactoryGenerator.getSessionFactory();
It seems to be some issue with classloader.Somehow it is not able to load hibernatecore.jar. Earlier it use to work fine with same set of jars when EAR was not in the picture. I am new to EAR. Below is the structure of application.xml
<module>
<web>
<web-uri>EBS-web.war</web-uri>
<context-root>EBS-web</context-root>
</web>
</module>
<module>
<ejb>EBS-ejb.jar</ejb>
</module>
I also tried including all the jars in EAR lib folder but no success was achieved
I am developing a web module in struts2 framework and ejb module in
eclipse with hibernate as ORM framework. Every time when I modify my
ejb module I have to package it into jar and include it in my web
module /WEB-INF/lib folder in order to run my whole application.
With an Eclipse plugin as WTP, you should not have this problem.
I also tried including all the jars in EAR lib folder but no success
was achieved
If you place the JARs in the EAR, they should be in the APP-INF/lib folder at the root of the EAR.
Besides, you could use a build tool as Maven or Gradle. It could ease your job of packaging.

Apache Felix and Spring boot application : Class not found issue

I wrote a spring boot application which was working fine without any issues. Then I changed pom and added activator class and make it a Felix OSGI bundle. Then I was able to install it with Felix console as well.
But when I start it with Felix controller, I was getting following error,
g! start 21
org.osgi.framework.BundleException: Activator start error in bundle company.iot.devops [21].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2276)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.gogo.command.Basic.start(Basic.java:739)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at company.iot.devops.IOTMain.main(IOTMain.java:10)
at company.iot.devops.osgi.Activator.start(Activator.java:35)
Then I tried with
<Embed-Dependency>!company*;*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
In the POM and resolved that issue. But now I am getting different issue,
16:51:03.914 [Gogo shell] ERROR org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [company.iot.devops.IOTMain]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:182)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:50)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataRea
....
org.osgi.framework.BundleException: Activator start error in bundle company.iot.devops [42].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2276)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
....
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:50)
I can see jar file spring-boot-autoconfigure-1.3.5.RELEASE.jar in the bundle and it reffered from "Embedded-Artifacts" in the MANIFEST.MF as well.
Not sure why Spring boot can't find this class.
Thanks

Bluemix web app on Liberty is throwing ClassCastExceptions at runtime

My application running on Bluemix Liberty has started throwing a ClassCastException on every http request to the service. Has anything changed in the Bluemix environment?
class com.qw.psence.core.servlet.SkipListController class
com.qw.psence.core.servlet.ContactController [INFO ] FFDC1015I: An FFDC Incident has been created: "java.lang.ClassCastException:
org.jboss.weld.manager.BeanManagerImpl incompatible with
com.sun.jersey.server.impl.cdi.CDIExtension
com.ibm.ws.webcontainer.servlet.ServletWrapper.init 181" at
ffdc_15.09.19_09.53.35.0.log at
com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:180)
[ERROR ] SRVE0271E: Uncaught init() exception created by servlet [jersey-serlvet] in application [myapp]: java.lang.ClassCastException:
org.jboss.weld.manager.BeanManagerImpl incompatible with
com.sun.jersey.server.impl.cdi.CDIExtension at
javax.servlet.GenericServlet.init(GenericServlet.java:244) at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java
:394) at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.(CDIComponentProviderFactory.java:95) at
com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize
(CDIComponentProviderFactoryInitializer.java:76) at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) at
com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572) at [internal classes] at
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332) at
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) at
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604) at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332) at
[internal classes] at
com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572) at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:401) at
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332)
[ERROR ] SRVE0276E: Error while initializing Servlet [jersey-serlvet]:
javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet at
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604) at
com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:180) Caused by: java.lang.ClassCastException:
org.jboss.weld.manager.BeanManagerImpl incompatible with com.sun.jersey.server.impl.cdi.CDIExtension at
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) at
com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76) ... 1 more at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) at javax.servlet.GenericServlet.init(GenericServlet.java:244) at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332) at
com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.
(CDIComponentProviderFactory.java:95)
The Bluemix runtime has recently updated to Liberty buildpack v2. In an effort to eliminate all Classloading issues, try pushing your app as a stand-alone application:
cf push <yourappname> -p myapp.war
The server.xml file now includes many updated features (i.e jaxrs-2.0) for pushing stand-alone apps.
If you want to use the prior version of the buildpack, do so with the following comand:
cf push appName -p myapp.war -b liberty-for-java-v1
This blog post explains the changes in the Liberty for Java buildpack:
https://developer.ibm.com/bluemix/2015/09/08/upcoming-liberty-for-java-buildpack-changes/

Categories