0

I tried to create a spring boot deployable war file and then deployed it to weblogic 12c. Application startup failed with the exception:

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
ERROR SpringApplication - Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLServletRegistrationBean' defined in class path resource
...

Nested exception is:

java.lang.IllegalStateException: No *.graphqls files found on classpath.  Please add a graphql schema to the classpath or add a SchemaParser bean to your application context.

In fact, the above mentioned files *.graphqls exist in the war under WEB-INF/classes/ folder. If the war file was unzipped to the local disk and redeploy the app in exploded format, we won't see this exception.

Do I miss anything?

Thanks.

glytching
  • 44,936
  • 9
  • 114
  • 120
user3432316
  • 81
  • 1
  • 1
  • 6
  • 1
    spring boot is intended to run independently not inside an app server – jmhostalet Sep 28 '17 at 09:17
  • do you follow the guides to deploy a spring-boot app on weblogic? You will need some additional config files. – Patrick Sep 28 '17 at 09:43
  • 2
    @jmhostalet you statement is not true. Spring Boot application can be deployed in App Servers also, we are deploying Spring Boot application in JBoss for past 2 years. https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html – seenukarthi Sep 28 '17 at 09:50
  • Actually I can deploy this war file to TOMCAT and run it without problem. This is the code to load resource files: Resource[] resources = applicationContext.getResources("classpath*:**/*.graphqls"); if(resources.length <= 0) { throw new IllegalStateException("No *.graphqls files found on classpath. Please add a graphql schema to the classpath or add a SchemaParser bean to your application context."); } – user3432316 Sep 28 '17 at 10:58

3 Answers3

1

I wasted 8 hours in this loophole, piecing together various clues I got from other people facing the same problem.

**solution 1 is to deploy your application as exploded WAR in Weblogic. I assume you already prepared your spring boot application for deployment on Weblogic, there are several tricks on this topic but they are available on the Internet (exclude embedded tomcat and specify WAR packaging in POM.XML, create webapp/WEB-INF folder with weblogic.xml and servlet xml).

Now create a folder on the server, /home/oracle/wars/myapp for example, and just copy the unpacked contents of your WAR to that folder.

Then go to Deployments - Install, navigate to /home/oracle/wars/ and choose myapp folder from the radio button list, and simply follow the default steps to deploy.

Pay attention, you need a plain web.xml file along with weblogic.xml, otherwise Weblogic will not see it as 'Web application'**

Deploying as exploded WAR is a workaround to avoid the creation of _wl_cls_gen.jar which is at the source of this problem.

** Solution 2 By default the lookup location is set to "classpath:graphql/**/" which is not picked up by PathMatchingResourcePatternResolver. Set this in your application yaml or properties:

spring: graphql: schema: locations: classpath*:graphql/**/

Finally, for this particular error, **/*.graphqls file not found when deploying to weblogic, nothing of the below worked, I am mentioning it so you don't waste your time as well:

  1. Adding resource tag in POM

    src/main/resources **/*.properties **/*.graphqls
  2. Adding in application.properties graphql.tools.schema-location-pattern=**/*.graphqls

  3. Adding in application.properties graphql.servlet.exception-handlers-enabled=true

  4. Newer versions of GraphQL libraries, I tried it and everything fails with this error from graphql 7.0.1 onwards

  5. Adding spring-boot-starter-parent in POM

0

Without seeing your code, or knowing your spring-boot version, it's difficult to really diagnose your issue. There were small changes here and there that had to be to get my spring-boot app to run on WebLogic. Thinks like inclusion of weblogic.xml and some dependencies here and there

The main one being the addition of implements WebApplicationInitializer to my application class like so.

@SpringBootApplication
public class Application extends SpringBootServletInitializer
    implements
    WebApplicationInitializer {

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }

}

It looks like a few other had issues similar to yours, maybe these can help you out. It seems like you might be having issues with having spring-boot with other spring (but not spring-boot) dependencies. It's impossible to really tell as I don't know what your pom file or application class file look like.

One

Two

Three

Four

Tbuddy
  • 73
  • 5
  • Hi I'm trying to deploy and run this demo application in weblogic server. The source code can be found at: https://github.com/spring-petclinic/spring-petclinic-graphql/tree/master/backend As you suggested, I also made a few changes to the application: 1. modify the main application as: @SpringBootApplication public class PetClinicApplication extends SpringBootServletInitializer implements WebApplicationInitializer 2. add weblogic.xml to remove dependency conflicts true – user3432316 Sep 29 '17 at 01:48
0

I've figured out the cause of this issue. It's a bit odd in weblogic when deploying war file. It creates an internal _wl_cls_gen.jar file to package all files for /WEB-INF/classes folder.

but the application still looks for resources in match directory like /j2ee/wl12/cp_domain/servers/cp_msp01/tmp/_WL_user/cpapps-graphql-results/g4qyhf/war/WEB-INF/classes/**/*.graphqls and find nothing matched.

user3432316
  • 81
  • 1
  • 1
  • 6