2012-02-14 1 views
0

저는 아파치 cxf가 새로 도입되었으므로이 기술을 사용하여 웹 서비스를 개발했습니다.org.apache.cxf.interceptor.Fault : 마샬링 오류 : com.dosideas.cxf.Item이이 컨텍스트에 알려져 있지 않습니다.

XmlSchema-1.4.2.jar, commons-logging-1.1.1.jar, cxf-2.1.3.jar, geronimo-activation_1.1_spec-1.0.2.jar, geronimo-annotation_1.0_spec-1.1. jar, geronimo-javamail_1.4_spec-1.3.jar, xml-resolver-1.2.jar

:

@WebService 
public interface StoreAdmin 
{ 
    boolean logIn(@WebParam(name="legajo") String legajo 
      ,@WebParam(name="lat") String lat 
      ,@WebParam(name="lon") String lon)               throws StoreException; 

    boolean logOut(@WebParam(name="legajo") String legajo)              throws StoreException; 


    boolean addItemToSystem(@WebParam(name="isbn") String isbn 
         ,@WebParam(name="descripcion") String descripcion 
         ,@WebParam(name="precio") double precio 
         ,@WebParam(name="numeroTotal") int numeroTotal)            throws StoreException; 
    @WebResult(name="item") 
    com.dosideas.cxf.Item getItem(@WebParam(name="isbn") String isbn)            throws StoreException; 

    } 

이 구현 파일입니다

이 인터페이스입니다3210

package com.dosideas.cxf; 

    import com.dosideas.cxf.exception.StoreException; 
    import com.dosideas.cxf.service.ServicioEncriptacion; 
    import com.dosideas.cxf.service.ServicioItems; 
    import com.dosideas.cxf.service.ServicioUsuarios; 
    import java.util.logging.Level; 
    import java.util.logging.Logger; 
    import javax.jws.WebService; 

    /** 
    * 
    * @author alonso 
    */ 
    @WebService(endpointInterface = "com.dosideas.cxf.StoreAdmin",serviceName="storeAdmin") 
    public class StoreAdminImpl implements StoreAdmin{ 

    //injectd by spring 
    private ServicioUsuarios   servicioUsuarios; 
    private ServicioEncriptacion  servicioEncriptacion; 
    private ServicioItems    servicioItems; 

    //constructor... 
    StoreAdminImpl(ServicioUsuarios _servicioUsuarios 
      , ServicioEncriptacion _servicioEncriptacion 
      ,ServicioItems _servicioItems) 
    { 
    this.servicioUsuarios=_servicioUsuarios; 
    this.servicioEncriptacion=_servicioEncriptacion; 
    this.servicioItems=_servicioItems;   
} 

... 
// there are more methods but I don't put here, not relevant 

public Item getItem(String isbn) throws StoreException { 
    return servicioItems.getItem(isbn); 
} 

public ServicioUsuarios getServicioUsuarios() 
{ 
    return servicioUsuarios; 
} 
}

ServicioItemsImpl.getItem 방법 :

<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" /> 


<!-- Declaramos el bean implementación del Servicio Web. Como vemos, es 
    un bean más de Spring, por lo que podemos inyectarle dependencias, 
    interceptores, y demás. 
--> 
<bean id="holaMundoImpl" class="com.dosideas.cxf.HolaMundoImpl"/> 

<bean id="servicioUtiles" class="com.dosideas.cxf.service.ServicioUtilesImpl"/> 

<bean id="servicioUsuarios" class="com.dosideas.cxf.service.ServicioUsuariosImpl"> 
    <constructor-arg ref="servicioUtiles"/> 
    <constructor-arg ref="servicioEncriptacion"/> 
</bean> 

<bean id="servicioEncriptacion" class="com.dosideas.cxf.service.ServicioEncriptacionImpl"/> 

<bean id="servicioItems" class="com.dosideas.cxf.service.ServicioItemsImpl"/> 

<bean id="servicioApuntesContables" class="com.dosideas.cxf.service.ServicioApuntesContablesImpl"/> 

<bean id="storeImpl" class="com.dosideas.cxf.StoreImpl"> 
    <constructor-arg ref="servicioUsuarios"/> 
    <constructor-arg ref="servicioEncriptacion"/> 
    <constructor-arg ref="servicioItems"/> 
    <constructor-arg ref="servicioApuntesContables"/> 
</bean> 

<bean id="storeAdminImpl" class="com.dosideas.cxf.StoreAdminImpl"> 
    <constructor-arg ref="servicioUsuarios"/> 
    <constructor-arg ref="servicioEncriptacion"/> 
    <constructor-arg ref="servicioItems"/> 
</bean> 


<!-- Declaramos el endpoint de nuestro servicio web, indicando cual es la 
    clase de implementación. En el atributo "implementor" podemos escribir 
    el nombre completo de la clase implementación, o referenciar a un 
    bean de Spring usando un # seguido del nombre del bean. 
--> 
<jaxws:endpoint 
    id="holaMundo" 
    implementor="#holaMundoImpl" 
    address="/HolaMundo" /> 

<jaxws:endpoint 
    id="store" 
    implementor="#storeImpl" 
    address="/StoreImpl" /> 

<jaxws:endpoint 
    id="storeAdmin" 
    implementor="#storeAdminImpl" 
    address="/StoreAdminImpl" /> 

,935 :

hashMapItems는 ConcurrentHashMap의

public Item getItem(String isbn) throws StoreException 
    { 
    Logger.getLogger(ServicioItemsImpl.class.getName()).log(Level.INFO, "ServicioItemsImpl. INIT getItem."); 

    Item item = (Item) ServicioItemsImpl.hashMapItems.get(isbn); 
    if (item==null) 
    { 
     Logger.getLogger(ServicioItemsImpl.class.getName()).log(
      Level.WARNING, "ServicioItemsImpl. METHOD: getItem. ERROR. el item con isbn: {0} no existe en el sistema.", isbn); 

     //throw new StoreException("27",isbn,null); 
    } 
    else 
     Logger.getLogger(ServicioItemsImpl.class.getName()).log(
      Level.INFO, "ServicioItemsImpl. END isbn´s Item: {0}",item.getIsbn()); 

    return item; 

} 

이다 applicationContext.xml이 내 테스트 JUnit을 파일입니다

@Test 
public void testGetItem() 
{ 
    Logger.getLogger(StoreAdminTest.class.getName()).log(Level.INFO, "INIT testGetDescriptionItem"); 

    try 
    { 
     boolean retorno = instance.addItemToSystem("8717418323691", "Castle Tercera Temporarada DVD",39.95,100); 
     assertEquals(true,retorno); 

     //broken here 
     //org.apache.cxf.interceptor.Fault: Marshalling Error: com.dosideas.cxf.Item is not known to this context 

     Item item = instance.getItem("8717418323691"); 
     assertEquals(true, item!=null); 
     assertEquals("Castle Tercera Temporarada DVD",item.getDescripcion()); 

    } catch (StoreException ex) { 
     Logger.getLogger(StoreAdminTest.class.getName()).log(Level.SEVERE, null, ex); 
    } 

    Logger.getLogger(StoreAdminTest.class.getName()).log(Level.INFO, "END testGetDescriptionItem"); 

} 

항목 POJO 클래스 :

package com.dosideas.cxf; 

/** 
* 
* @author alonso 
*/ 
public class Item { 

private String isbn; 
private String descripcion; 
private double precio; 
private int numeroTotal; 

Item(){}; 
Item(String isbn,String descripcion,double precio,int numeroTotal) 
{ 
    this.isbn=isbn; 
    this.descripcion=descripcion; 
    this.precio=precio; 
    this.numeroTotal=numeroTotal; 
}; 

public String getDescripcion() { 
    return descripcion; 
} 

public void setDescripcion(String descripcion) { 
    this.descripcion = descripcion; 
} 

public String getIsbn() { 
    return isbn; 
} 

public void setIsbn(String isbn) { 
    this.isbn = isbn; 
} 

public int getNumeroTotal() { 
    return numeroTotal; 
} 

public void setNumeroTotal(int numeroTotal) { 
    this.numeroTotal = numeroTotal; 
} 

public double getPrecio() { 
    return precio; 
} 

public void setPrecio(double precio) { 
    this.precio = precio; 
} 


public void decrementarNumeroTotal() 
{ 
    if (getNumeroTotal()>0) 
     setNumeroTotal(getNumeroTotal() - 1); 
    else 
     setNumeroTotal(0); 
} 

}

예외 로그 :

org.apache.cxf.interceptor.Fault : 마샬링 오류 : com.dosideas.cxf.Item이이 컨텍스트에 알려져 있지 않습니다.

나는 무엇을 해야할지 모르겠다. 계속되고, 나는 3 일을 블로그를 읽는 데에 썼다, 도와주세요!

+0

당신의'Item' 클래스는 JAXB에 의해 주석이 없습니다. 당신이이 기술에 익숙하지 않은 것처럼 보입니다. 그렇다면'wsimport'를 사용하여 WSDL에서 빈을 생성하고 이것을 가지고 놀고 자신감이 있다면 빈을 수정하도록 제안 할 것입니다. 대답 dma_k에 대한 –

+0

thx, 나는 cxf로 꽤 newbee지만 webservices를 개발하지 않습니다. cxf가 아이템 pojo를 마샬링하지 않은 것처럼 보입니다. 왜 그 끔찍한 짓을하지 않습니까? 그 사이에, 나는 wsimport – aironman

+0

안녕하세요 다시 확인, 내 문제를 해결, 미안, 기본 범위 생성자 wasnt 공개, arggg. 어쨌든, 그 대답은. – aironman

답변

0

내 문제를 해결했습니다. 미안하지만, 기본 범위 생성자 wasnt public, arggg입니다. 어쨌든, 대답은

관련 문제