You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2011/08/28 03:21:38 UTC
[jira] [Commented] (CXF-3771) Excluded service methods not excluded
in OSGi
[ https://issues.apache.org/jira/browse/CXF-3771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13092405#comment-13092405 ]
Freeman Fang commented on CXF-3771:
-----------------------------------
Hi,
I'd like to see how you package the bundle.
e.g., what your pom.xml looks like, that's import to know if you correctly import necessary package with maven-bundle-plug.
If you can append a src project with pom.xml which we can build and deploy, that would be great.
Freeman
> Excluded service methods not excluded in OSGi
> ---------------------------------------------
>
> Key: CXF-3771
> URL: https://issues.apache.org/jira/browse/CXF-3771
> Project: CXF
> Issue Type: Bug
> Components: OSGi
> Affects Versions: 2.4.2
> Environment: Windows XP; ServiceMix (or Talend TSF)
> Reporter: Barry Hathaway
>
> I have a annotated web service consisting of an interface and an implementation that works just fine under CXF running in a Tomcat container. When I try to move it to an OSGi environment (either SMX or TSF) I get the exception below. The problem seems to be that the 2 excluded methods getServiceNameMap and setServiceNameMap are trying to get processed by JAXB when they should have been excluded and only called by Spring at bean creation.
> karaf@root> Exception in thread "SpringOsgiExtenderThread-6" org.springframework.beans.factory.BeanCreationException: Error creating b
> th name 'SadlService': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.
> y.ServiceConstructionException
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFact
> va:1420)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactor
> :519)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.
> 56)
> at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
> at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.ja
> )
> at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.j
> 5)
> at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutio
> cationContext.java:69)
> at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionAppli
> Context.java:355)
> at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExec
> pplicationContext.java:320)
> at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshT
> n(DependencyWaiterApplicationContextExecutor.java:132)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
> at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)
> at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
> at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapable
> ctory.java:1544)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanF
> .java:1485)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFact
> va:1417)
> ... 14 more
> Caused by: org.apache.cxf.service.factory.ServiceConstructionException
> at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:292)
> at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
> at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:438)
> at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)
> at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)
> at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
> at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
> at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:157)
> at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
> at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433)
> at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322)
> ... 23 more
> Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
> java.util.Map is an interface, and JAXB can't handle interfaces.
> this problem is related to the following location:
> at java.util.Map
> at private java.util.Map com.ge.research.sadl.sadlserver.cxf.provider.jaxws_asm.SetServiceNameMap.arg0
> at com.ge.research.sadl.sadlserver.cxf.provider.jaxws_asm.SetServiceNameMap
> java.util.Map does not have a no-arg default constructor.
> this problem is related to the following location:
> at java.util.Map
> at private java.util.Map com.ge.research.sadl.sadlserver.cxf.provider.jaxws_asm.SetServiceNameMap.arg0
> at com.ge.research.sadl.sadlserver.cxf.provider.jaxws_asm.SetServiceNameMap
> at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
> at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
> at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
> at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
> at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
> at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:213)
> at javax.xml.bind.ContextFinder.find(ContextFinder.java:387)
> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:618)
> at org.apache.cxf.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:258)
> at org.apache.cxf.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:167)
> at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:418)
> at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:290)
> ... 34 more
> -------- Sample Code --------------
> Interface file: ISadlServiceProvider.java
> package com.ge.research.sadl.sadlserver.cxf.provider;
> import java.util.List;
> import java.util.Map;
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebService;
> /**
> * Interface of the SadlService which creates a SADL Server for use
> * in a CXF environment.
> *
> * @author Barry Hathaway
> */
> @WebService(name="SadlService",targetNamespace="http://sadlserver.sadl.research.ge.com")
> public interface ISadlServiceProvider {
> /**
> * Gets the service name map which translates the service name into a
> * knowledge base identifier and model name.
> *
> * @return Service name map
> */
> public Map<String,String[]> getServiceNameMap();
> /**
> * Sets the service name map which translates the service name into a
> * knowledge base identifier and model name.
> *
> * @param Service name map
> */
> public void setServiceNameMap(Map<String,String[]> serviceNameMap);
> /**
> * Gets the SADL server implementation class name
> *
> * @return SadlServer class name
> * @throws com.ge.research.sadl.sadlserver.SessionNotFoundException
> */
> @WebMethod(operationName="getClassName", action="urn:getClassName")
> public String getClassName();
> }
> -------------
> Implementation file: SadlServiceProvider.java
> package com.ge.research.sadl.sadlserver.cxf.provider;
> import java.io.BufferedWriter;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.URL;
> import java.util.ArrayList;
> import java.util.Arrays;
> import java.util.Iterator;
> import java.util.List;
> import java.util.Map;
> import java.util.Scanner;
> import javax.activation.DataSource;
> import javax.activation.FileDataSource;
> import javax.activation.URLDataSource;
> import javax.jws.WebMethod;
> import javax.jws.WebService;
> import org.apache.cxf.annotations.FactoryType;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> /**
> * Implementation of the SadlService which creates a SADL Server for use
> * in a CXF environment.
> *
> * @author Barry Hathaway
> */
> @WebService(serviceName="SadlService",name="SadlService",targetNamespace="http://sadlserver.sadl.research.ge.com",endpointInterface="com.ge.research.sadl.sadlserver.cxf.provider.ISadlServiceProvider")
> public class SadlServiceProvider implements ISadlServiceProvider {
> private Logger logger = LoggerFactory.getLogger(getClass());
> ISadlServer server = null;
> public static final String SERVER = "server";
> private Map<String,String[]> serviceNameMap = null;
> /**
> * Gets the service name map which translates the service name into a
> * knowledge base identifier and model name.
> *
> * @return Service name map
> */
> @WebMethod(exclude=true)
> public Map<String,String[]> getServiceNameMap() {
> return serviceNameMap;
> }
> /**
> * Sets the service name map which translates the service name into a
> * knowledge base identifier and model name.
> *
> * @param Service name map
> */
> @WebMethod(exclude=true)
> public void setServiceNameMap(Map<String,String[]> serviceNameMap) {
> this.serviceNameMap = serviceNameMap;
> Iterator<String> it = this.serviceNameMap.keySet().iterator();
> while (it.hasNext()) {
> String key = it.next();
> String[] val = this.serviceNameMap.get(key);
> logger.debug("ServiceNameMap: "+ key +" = "+ val[0] +" : "+ val[1]);
> }
> this.server.setServiceNameMap(serviceNameMap);
> }
> /**
> * Default constructor
> */
> public SadlServiceProvider() {
> logger.debug("constructor called");
> // this.server = new SadlServerImpl();
> }
>
> /**
> * Gets the SADL server implementation class name
> *
> * @return SadlServer class name
> * @throws com.ge.research.sadl.sadlserver.SessionNotFoundException
> */
> public String getClassName() {
> return this.getClass().getName();
> }
> }
> -----
> beans.xml file
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxws="http://cxf.apache.org/jaxws"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> -->
> <!-- <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> -->
> <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />
> <bean id="sadlServiceProvider" scope="session" class="com.ge.research.sadl.sadlserver.cxf.provider.SadlServiceProvider">
> <aop:scoped-proxy/>
> <property name="serviceNameMap">
> <map>
> <entry key="cfm56_7_top">
> <list>
> <value>D:\projects\SADL\SadlServerV2Standalone\DataModels\InScope</value>
> <value>http://ctp.geae.ge.com/iws/cfm56_7_top</value>
> </list>
> </entry>
> <entry key="cfm56-7_full_test1">
> <list>
> <value>D:\projects\SADL\SadlServerV2Standalone\DataModels\InScope</value>
> <value>http://ctp.geae.ge.com/iws/cfm56-7_full_test1</value>
> </list>
> </entry>
> <entry key="shapes_test">
> <list>
> <value>D:\projects\SADL\SadlServerV2Standalone\DataModels\ShapesDemo</value>
> <value>http://sadl.imp/shapes_test</value>
> </list>
> </entry>
> <entry key="shapes_rules">
> <list>
> <value>D:\projects\SADL\SadlServerV2Standalone\DataModels\ShapesDemo</value>
> <value>http://sadl.imp/shape_rules</value>
> </list>
> </entry>
> </map>
> </property>
> </bean>
> <jaxws:endpoint
> id="SadlService"
> implementor="#sadlServiceProvider"
> address="/SadlService" />
>
> </beans>
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira