1
votes

I am trying to create SOAP webservice with the PLAY Framework, referred the sample from http://www.imind.eu/web/2013/11/07/developing-soap-services-using-play-framework-2-2-x/ . When I tried to execute the sample , getting this error. Please find my code as below. I not really sure what's the issue with the sample.

ERROR:

! @75olpeh6j - Internal server error, for (GET) [/service/hello?wsdl] ->

play.api.PlayException: Cannot init the Global object[Error creating bean with name 'org.apache.cxf.transport.play.CxfController#0' defined in class path resource [cxf.xml]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.cxf.transport.play.CxfController$]: Factory method 'getInstance' threw exception; nested exception is java.lang.AbstractMethodError: org.apache.cxf.transport.play.CxfController$.play$api$mvc$Results$_setter_$TooManyRequests_$eq(Lplay/api/mvc/Results$Status;)V]
        at play.api.GlobalSettings$.apply(GlobalSettings.scala:229)
        at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$1.apply(GuiceApplicationBuilder.scala:99)
        at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$1.apply(GuiceApplicationBuilder.scala:99)
        at scala.Option.getOrElse(Option.scala:121)
        at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:99)
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:168)
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:164)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.transport.play.CxfController#0' defined in class path resource [cxf.xml]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.cxf.transport.play.CxfController$]: Factory method 'getInstance' threw exception; nested exception is java.lang.AbstractMethodError: org.apache.cxf.transport.play.CxfController$.play$api$mvc$Results$_setter_$TooManyRequests_$eq(Lplay/api/mvc/Results$Status;)V
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1249)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756)

Global.java:

import play.*;
import play.libs.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import play.Application;
import play.GlobalSettings;

public class Global extends GlobalSettings {

    protected ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

    @Override
    public void onStart(Application app) {
        ctx.start();
    }

    @Override
    public void onStop(Application app) {
        ctx.stop();
    }
}

applicationContext.xml:

<!-- applicationContext.xml -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
 http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
 ">

    <!-- Import Apache CXF configuration and Play! transport plugin. -->
    <import resource="classpath:cxf.xml"/>

            <!-- Define Hello World endpoint. It will be available at http://localhost:9000/service/hello -->
    <jaxws:endpoint name="helloWorld"
                    transportId="http://schemas.xmlsoap.org/soap/http"
                    address="/service/hello"
                    implementor="services.hello.HelloWorldImpl"/>

</beans>

build.sbt

name := "play-cxf-hello"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.7"
libraryDependencies += "org.springframework" % "spring-context" % 5.0.1.RELEASE"
libraryDependencies += "eu.imind.play" %% "play-cxf_play24" % "1.2.1"
libraryDependencies += "org.apache.cxf" % "cxf-rt-bindings-soap" % "3.1.7"
libraryDependencies += "org.apache.cxf" % "cxf-rt-frontend-jaxws" % "3.1.7"
lazy val root = (project in file(".")).enablePlugins(PlayJava)

plugins.sbt

// Comment to get more information during initialization
logLevel := Level.Warn

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

resolvers += Resolver.typesafeRepo("releases")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")
1
Your applicationContext.xml says implementor="services.hello.HelloWorldImpl. Can you post you implementor code as well? - codingsplash
please refer imind.eu/web/2013/11/07/… for the implementer, i have used that example only. - Suresh Govi

1 Answers

0
votes

You can replace WSDL generating part with an alternative solution like scalaxb, Apache XF or just generate all the boilerplate with wsimport yourself. To simplify the latter one, take a look at the following project: https://github.com/sainnr/sbt-scala-wsdl-template. Basically, all you need is to wrap a Shell script for wsimport with a build task (the referred project uses SBT but you can adapt it to Gradle or Maven, for example), and then arrange proper task ordering so that all boilerplate code would be generated & compiled before the main business logic. Plus, keeps your repo nice and clean.