Transitive log4j2 dependency - configuration failing - java

Im working on a project that has log4j2 as a transitive dependency.
I was having this error
ERROR StatusLogger No log4j2 configuration file found. Using default
configuration: logging only errors to the console.
So I created a new log4j2.xml file under src/main/resources and I tried with the Default Apache's configuration.
Here:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
Now when I build my project this warns (errors) prompts:
2015-02-11 17:02:52,375 WARN JNDI lookup class is not available because this JRE does not support JNDI. JNDI string lookups will not be available, continuing configuration. java.lang.ClassCastException: Cannot cast org.apache.logging.log4j.core.lookup.JndiLookup to org.apache.logging.log4j.core.lookup.StrLookup
at java.lang.Class.cast(Class.java:3133)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:163)
at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOf(Loader.java:311)
at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:92)
at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:104)
at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:55)
at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:375)
at org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout(PatternLayout.java:280)
at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.<init>(ConsoleAppender.java:116)
at org.apache.logging.log4j.core.appender.ConsoleAppender.newBuilder(ConsoleAppender.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.createBuilder(PluginBuilder.java:158)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:118)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:766)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:706)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:698)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:358)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
at org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.mule.util.IOUtils.<clinit>(IOUtils.java:33)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.getExamplesFile(JavaDocAnnotationVerifier.java:222)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateSampleTag(JavaDocAnnotationVerifier.java:199)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateMethod(JavaDocAnnotationVerifier.java:143)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.verify(JavaDocAnnotationVerifier.java:74)
at org.mule.devkit.verifiers.SimpleJavaDocAnnotationVerifier.verify(SimpleJavaDocAnnotationVerifier.java:17)
at org.mule.devkit.apt.AbstractAnnotationProcessor.doVerify(AbstractAnnotationProcessor.java:462)
at org.mule.devkit.apt.AbstractAnnotationProcessor.verifyModule(AbstractAnnotationProcessor.java:307)
at org.mule.devkit.apt.AbstractAnnotationProcessor.runVerifiers(AbstractAnnotationProcessor.java:185)
at org.mule.devkit.apt.AbstractAnnotationProcessor.doProcess(AbstractAnnotationProcessor.java:413)
at org.mule.devkit.apt.AbstractAnnotationProcessor.process(AbstractAnnotationProcessor.java:140)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:231)
at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:149)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
2015-02-11 17:02:52,379 WARN JMX runtime input lookup class is not available because this JRE does not support JMX. JMX lookups will not be available, continuing configuration. java.lang.ClassCastException: Cannot cast org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup to org.apache.logging.log4j.core.lookup.StrLookup
at java.lang.Class.cast(Class.java:3133)
at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:163)
at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOf(Loader.java:311)
at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:103)
at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:104)
at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:55)
at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:375)
at org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout(PatternLayout.java:280)
at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.<init>(ConsoleAppender.java:116)
at org.apache.logging.log4j.core.appender.ConsoleAppender.newBuilder(ConsoleAppender.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.createBuilder(PluginBuilder.java:158)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:118)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:766)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:706)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:698)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:358)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
at org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.mule.util.IOUtils.<clinit>(IOUtils.java:33)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.getExamplesFile(JavaDocAnnotationVerifier.java:222)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateSampleTag(JavaDocAnnotationVerifier.java:199)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateMethod(JavaDocAnnotationVerifier.java:143)
at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.verify(JavaDocAnnotationVerifier.java:74)
at org.mule.devkit.verifiers.SimpleJavaDocAnnotationVerifier.verify(SimpleJavaDocAnnotationVerifier.java:17)
at org.mule.devkit.apt.AbstractAnnotationProcessor.doVerify(AbstractAnnotationProcessor.java:462)
at org.mule.devkit.apt.AbstractAnnotationProcessor.verifyModule(AbstractAnnotationProcessor.java:307)
at org.mule.devkit.apt.AbstractAnnotationProcessor.runVerifiers(AbstractAnnotationProcessor.java:185)
at org.mule.devkit.apt.AbstractAnnotationProcessor.doProcess(AbstractAnnotationProcessor.java:413)
at org.mule.devkit.apt.AbstractAnnotationProcessor.process(AbstractAnnotationProcessor.java:140)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:231)
at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:149)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Currently dependency versions:
What could be causing this?
Thanks in advance.
Juan c:

This is not a problem. The Interpolator class is trying to enable various kinds of lookups: for example env:propertyName lookups for environment variables, sys:propertyName for Java system properties, jndi:propertyName for JNDI properties, etc.
If JNDI is not available you will see this warning. Configuration will continue after this message is logged.
You can raise a request on the log4j2 Jira issue tracker to make this look less like an error (with hindsight the stack trace is confusing and unnecessary here).

Perhaps the project also loads another log4j2 configuration somewhere that depends on the JMX properties. You can get more information about what Log4j is doing by enabling DEBUG or TRACE status on your config file like shown here
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG" name="example-config">
</Configuration>
Also try setting the default StatusLogger for Log4j to DEBUG by passing in a system property when running the application:
java -DLog4jDefaultStatusLevel=DEBUG MyApp
Also, are you sure that there are no 1.2 dependencies in the classpath? If there are, they might conflict with the 1.2-2.1 bridge.

Related

Maven ArcheType Filter On Yaml File

When building my Archetype I received an error on parsing of a yaml file
I have set fileSet on archetype-metadata.xml for yaml in this way
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
</includes>
</fileSet>
this is my yaml file
spring:
application:
name: ${applicationName}-service
logging:
pattern:
console: ""
management:
security:
enabled: false
server:
port: ${PORT:4001}
This is error on clean and install of my ArcheType
org.apache.velocity.exception.ParseErrorException: Encountered ":4001}" at archetype-resources/src/main/resources/bootstrap.yml[line 11, column 15]
Was expecting one of:
"[" ...
"}" ...
at org.apache.velocity.Template.process(Template.java:151)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:437)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:343)
at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processTemplate(DefaultFilesetArchetypeGenerator.java:770)
at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFileSet(DefaultFilesetArchetypeGenerator.java:571)
at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processTemplates(DefaultFilesetArchetypeGenerator.java:820)
at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processArchetypeTemplates(DefaultFilesetArchetypeGenerator.java:545)
at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetProject(DefaultFilesetArchetypeGenerator.java:663)
at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetModule(DefaultFilesetArchetypeGenerator.java:596)
at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.generateArchetype(DefaultFilesetArchetypeGenerator.java:207)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.processFileSetArchetype(DefaultArchetypeGenerator.java:135)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:106)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:149)
at org.apache.maven.archetype.mojos.IntegrationTestMojo.generate(IntegrationTestMojo.java:535)
at org.apache.maven.archetype.mojos.IntegrationTestMojo.processIntegrationTest(IntegrationTestMojo.java:494)
at org.apache.maven.archetype.mojos.IntegrationTestMojo.execute(IntegrationTestMojo.java:313)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
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:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
I'm using
Eclipse Oxigen
jdk 1.8
Maven 3.3.1
Velocity will try to get variable after $ (Dollar Sign), so I suggest you trick velocity to ignore it and then your Spring will get the required output ${PORT:4001} after velocity finish transform the template.
#set ( $dollarSign = "$")
port: $dollarSign{PORT:4001}
it should be ${dollarSign}{PORT:4001}
Alas, the ${PORT:4001} syntax is not (yet?) supported by Velocity.
So you have to use #if($PORT)$PORT#{else}4001#end

Unable to create class org.apache.logging.log4j.core.impl.Log4jContextFactory

I am using spring boot application for a project and getting the following error while running the project from jar using java -jar build/libs/com.user.admin.rest.services.jar. But its not a blocker and i was able to access the api's, and the logger is working fine as intended. I just want to resolve this error.
ERROR StatusLogger Unable to create class org.apache.logging.log4j.core.impl.Log4jContextFactory specified in jar:file:/Users/Samuel/UserMgmt/com.user.admin.rest.services/build/libs/com.user.admin.rest.services.jar!/META-INF/log4j-provider.properties
java.lang.ClassNotFoundException: org.apache.logging.log4j.core.impl.Log4jContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.logging.log4j.spi.Provider.loadLoggerContextFactory(Provider.java:96)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:91)
at com.user.admin.rest.services.api.UserServiceResource.<clinit>(UserServiceResource.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1147)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at com.user.admin.rest.services.api.Application.main(Application.java:27)
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 org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
I have added the following lines for logger in the build.gradle file.
compile 'org.apache.logging.log4j:log4j-api:2.8.2'
compile 'org.apache.logging.log4j:log4j-core:2.8.2'
And my log4j2.xml file is given below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Configuration status="ERROR" name="example-config">
<Properties>
<Property name="PATTERN">%-5level %d [%t] %c:%M(%L): %m%n</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="${PATTERN}" />
</Console>
</Appenders>
<Loggers>
<Root level="TRACE">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>
Generally speaking, you should never need to switch logging implementations; Logback should suit you fine. However, if you decide that you’d rather use Log4j or Log4j2, you’ll need to change your dependencies to include the appropriate starter for the logging implementation you want to use and to exclude Logback.
Spring Boot in Action
Swapping out Logback for Log4j2 in Gradle
Exclude the default logging
configurations {
all*.exclude group:'org.springframework.boot',
module:'spring-boot-starter-logging'
}
Add Log4j2 logging
compile("org.springframework.boot:spring-boot-starter-log4j2")
You can find details of spring-boot-starter-log4j2 dependency version that is provided by Spring Boot here.
I have met the similar problem. The version of log4j-api and log4j-core have to match (and ClassNotFound is a strange exception here). As you have said in comment, you have found log4j-core-2.7.jar, but I may guess your log4j-api is in version of 2.8.2 as your above description shows.
Check your dependency, remove old version of log4j-core and add new version should fix the problem.
This exception is printed to System.out because the class is not on the classpath of Spring's boot loader. But this is not the cause of logging not working or not using the specified configuration file.
It's a Spring Boot Gradle plugin issue. It should add Log4j to the boot loader classpath when it detects a dependency on Log4j.

Google errorprone java compiler - Bugs during maven build: java.lang.NoSuchFieldError: pid

I have added the following to the pom file:
<!-- Source: http://errorprone.info/docs/installation -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<!-- maven-compiler-plugin defaults to targeting Java 5, but our javac
only supports >=6 -->
<source>8</source>
<target>8</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.5</version>
</dependency>
<!-- override plexus-compiler-javac-errorprone's dependency on
Error Prone with the latest version -->
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.0.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Which during maven clean install leads to:
An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NoSuchFieldError: pid
at lombok.javac.JavacAST.packageDeclaration(JavacAST.java:107)
at lombok.javac.JavacAST.<init>(JavacAST.java:81)
at lombok.javac.JavacTransformer.transform(JavacTransformer.java:67)
at lombok.javac.apt.Processor.process(Processor.java:250)
at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:115)
at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:165)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:801)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1021)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1129)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1141)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:833)
at com.sun.tools.javac.main.Main.compile(Main.java:249)
at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:220)
at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:158)
at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:87)
at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
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:497)
at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:825)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
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:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[DEBUG] incrementalBuildHelper#afterRebuildExecution
[INFO] ------------------------------------------------------------------------
...
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
(default-compile) on project Core: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
(default-compile) on project Core: Compilation failure at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) at
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at
org.apache.maven.cli.MavenCli.main(MavenCli.java:158) 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:497) at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by:
org.apache.maven.plugin.compiler.CompilationFailureException:
Compilation failure at
org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:915)
at
org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more [ERROR]
Hmm.. I notice just now that it is comlaining with regards to a lombok related AST stuff.
Does errorprone and lombok not work well together?
What can I do to resolve this issue?
They indeed do not work well together, because of compiler.
Error-prone dev comments (Jun, 26, 2015):
We made the decision to pin Error Prone to a specific version of javac because Error Prone relies on compiler internals, and supporting multiple versions of javac was difficult and hard to validate, because we use only one version of javac internally.
Lombok dev comment (Oct, 12, 2015):
I'm afraid Java 9 support is not going to be fixed in a few days.
It looks like all releases of errorprone starting with 2.0 do use javac9, thus making it not possible to workaround, although you may try previous versions of errorprone.
I had the same problem, solved it by using Java 8 to compile (turned out that my JAVA_HOME was pointing to a Java 9 version).

BDD jbehave integration with maven

Hi i've got the following jbehave plugin configuration in parent pom.xml
${jbehave.version} = 3.9.4
<!--Jbehave-->
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>${jbehave.version}</version>
<configuration>
<scope>test</scope>
<includes>
<include>**/HotelStories.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>run-stories-with-annotated-embedder</id>
<phase>test</phase>
<goals>
<goal>run-stories-with-annotated-embedder</goal>
</goals>
</execution>
</executions>
</plugin>
Unfortunately plugin cannot load the class HotelStories.java. It fails with the following exception
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.4:run-stories-with-annotated-embedder (default-cli) on project com.alg.ce.services.jbehave: Failed to run stories with annotated embedder runner: Failed to load class com.alg.services.jbehave.stories.HotelStories with classLoader EmbedderClassLoader[urls=[/C:/Users/gsamsonov/av_services/serviceslayer/jbehave/target/test-classes, /C:/Users/gsamsonov/av_services/serviceslayer/jbehave/target/classes, hamcrest-library-1.2.1.jar, hamcrest-core-1.2.1.jar, jbehave-core-3.9.4.jar, junit-4.11.jar, hamcrest-integration-1.3.jar, commons-collections-3.2.1.jar, commons-io-2.4.jar, commons-lang-2.3.jar, plexus-utils-3.0.10.jar, freemarker-2.3.19.jar, paranamer-2.4.jar, xstream-1.4.5.jar, xmlpull-1.1.3.1.jar, xpp3_min-1.1.4c.jar, jbehave-maven-plugin-3.9.4.jar, maven-plugin-api-2.0.11.jar, maven-artifact-2.0.11.jar, maven-project-2.0.11.jar, maven-settings-2.0.11.jar, maven-profile-2.0.11.jar, maven-model-2.0.11.jar, maven-artifact-manager-2.0.11.jar, maven-repository-metadata-2.0.11.jar, wagon-provider-api-1.0-beta-2.jar, maven-plugin-registry-2.0.11.jar, plexus-interpolation-1.1.jar, plexus-container-default-1.0-alpha-9-stable-1.jar, classworlds-1.1-alpha-2.jar, plexus-archiver-1.2.jar, plexus-io-1.0.1.jar, jbehave-spring-3.9.4.jar, spring-context-4.0.5.RELEASE.jar, spring-aop-4.0.5.RELEASE.jar, aopalliance-1.0.jar, spring-beans-4.0.5.RELEASE.jar, spring-expression-4.0.5.RELEASE.jar, spring-test-4.0.5.RELEASE.jar, spring-core-4.0.5.RELEASE.jar, com.alg.ce.services.common-0.0.1-SNAPSHOT.jar, validation-api-1.1.0.Final.jar, spring-jdbc-4.0.5.RELEASE.jar, spring-tx-4.0.5.RELEASE.jar, spring-ws-core-2.2.0.RELEASE.jar, spring-xml-2.2.0.RELEASE.jar, spring-oxm-4.0.5.RELEASE.jar, spring-webmvc-4.0.5.RELEASE.jar, httpclient-4.3.3.jar, httpcore-4.3.2.jar, commons-codec-1.9.jar, com.alg.ce.services.repository-0.0.1-SNAPSHOT.jar, couchbase-client-1.4.2.jar, netty-3.5.5.Final.jar, jettison-1.1.jar, stax-api-1.0.1.jar, spymemcached-2.11.3.jar, httpcore-nio-4.3.jar, jackson-databind-2.2.1.jar, jackson-annotations-2.2.1.jar, jackson-core-2.2.1.jar, aspectjweaver-1.7.3.jar, aspectjrt-1.7.3.jar, aspectjtools-1.7.3.jar, asm-all-4.0.jar, cglib-2.2.0-b14.jar, poi-3.10-FINAL.jar, poi-ooxml-3.10-FINAL.jar, poi-ooxml-schemas-3.10-FINAL.jar, xmlbeans-2.3.0.jar, dom4j-1.6.1.jar, xml-apis-1.0.b2.jar, jackson-mapper-asl-1.9.13.jar, jackson-core-asl-1.9.13.jar, spring-web-4.0.5.RELEASE.jar, com.alg.ce.services.bl-0.0.1-SNAPSHOT.jar, joda-time-2.3.jar, logback-classic-1.1.2.jar, logback-core-1.1.2.jar, slf4j-api-1.7.6.jar, commons-logging-1.1.3.jar, db2jcc-4.9.78.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:3.9.4, parent: sun.misc.Launcher$AppClassLoader#1df95673]] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.4:run-stories-with-annotated-embedder (default-cli) on project com.alg.ce.services.jbehave: Failed to run stories with annotated embedder runner
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to run stories with annotated embedder runner
at org.jbehave.mojo.RunStoriesWithAnnotatedEmbedderRunner.execute(RunStoriesWithAnnotatedEmbedderRunner.java:23)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 25 more
Caused by: org.jbehave.core.junit.AnnotatedEmbedderUtils$ClassLoadingFailed: Failed to load class com.alg.services.jbehave.stories.HotelStories with classLoader EmbedderClassLoader[urls=[/C:/Users/gsamsonov/av_services/serviceslayer/jbehave/target/test-classes, /C:/Users/gsamsonov/av_services/serviceslayer/jbehave/target/classes, hamcrest-library-1.2.1.jar, hamcrest-core-1.2.1.jar, jbehave-core-3.9.4.jar, junit-4.11.jar, hamcrest-integration-1.3.jar, commons-collections-3.2.1.jar, commons-io-2.4.jar, commons-lang-2.3.jar, plexus-utils-3.0.10.jar, freemarker-2.3.19.jar, paranamer-2.4.jar, xstream-1.4.5.jar, xmlpull-1.1.3.1.jar, xpp3_min-1.1.4c.jar, jbehave-maven-plugin-3.9.4.jar, maven-plugin-api-2.0.11.jar, maven-artifact-2.0.11.jar, maven-project-2.0.11.jar, maven-settings-2.0.11.jar, maven-profile-2.0.11.jar, maven-model-2.0.11.jar, maven-artifact-manager-2.0.11.jar, maven-repository-metadata-2.0.11.jar, wagon-provider-api-1.0-beta-2.jar, maven-plugin-registry-2.0.11.jar, plexus-interpolation-1.1.jar, plexus-container-default-1.0-alpha-9-stable-1.jar, classworlds-1.1-alpha-2.jar, plexus-archiver-1.2.jar, plexus-io-1.0.1.jar, jbehave-spring-3.9.4.jar, spring-context-4.0.5.RELEASE.jar, spring-aop-4.0.5.RELEASE.jar, aopalliance-1.0.jar, spring-beans-4.0.5.RELEASE.jar, spring-expression-4.0.5.RELEASE.jar, spring-test-4.0.5.RELEASE.jar, spring-core-4.0.5.RELEASE.jar, com.alg.ce.services.common-0.0.1-SNAPSHOT.jar, validation-api-1.1.0.Final.jar, spring-jdbc-4.0.5.RELEASE.jar, spring-tx-4.0.5.RELEASE.jar, spring-ws-core-2.2.0.RELEASE.jar, spring-xml-2.2.0.RELEASE.jar, spring-oxm-4.0.5.RELEASE.jar, spring-webmvc-4.0.5.RELEASE.jar, httpclient-4.3.3.jar, httpcore-4.3.2.jar, commons-codec-1.9.jar, com.alg.ce.services.repository-0.0.1-SNAPSHOT.jar, couchbase-client-1.4.2.jar, netty-3.5.5.Final.jar, jettison-1.1.jar, stax-api-1.0.1.jar, spymemcached-2.11.3.jar, httpcore-nio-4.3.jar, jackson-databind-2.2.1.jar, jackson-annotations-2.2.1.jar, jackson-core-2.2.1.jar, aspectjweaver-1.7.3.jar, aspectjrt-1.7.3.jar, aspectjtools-1.7.3.jar, asm-all-4.0.jar, cglib-2.2.0-b14.jar, poi-3.10-FINAL.jar, poi-ooxml-3.10-FINAL.jar, poi-ooxml-schemas-3.10-FINAL.jar, xmlbeans-2.3.0.jar, dom4j-1.6.1.jar, xml-apis-1.0.b2.jar, jackson-mapper-asl-1.9.13.jar, jackson-core-asl-1.9.13.jar, spring-web-4.0.5.RELEASE.jar, com.alg.ce.services.bl-0.0.1-SNAPSHOT.jar, joda-time-2.3.jar, logback-classic-1.1.2.jar, logback-core-1.1.2.jar, slf4j-api-1.7.6.jar, commons-logging-1.1.3.jar, db2jcc-4.9.78.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:3.9.4, parent: sun.misc.Launcher$AppClassLoader#1df95673]]
at org.jbehave.core.junit.AnnotatedEmbedderUtils.loadClass(AnnotatedEmbedderUtils.java:37)
at org.jbehave.core.junit.AnnotatedEmbedderUtils.runnerClass(AnnotatedEmbedderUtils.java:15)
at org.jbehave.core.junit.AnnotatedEmbedderUtils.annotatedEmbedderRunner(AnnotatedEmbedderUtils.java:10)
at org.jbehave.core.embedder.Embedder.runStoriesWithAnnotatedEmbedderRunner(Embedder.java:168)
at org.jbehave.mojo.RunStoriesWithAnnotatedEmbedderRunner.execute(RunStoriesWithAnnotatedEmbedderRunner.java:21)
... 27 more
Caused by: java.lang.ClassNotFoundException: com.alg.services.jbehave.stories.HotelStories
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.jbehave.core.junit.AnnotatedEmbedderUtils.loadClass(AnnotatedEmbedderUtils.java:35)
Has anybody encountered a similar issue i seem to've searched a lot on the web and been unable to find a solution.
The error boils down to:
ClassNotFoundException: com.alg.services.jbehave.stories.HotelStories
which means HotelStories.java is not on the classpath. It needs to be. So unless you have changed the default configuration, it should be under /src/main/java of the current project, or one of its dependencies.

Error in own archetype creation

I am creation my own archetype using the link
http://maven.apache.org/guides/mini/guide-creating-archetypes.html
here is my SpringHibernateArcheType\pom.xml for archetype
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SpringHibernateArchetype</groupId>
<artifactId>SpringHibernateArcheType</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Archetype - SpringHibernateArcheType</name>
<url>http://maven.apache.org</url>
</project>
and my SpringHibernateArcheType\src\main\resources\META-INF\maven\archetype.xml is
<archetype
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>SpringHibernateArcheType</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<resources>
<resource>src/main/webapp/WEB-INF/web.xml</resource>
<resource>src/main/webapp/index.jsp</resource>
</resources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>
The code is working fine, I want to add one more configuration ie the application context of the Spring MVC application which is in the servlet-name-servlet.xml format. Mostly I choose the artifactId as my DispatcherServlet name, So how can I add the context file named
src/main/webapp/WEB-INF/{artifactId}-servlet.xml in my archetype.
I tried to add the code,
<resource>src/main/webapp/WEB-INF/${artifactId}-servlet.xml</resource>
but it is throwing me error that
Error merging velocity templates
How to resolve this problem ?
Here is the stacktrace,
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: Error merging velocity templates -> [
Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project stand
alone-pom: Error merging velocity templates
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Error merging velocity templates
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:211)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more

Categories