users@glassfish.java.net

Re: EJB Container initialization error

From: <glassfish_at_javadesktop.org>
Date: Fri, 30 Apr 2010 04:06:15 PDT

ok this is the code :
EJB class :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.Bridge.finalStep;

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;

/**
 *
 * @author mdieng
 */
@Singleton
public class JavaBeans {
     private String word ;
    private int tLang, fLang;
    /*public JavaBeans(){
        init();
    }*/
@PostConstruct
private void init(){
    word ="haus";
    fLang =1;
    tLang=2;
}
    /*
     * return the given word
     */
    public String getWord(){
        return word;
    }
    /*
     * the word to set
     */
    public void setWord(String word){
        this.word=word;
    }
    /*
     * return the original language of the word to translate
     */
    public int getfLang(){
        return fLang;
    }
    /*
     * setting the from language
     */
    public void setfLang(int fLang){
        this.fLang=fLang;
    }
    /*
     * return the destination language
     */
    public int gettLang(){
        return tLang;
    }
    /*
     * setting the destination language
     */
    public void settlang(int tLang){
        this.tLang=tLang;
    }

}



Webservice :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.Bridge.finalStep;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.xml.ws.WebServiceRef;

/**
 * REST Web Service
 *
 * @author mdieng
 */

@Path("translating")
@Stateless
public class TranslatingResource {
    @WebServiceRef(wsdlLocation = "WEB-INF/wsdl/api.xlingua.de/XLinguaService.svc.wsdl")
    private XLinguaService service;

     private java.lang.Integer fLang ;
     private java.lang.Integer tLang;
     private java.lang.String word ;
     
    @EJB
    private JavaBeans javaBeans;
    @Context
    private UriInfo context;

    /** Creates a new instance of TranslatingResource */
    public TranslatingResource() {
        this.getXml();
    }

    /**
     * Retrieves representation of an instance of com.Bridge.finalStep.TranslatingResource
     * @return an instance of com.microsoft.schemas._2003._10.serialization.arrays.ArrayOfanyType
     */
    @GET
    @Produces("application/xml")
    public List<String> getXml() {
        javaBeans = new JavaBeans();
        ArrayList<String> array = new ArrayList<String>();
        try { // Call Web Service Operation
            com.Bridge.finalStep.IXLinguaService port = service.getWSHttpBindingIXLinguaService();
            // TODO initialize WS operation arguments here
             fLang = javaBeans.getfLang();
             tLang = javaBeans.gettLang();
             word = javaBeans.getWord();
            // TODO process result here
            com.Bridge.finalStep.ArrayOfanyType result = port.getTranslations(fLang, tLang, word);
            array.add(result.getAnyType().get(0).toString());
            System.out.println("Result = "+result);
        } catch (Exception ex) {
            System.out.println(ex.getStackTrace());
        }
        return array;
    }

    /**
     * PUT method for updating or creating an instance of TranslatingResource
     * @param content representation for the resource
     * @return an HTTP response with content of the updated or created resource.
     */
    @PUT
    @Consumes("application/xml")
    public void putXml(int l1, int l2, String w) {
        javaBeans.setfLang(l1);
        javaBeans.setfLang(l2);
        javaBeans.setWord(w);
    }
}

thanks in advance
[Message sent by forum member 'diengsallah']

http://forums.java.net/jive/thread.jspa?messageID=399740