dependency injection - Spring, maven archetype @value -
we using spring boot (1.4) , maven (3.3.9) archetypes. in archetype, trying create jerseyconfiguration
extends abstractjerseyconfiguration
(that implements org.glassfish.jersey.server.resourceconfig
). in constructor trying pass value through constructor injection (with key loggingfilter.register
) configurtion.properties
. in order @value("${loggingfilter.register:false}") boolean ..
after archetype generates mvn project, doing @value("${$symbol_dollar}{loggingfilter.register:false}") boolean ..
.
here code snippet:
#set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) package ${package}; import java.util.logging.logger; import javax.ws.rs.applicationpath; import org.springframework.beans.factory.annotation.autowired; import org.springframework.beans.factory.annotation.value; import org.springframework.stereotype.component; import com.a.a.c.abstractjerseyconfiguration; import com.a.a.c.m.logrequestfilter; import ${package}.service.rs.restserviceimpl; @component @applicationpath("/") public class jerseyconfiguration extends abstractjerseyconfiguration { private static final logger log = logger.getlogger(jerseyconfiguration.class.getname()); @autowired public jerseyconfiguration(logrequestfilter lrf, @value("${$symbol_dollar}{loggingfilter.register:false}") boolean filterflag) { super(lrf, filterflag); register(restserviceimpl.class); } }
i able generate mvn project locally needed. when checked master, jenkins build runs on archetype. when mvn archetype:generate run using ui, not replace placeholder correctly, , hence not able start embedded tomcat. here stack trace:
2016-11-04 21:21:15.269 error $ threadid: {pid:- } --- [ hostname: servicename: version: transactionid: requesttimestamp: responsetimestamp: duration: ] [ main] o.s.boot.springapplication : application startup failed org.springframework.context.applicationcontextexception: unable start embedded container; nested exception org.springframework.boot.context.embedded.embeddedservletcontainerexception: unable start embedded tomcat @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.onrefresh(embeddedwebapplicationcontext.java:137) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:535) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.refresh(embeddedwebapplicationcontext.java:122) @ org.springframework.boot.springapplication.refresh(springapplication.java:761) @ org.springframework.boot.springapplication.refreshcontext(springapplication.java:371) @ org.springframework.boot.springapplication.run(springapplication.java:315) @ org.springframework.boot.test.context.springbootcontextloader.loadcontext(springbootcontextloader.java:111) @ org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate.loadcontextinternal(defaultcacheawarecontextloaderdelegate.java:98) @ org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate.loadcontext(defaultcacheawarecontextloaderdelegate.java:116) @ org.springframework.test.context.support.defaulttestcontext.getapplicationcontext(defaulttestcontext.java:83) @ org.springframework.test.context.support.dependencyinjectiontestexecutionlistener.injectdependencies(dependencyinjectiontestexecutionlistener.java:117) @ org.springframework.test.context.support.dependencyinjectiontestexecutionlistener.preparetestinstance(dependencyinjectiontestexecutionlistener.java:83) @ org.springframework.boot.test.autoconfigure.springbootdependencyinjectiontestexecutionlistener.preparetestinstance(springbootdependencyinjectiontestexecutionlistener.java:44) @ org.springframework.test.context.testcontextmanager.preparetestinstance(testcontextmanager.java:230) @ org.springframework.test.context.junit4.springjunit4classrunner.createtest(springjunit4classrunner.java:228) @ org.springframework.test.context.junit4.springjunit4classrunner$1.runreflectivecall(springjunit4classrunner.java:287) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.springframework.test.context.junit4.springjunit4classrunner.methodblock(springjunit4classrunner.java:289) @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:247) @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:94) @ org.junit.runners.parentrunner$3.run(parentrunner.java:290) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288) @ org.junit.runners.parentrunner.access$000(parentrunner.java:58) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268) @ org.springframework.test.context.junit4.statements.runbeforetestclasscallbacks.evaluate(runbeforetestclasscallbacks.java:61) @ org.springframework.test.context.junit4.statements.runaftertestclasscallbacks.evaluate(runaftertestclasscallbacks.java:70) @ org.junit.runners.parentrunner.run(parentrunner.java:363) @ org.springframework.test.context.junit4.springjunit4classrunner.run(springjunit4classrunner.java:191) @ org.apache.maven.surefire.junit4.junit4provider.execute(junit4provider.java:367) @ org.apache.maven.surefire.junit4.junit4provider.executewithrerun(junit4provider.java:274) @ org.apache.maven.surefire.junit4.junit4provider.executetestset(junit4provider.java:238) @ org.apache.maven.surefire.junit4.junit4provider.invoke(junit4provider.java:161) @ org.apache.maven.surefire.booter.forkedbooter.invokeproviderinsameclassloader(forkedbooter.java:290) @ org.apache.maven.surefire.booter.forkedbooter.runsuitesinprocess(forkedbooter.java:242) @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:121) caused by: org.springframework.boot.context.embedded.embeddedservletcontainerexception: unable start embedded tomcat @ org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainer.initialize(tomcatembeddedservletcontainer.java:115) @ org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainer.<init>(tomcatembeddedservletcontainer.java:82) @ org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainerfactory.gettomcatembeddedservletcontainer(tomcatembeddedservletcontainerfactory.java:535) @ org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainerfactory.getembeddedservletcontainer(tomcatembeddedservletcontainerfactory.java:177) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.createembeddedservletcontainer(embeddedwebapplicationcontext.java:164) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.onrefresh(embeddedwebapplicationcontext.java:134) ... 35 common frames omitted caused by: java.lang.illegalargumentexception: not resolve placeholder '$symbol_dollar' in string value "${$symbol_dollar}{loggingfilter.register:false}" @ org.springframework.util.propertyplaceholderhelper.parsestringvalue(propertyplaceholderhelper.java:174) @ org.springframework.util.propertyplaceholderhelper.replaceplaceholders(propertyplaceholderhelper.java:126) @ org.springframework.core.env.abstractpropertyresolver.doresolveplaceholders(abstractpropertyresolver.java:219) @ org.springframework.core.env.abstractpropertyresolver.resolverequiredplaceholders(abstractpropertyresolver.java:193) @ org.springframework.context.support.propertysourcesplaceholderconfigurer$2.resolvestringvalue(propertysourcesplaceholderconfigurer.java:172) @ org.springframework.beans.factory.support.abstractbeanfactory.resolveembeddedvalue(abstractbeanfactory.java:813) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory.java:1076) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory.java:1056) @ org.springframework.beans.factory.support.constructorresolver.resolveautowiredargument(constructorresolver.java:835) @ org.springframework.beans.factory.support.constructorresolver.createargumentarray(constructorresolver.java:741) @ org.springframework.beans.factory.support.constructorresolver.autowireconstructor(constructorresolver.java:189) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.autowireconstructor(abstractautowirecapablebeanfactory.java:1148) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance(abstractautowirecapablebeanfactory.java:1051) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:510) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:482) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:306) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:302) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:202) @ org.springframework.beans.factory.config.dependencydescriptor.resolvecandidate(dependencydescriptor.java:207) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory.java:1128) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory.java:1056) @ org.springframework.beans.factory.support.constructorresolver.resolveautowiredargument(constructorresolver.java:835) @ org.springframework.beans.factory.support.constructorresolver.createargumentarray(constructorresolver.java:741) @ org.springframework.beans.factory.support.constructorresolver.autowireconstructor(constructorresolver.java:189) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.autowireconstructor(abstractautowirecapablebeanfactory.java:1148) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance(abstractautowirecapablebeanfactory.java:1051) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:510) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:482) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:306) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:302) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:197) @ org.springframework.beans.factory.support.constructorresolver.instantiateusingfactorymethod(constructorresolver.java:372) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.instantiateusingfactorymethod(abstractautowirecapablebeanfactory.java:1128) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance(abstractautowirecapablebeanfactory.java:1023) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:510) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:482) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:306) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:302) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:202) @ org.springframework.boot.web.servlet.servletcontextinitializerbeans.getorderedbeansoftype(servletcontextinitializerbeans.java:233) @ org.springframework.boot.web.servlet.servletcontextinitializerbeans.getorderedbeansoftype(servletcontextinitializerbeans.java:214) @ org.springframework.boot.web.servlet.servletcontextinitializerbeans.addservletcontextinitializerbeans(servletcontextinitializerbeans.java:90) @ org.springframework.boot.web.servlet.servletcontextinitializerbeans.<init>(servletcontextinitializerbeans.java:78) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.getservletcontextinitializerbeans(embeddedwebapplicationcontext.java:241) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.selfinitialize(embeddedwebapplicationcontext.java:228) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.access$000(embeddedwebapplicationcontext.java:89) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext$1.onstartup(embeddedwebapplicationcontext.java:213) @ org.springframework.boot.context.embedded.tomcat.tomcatstarter.onstartup(tomcatstarter.java:55) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5178) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1403) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1393) @ java.util.concurrent.futuretask.run(futuretask.java:266) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ java.lang.thread.run(thread.java:745)
any or direction appreciated.
Comments
Post a Comment