You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Bruce Edge <br...@gmail.com> on 2009/05/06 18:28:30 UTC

Re: Service path name hell - fixed - getRest bug?

I'm up and running now, but I think a change in the getRest error
handling is in order.

My problem was a missing "/" in the cxf-servelet.xml, the address was
"dpmcore" instead of "/dpmcore"

<jaxws:endpoint id="dpmcore"
      implementor="com.lsi.dpm.core.DpmCorePortTypeImpl"
      address="/dpmcore"
      wsdlLocation="WEB-INF/wsdl/DpmCore.wsdl">
   </jaxws:endpoint>

This code in URIMappingInterceptor:241

private String getRest(Message message) {
        String path = (String)message.get(Message.PATH_INFO);
        String basePath = getBasePath(message);
        return StringUtils.diff(path, basePath);
    }

    protected String getOperationName(Message message) {
        String rest = getRest(message);
        String opName = StringUtils.getFirstNotEmpty(rest, "/");
        if (opName.indexOf("?") != -1) {
            opName = opName.split("\\?")[0];
        }

and this in StringUtils.java:113

  public static String diff(String str1, String str2) {
        int index = str1.lastIndexOf(str2);
        if (index > -1) {
            return str1.substring(str2.length());
        }
        return str1;
    }

Did not help and obscured the error.

When I passed in services/dpmcore/funcname I would get back an
operation name of "e" because the StringUtils.diff was looking at the
length of the
      address="dpmcore"  (missing "/")
string in cxf-servelet.xml
 and therefore returned "e/funcname" instead of "/funcname" , which
was then truncated to just "e".

There is no check in in getRest to verify that the vars path and
basePath actually match for the length of basePath. If this were
checked and an exception thrown, then this would have been a much
easier fix.

-Bruce


On Tue, May 5, 2009 at 11:59 PM, Diefenbach Anne <Di...@fgan.de> wrote:
> Hi Bruce,
>
> maybe more knowledgeable people will correct me, but it seems to me that "address" in cxf-servlet.xml should be set to "http://localhost:8080/DpmCore/services/DpmCorePortType" and in @javax.jws.WebService "wsdlLocation" should be "WEB-INF/wsdl/DpmCore.wsdl".
>
> Regards,
> Anne
>
> -----Ursprüngliche Nachricht-----
> Von: Bruce Edge [mailto:bruce.edge@gmail.com]
> Gesendet: Mittwoch, 6. Mai 2009 04:44
> An: users@cxf.apache.org
> Betreff: Service path name hell
>
> Apolgies for the long post but I'm on the hook for a working proof of
> concept here.
>
> I have an app that runs only form eclipse. I think there's an
> inconsistency in the service path name, which is set in a bunch of
> different places.
> Are all of these needed, and should they all be the same, or do some
> need "Impl", or "PortType", etc... after them.
>
> The wsdl has:
>
> <portType name="DpmCorePortType">
> ...
> <binding name="DpmCoreBinding" type="tns:DpmCorePortType">
> ...
> and
> <service name="DpmCoreService">
>        <port binding="tns:DpmCoreBinding" name="DpmCorePort">
>                <soap:address
> location="http://localhost:8080/DpmCore/services/DpmCorePortType" />
>        </port>
> </service>
>
> The cxf-servelet.xml has:
>
> <jaxws:endpoint id="dpmcore"
>      implementor="com.lsi.dpm.core.DpmCorePortTypeImpl"
>      address="dpmcore"
>      wsdlLocation="WEB-INF/wsdl/DpmCore.wsdl">
> </jaxws:endpoint>
>
> (here if I remove the "Impl" the jetty-runner parser fails on the xml file.)
>
> And the app's *Impl.java file has:
>
> @javax.jws.WebService(
>                      serviceName = "DpmCoreService",
>                      portName = "DpmCorePort",
>                      targetNamespace = "http://lsi.com/dpm/core",
>                      wsdlLocation =
> "http://localhost:8080/DpmCore/services/DpmCorePortType",
>                      endpointInterface = "com.lsi.dpm.core.DpmCorePortType")
>
> and the apps main has:
>
> public class DpmCorePortType_DpmCorePort_Server{
>    public static final Logger LOGGING = Logger.getLogger("MAIN");
>    protected DpmCorePortType_DpmCorePort_Server() throws Exception {
>        Object implementor = new DpmCorePortTypeImpl();
>        String address =
> "http://localhost:8080/DpmCore/services/DpmCorePortType";
>        Endpoint.publish(address, implementor);
>
> So there are 4 or 5 "DpmCore/services/DpmCorePortType" type strings
> here and I can't figure out what combination is valid to get this
> thing up and running without life support.
>
> Eclipse is just intelligent enough to let me believe that it's
> working, but deploying under jetty, tomcat, or jetty-runner all fail
> complaining about endpoint creation,
>
>
> Tomcat does this:
> May 5, 2009 7:20:54 PM org.apache.catalina.core.ApplicationContext log
> SEVERE: StandardWrapper.Throwable
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'dpmcore': Invocation of init method failed;
> nested exception is javax.xml.ws.WebServiceException:
> org.apache.cxf.service.factory.ServiceConstructionException: Failed to
> create service.
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
>        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
>        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
>        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
>        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
>        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
>        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
>        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
>        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
>        at org.apache.cxf.transport.servlet.CXFServlet.loadAdditionalConfig(CXFServlet.java:166)
>
>
> jetty-runner does this: (no errors, but I can't find the service on
> any url either)
>
> 2009-05-05 19:25:48.864::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
> 2009-05-05 19:25:48.865::INFO:  Runner
> 2009-05-05 19:25:48.865::WARN:  No tx manager found
> 2009-05-05 19:25:48.947::INFO:  jetty-7.0.0.pre5
> 2009-05-05 19:25:49.999::INFO:  Extract
> jar:file:/import/gin/bedge/dev_kaan/Apps/ws/core/service-war/target/DpmCore.war!/
> to /tmp/Jetty_0_0_0_0_8080_DpmCore.war____.psrykp/webapp
> 2009-05-05 19:25:49.375::INFO:  No Transaction manager found - if your
> webapp requires one, please configure one.
> 2009-05-05 19:25:49.916:/:INFO:  Initializing Spring root WebApplicationContext
> May 5, 2009 7:25:49 PM org.springframework.web.context.ContextLoader
> initWebApplicationContext
> INFO: Root WebApplicationContext: initialization started
> May 5, 2009 7:25:49 PM
> org.springframework.context.support.AbstractApplicationContext
> prepareRefresh
> INFO: Refreshing
> org.springframework.web.context.support.XmlWebApplicationContext@1af33d6:
> display name [Root WebApplicationContext]; startup date [Tue May 05
> 19:25:49 PDT 2009]; root of context hierarchy
> May 5, 2009 7:25:49 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader
> loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [META-INF/cxf/cxf.xml]
> May 5, 2009 7:25:50 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader
> loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [META-INF/cxf/cxf-extension-soap.xml]
> May 5, 2009 7:25:50 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader
> loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [META-INF/cxf/cxf-servlet.xml]
> May 5, 2009 7:25:50 PM
> org.springframework.context.support.AbstractApplicationContext
> obtainFreshBeanFactory
> INFO: Bean factory for application context
> [org.springframework.web.context.support.XmlWebApplicationContext@1af33d6]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@17b0998
> May 5, 2009 7:25:50 PM
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@17b0998:
> defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.servlet.ServletTransportFactory];
> root of factory hierarchy
> May 5, 2009 7:25:50 PM org.springframework.web.context.ContextLoader
> initWebApplicationContext
> INFO: Root WebApplicationContext: initialization completed in 811 ms
> May 5, 2009 7:25:50 PM org.apache.cxf.transport.servlet.CXFServlet updateContext
> INFO: Load the bus with application context
> May 5, 2009 7:25:50 PM
> org.springframework.context.support.AbstractApplicationContext
> prepareRefresh
> INFO: Refreshing
> org.apache.cxf.bus.spring.BusApplicationContext@1015a9e: display name
> [org.apache.cxf.bus.spring.BusApplicationContext@1015a9e]; startup
> date [Tue May 05 19:25:50 PDT 2009]; parent:
> org.springframework.web.context.support.XmlWebApplicationContext@1af33d6
> May 5, 2009 7:25:50 PM org.apache.cxf.bus.spring.BusApplicationContext
> getConfigResources
> INFO: No cxf.xml configuration file detected, relying on defaults.
> May 5, 2009 7:25:50 PM
> org.springframework.context.support.AbstractApplicationContext
> obtainFreshBeanFactory
> INFO: Bean factory for application context
> [org.apache.cxf.bus.spring.BusApplicationContext@1015a9e]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@1954f89
> May 5, 2009 7:25:50 PM
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@1954f89:
> defining beans []; parent:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@17b0998
> May 5, 2009 7:25:50 PM
> org.apache.cxf.transport.servlet.AbstractCXFServlet
> replaceDestinationFactory
> INFO: Servlet transport factory already registered
> May 5, 2009 7:25:50 PM org.apache.cxf.transport.servlet.CXFServlet
> loadAdditionalConfig
> INFO: Build endpoints from config-location: /WEB-INF/cxf-servlet.xml
> May 5, 2009 7:25:50 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader
> loadBeanDefinitions
> INFO: Loading XML bean definitions from /WEB-INF/cxf-servlet.xml
> Loaded 2 entries from config.properties file: /etc/dpm/config.properties
> May 5, 2009 7:25:50 PM
> org.springframework.context.support.AbstractApplicationContext
> prepareRefresh
> INFO: Refreshing
> org.springframework.context.support.GenericApplicationContext@ac06d4:
> display name [org.springframework.context.support.GenericApplicationContext@ac06d4];
> startup date [Tue May 05 19:25:50 PDT 2009]; parent:
> org.springframework.web.context.support.XmlWebApplicationContext@1af33d6
> May 5, 2009 7:25:50 PM
> org.springframework.context.support.AbstractApplicationContext
> obtainFreshBeanFactory
> INFO: Bean factory for application context
> [org.springframework.context.support.GenericApplicationContext@ac06d4]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@df0256
> May 5, 2009 7:25:50 PM
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@df0256:
> defining beans [dpmcore]; parent:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@17b0998
> May 5, 2009 7:25:50 PM
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean
> buildServiceFromWSDL
> INFO: Creating Service {http://lsi.com/dpm/core}DpmCoreService from
> WSDL: WEB-INF/wsdl/DpmCore.wsdl
> May 5, 2009 7:25:51 PM org.apache.cxf.endpoint.ServerImpl initDestination
> INFO: Setting the server's publish address to be dpmcore
> 2009-05-05 19:25:51.244::INFO:  Started SelectChannelConnector@0.0.0.0:8080
>
> -Bruce
>