Search code examples
gradlespring-ws

gradle build causing error :startScripts Failed


I am following the step-by-step instructions provided in http://spring.io/guides/gs/consuming-web-service/#scratch to learn how to consume a SOAP web service using Gradle and Spring-WS. I have created the folder structure specified in the above URL (namely., c:/src/main/java/hello) and copied the source code for build.gradle, WeatherClient.java, WeatherConfiguration.java and Application.java into this directory structure. When I execute the command "gradle build" in c:\src\main\java\hello, I am getting the following error:

FAILURE: Build failed with an exception. * What went wrong: A problem was found with the configuration of task ':startScripts'.

No value has been specified for property 'mainClassName'.

Following a suggestion I found in one of the Q&A in stackoverflow, I included mainClassName = '' at the end of the build.gradle file. The above error was overcome, but I do not find the "gs-consuming-web-service.jar" file in the C:\src\main\java\hello\build\libs folder as suggested by the instructions. Rather, I find a jar file named "hello.jar" in this folder.

And if I try to execute the hello.jar executable, I get a java.lang.ClassNotFoundException.

Has anyone tried to follow the instructions given in the URL: http://spring.io/guides/gs/consuming-web-service/#scratch with success? If yes, can you please advise where I have gone wrong?


Solution

  • I was able to get the demo project work by following the steps:

    1. Create a folder named gs-consuming-web-service and in it, create a file named build.gradle with the source code provided in http://spring.io/guides/gs/consuming-web-service/#scratch. Add an extra dependency (the one that is highlighted below) in this build.gradle file at the location below:

      dependencies {
          compile("org.springframework.boot:spring-boot-starter")
          compile("org.springframework.ws:spring-ws-core")
          compile(files(genJaxb.classesDir).builtBy(genJaxb))
          **compile("org.springframework:spring-web:4.1.4.RELEASE")**
      
          jaxb "com.sun.xml.bind:jaxb-xjc:2.1.7"
      }
      
    2. Create the directory structure ...gs-consuming-web-service/src/main/java/hello and in the hello folder, create the java files for WeatherClient.java, WeatherConfiguration.java and Application.java using the source code in http://spring.io/guides/gs/consuming-web-service/#scratch.

    3. Launch InteliJ IDE and select the import project option. In the ensuing screen/step, select the build.gradle file in gs-consuming-web-service folder. Select check-boxes "Use auto-import" and "Create directories for empty content roots automatically". In this screen, make sure that the Gradle home, Gradle JVM are pre-populated correctly (in my case, these have been pre-populated with the path to Gradle-2.8 and JDK 1.8 respectively). Click OK.

    4. At command prompt window, while within the gs-consuming-web-service folder, execute the command "gradle build".

    This should get you to a successful gradle build. Good luck and happy learning.