GateNLP / gatelib-spring

Spring support for use with GATE
GNU Lesser General Public License v3.0
2 stars 2 forks source link

Spring boot war is not working in external tomcat application #1

Closed krishnareddyML closed 5 years ago

krishnareddyML commented 5 years ago

I am using gatelib-spring in spring boot app to work in multithread environment. while deploying spring boot war to external tomcat getting following error. The Gate application (application.xgapp) is stored in /apache-tomcat-9.0.12/webapps/kcvparser/WEB-INF/classes/gate-files/application.xgapp, but container searching directly under project folder.

Tomcat Error Log: Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myApp': Cannot create inner bean 'gate:saved-application#1d5a4df3' of type [gate.util.spring.SavedApplicationFactoryBean] while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gate:saved-application#1d5a4df3': FactoryBean threw exception on object creation; nested exception is java.io.FileNotFoundException: /home/kpmd/apache-tomcat-9.0.12/webapps/kcvparser/gate-files/application.xgapp

greenwoodma commented 5 years ago

How exactly are you configuring the location of the app in your bean definition file?

krishnareddyML commented 5 years ago

In src/main/resources/gate-beans.xml file gate app path mentioned as follows.

Application is working fine while I am running as spring boot app in my eclipse container, but when deploying war in external tomcat it is getting failed
krishnareddyML commented 5 years ago

gate app boot structure Please find following screen shot about project structure in Eclipse

greenwoodma commented 5 years ago

I'm guessing the difference between the two setups is the way in which eclipse builds the classpath. If you look at the javadoc for the bean the example includes WEB-INF as part of the location path. So try updating your bean definition to

<gate:duplicate id="myApp">
   <gate:saved-application location="WEB-INF/gate-files/application.xgapp" />
</gate:duplicate>

and see if that works correctly in both cases

krishnareddyML commented 5 years ago

it is not working in both eclipse and external tomcat with above change.
And I also tested hands-on Spring boot application given under GATE site (https://gate.ac.uk/sale/talks/gate-course-jun18/module-8-developers/3-advanced-embedded/3-advanced-embedded-hands-on.zip). It is also working in Eclipse environment but failed to work in external Tomcat.

I attached herewith hands-on Spring boot app downloaded from above site, and included required GATE files (sample ANNIE application exported from GATE Dev) under resources folder for your reference. Kindly check is it possible to recreate issue at your end. webapps.zip

Thank you.

greenwoodma commented 5 years ago

Hmm, we think the solution to get it to work in both Eclipse and tomcat is to abandon relative URLs and use a classpath: URL instead. So the snippet should probably read

<gate:duplicate id="myApp">
   <gate:saved-application location="classpath:gate-files/application.xgapp" />
</gate:duplicate>
krishnareddyML commented 5 years ago

yes, classpath prefix fixed the issue.

Thank you for quick fix.