Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring initialization failure with CsvQueryResultExporter #15

Closed
bflad opened this issue Dec 17, 2013 · 1 comment
Closed

Spring initialization failure with CsvQueryResultExporter #15

bflad opened this issue Dec 17, 2013 · 1 comment
Assignees
Labels
Milestone

Comments

@bflad
Copy link

bflad commented Dec 17, 2013

Environment:

RHEL 6.4
Tomcat 7
java version "1.7.0_25"
OpenJDK Runtime Environment (rhel-2.3.10.3.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Error on Tomcat startup:

20:48:59,981 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader::initWebApplicationContext - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'csvQueryResultExporter' defined in file [/opt/tomcat7-cyclop/webapps/cirrus/WEB-INF/classes/org/cyclop/service/converter/CsvQueryResultExporter.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.cyclop.service.converter.CsvQueryResultExporter]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Can not access AppConfig because spring initialization is not trough
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1011) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:957) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) ~[spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) ~[spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) ~[spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) ~[spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) ~[catalina-7.0.34.jar:7.0.34]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) ~[catalina-7.0.34.jar:7.0.34]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[catalina-7.0.34.jar:7.0.34]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) ~[catalina-7.0.34.jar:7.0.34]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) ~[catalina-7.0.34.jar:7.0.34]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) ~[catalina-7.0.34.jar:7.0.34]
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977) ~[catalina-7.0.34.jar:7.0.34]
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655) ~[catalina-7.0.34.jar:7.0.34]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[na:1.7.0_25]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) ~[na:1.7.0_25]
    at java.util.concurrent.FutureTask.run(FutureTask.java:166) ~[na:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.cyclop.service.converter.CsvQueryResultExporter]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Can not access AppConfig because spring initialization is not trough
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    ... 27 common frames omitted
Caused by: java.lang.IllegalArgumentException: Can not access AppConfig because spring initialization is not trough
    at org.cyclop.common.AppConfig.get(AppConfig.java:28) ~[AppConfig.class:na]
    at org.cyclop.service.converter.CsvQueryResultExporter.<init>(CsvQueryResultExporter.java:34) ~[CsvQueryResultExporter.class:na]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_25]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_25]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_25]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_25]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    ... 29 common frames omitted
Dec 16, 2013 8:48:59 PM org.apache.catalina.core.StandardContext listenerStart
S

I'm not a Java programmer but trade, but to workaround the Spring injection issue, I switched:
https://github.com/maciejmiklas/cyclop/blob/master/src/main/java/org/cyclop/service/converter/CsvQueryResultExporter.java#L34

// old
private final AppConfig.CqlExport conf = AppConfig.get().cqlExport;
// new
@Inject
private AppConfig appConfig;

Then replaced all later references of conf. with appConfig.cqlExport.

Please let me know if you'd like a pull request with the above. Thanks!

@ghost ghost assigned maciejmiklas Dec 17, 2013
@maciejmiklas
Copy link
Owner

you are correct - I've fixed it already in trunk, so there is no need for pull request. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants