2012-02-14 8 views
0

私はApache Cxfでかなり新しく、この技術を使ってWebサービスを開発しました。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。 1.jar、geronimo-javamail_1.4_spec-1.3.jar、geronimo-servlet_2.5_spec-1.2.jar、geronimo-ws-metadata_2.0spec-1.1.2.jar、jaxb-api-2.1.jar、jaxb-impl- 2.1.7.jar、neethi-2.0.4.jar、saaj-api-1.3.jar、saaj-impl-1.3.2.jar、wsdl4j-1.6.2.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; 

    } 

これは、実装ファイルです:

これはインタフェースであり、

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方法:

hashMapItemsはapplicationContext.xmlを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; 

} 

ある:

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

@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これは私のテストのJUnitファイルです。マーシャリングエラー:com.dosideas.cxf.Itemはこのコンテキストでは認識されません

私にはわかりません私は3日間ブログを読んで過ごしました。助けてください!

+0

あなたの 'Item'クラスはJAXBによって注釈されません。あなたがこの技術に慣れていないようで、もし私がWSDLから 'wsimport'を使ってBeanを生成するよう提案したら、これで遊んでください。自信があるならば、Beanを修正してください。 –

+0

レスポンスdma_kのthxです.cxfのnewbeeですが、webservicesは開発されていません。それはcxf doesnt marshallアイテムpojoのように見えます、どうして虚構な地獄はそれをしないのですか?その間、私はwsimport – aironman

+0

を再度チェックします。こんにちは、私の問題を解決しました。申し訳ありませんが、デフォルトのスコープコンストラクタis not public、arggg。とにかく、答えを教えてください – aironman

答えて

0

私の問題を解決しました。申し訳ありませんが、デフォルトのスコープコンストラクタwas not public、argggです。とにかく、答えは

関連する問題