1

I have a large java web application which I am deploying in tomcat. This application has multiple war files and jar files. When I deploy them to tomcat, it fails on deploying one of the war files with the following error:

Error creating bean with name 'toolWicketApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'org.sakaiproject.scorm.service.api.ScormResourceService' while setting bean property 'resourceService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No bean named 'org.sakaiproject.scorm.service.api.ScormResourceService' is defined

However, in one of my other jars, I do have a bean defined with that name:

<bean id="org.sakaiproject.scorm.service.api.ScormResourceService"
    class="org.sakaiproject.scorm.service.chh.impl.CHHResourceService">

    <!-- Sakai API Service -->
    <lookup-method name="configurationService" bean="org.sakaiproject.component.api.ServerConfigurationService" />
    <lookup-method name="contentService" bean="org.sakaiproject.content.api.ContentHostingService" /> 
    <lookup-method name="toolManager" bean="org.sakaiproject.tool.api.ToolManager" />

    <lookup-method name="scormCHH" bean="org.sakaiproject.scorm.content.api.ScormCHH" />
</bean>

My current theory is that this is an order of loading problem.The war file loads first and needs a bean that is defined in the jar file.

I know that tomcat uses an indeterminate ordering when loading jars and war files (see http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html and Is there a way to enforce a deployment order in tomcat6? and How to control webapp deployment order when restarting tomcat

However, I was wondering about how people handle this situation of jars and wars that have dependencies on each other. Do they put everything in one monolithic jar/war file? And if tomcat/spring is looking for something which isn't loaded yet, shouldn't it wait until it loads the missing component instead of throwing an error?

I did see a spring config option called "depends-on". Would I need to change my config to:

<bean id="toolWicketApplication" class="org.sakaiproject.scorm.ui.player.ScormTool" 
      depends-on="org.sakaiproject.scorm.service.api.ScormResourceService">
        <property name="resourceService"><ref bean="org.sakaiproject.scorm.service.api.ScormResourceService"/></property>
    </bean>

Or does anyone have any other speculation about what else might fix the problem?

Thanks.

Community
  • 1
  • 1
David
  • 15
  • 3
  • Yeah, I'd either have tried the depends-on with maybe a lazy-init=true. If you're in the tool level you have to wait, otherwise have the bean available as a component. This is mentioned in the WebApp component hosting section of [sakai_component.doc](https://github.com/sakaiproject/sakai/blob/master/reference/docs/architecture/sakai_component.doc) – jonespm Apr 28 '17 at 13:34

0 Answers0