Upload no servidor

Boa tarde, pessoal

estou utilizando o codigo abaixo para fazer upload de arquivos em um projeto (jsf e jpa) no servidor glassfish 3.0, no meu servidor local ele faz certo mas quando eu fui publicar meu projeto ao inves dele fazer o seguinte colocar o arquivo na pasta upload\processo\projeto\documento\arquivo.doc ele cria um arquivo na pasta raiz do meu projeto com o nome de ‘upload\processo\projeto\documento\arquivo.doc’
no caso ao invez dele criar o arquivo na pasta correta ele cria o arquivo como nome das pastas junto no raiz. alguem teria uma solução para isso?

public void enviaArquivo(FileUploadEvent evento) throws Exception {
        FacesContext context = FacesContext.getCurrentInstance();
        ServletContext sc = (ServletContext) context.getExternalContext().getContext();
        String realTargetPath = sc.getRealPath("/");
        
        UploadedFile item = evento.getUploadedFile();
        Arquivo file = new Arquivo();
        file.setLength(item.getData().length);
        file.setName(item.getName());
        file.setData(item.getData());
        
        String filePathName = item.getName();
        String fileName = "";
        String extensao = "";
        StringTokenizer st = new StringTokenizer(filePathName, "\\");
        
        while(st.hasMoreElements()){
            fileName = st.nextToken();
        }
        
        int extDot = fileName.lastIndexOf('.');
        if (extDot > 0) {
            extensao = fileName.substring(extDot + 1);
        }
        
        Date data = new Date();
        DateFormat dtOutput = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
        String now = dtOutput.format(data);
        
        String nome = Integer.toString(CadastroUtil.entidadeAtual) + "-" 
                + Integer.toString(CadastroUtil.anoAtual) + "-"
                + Integer.toString(projeto.getProjetoPK().getiProjeto()) 
                + "-" + now;
        
        if(file.getMime().equals("file/pdf")){
            realTargetPath = realTargetPath + "upload\\processo\\projeto\\pdf\\" + nome + "." + extensao;
        }else if(file.getMime().equals("file/xls") || file.getMime().equals("file/xlsx")
                || file.getMime().equals("file/doc") || file.getMime().equals("file/docx")){
            realTargetPath = realTargetPath + "upload\\processo\\projeto\\documento\\" + nome + "." + extensao;
        }else{
            realTargetPath = realTargetPath + "upload\\processo\\projeto\\imagem\\" + nome + "." + extensao;
        }
        
        OutputStream out = new FileOutputStream(realTargetPath);
        
        try{
            out.write(item.getData());
            out.close();
        } catch(IOException e) {
            
        }
    }

“Publicar” se refere a hospedar em um servidor por aí a fora? Talvez seja por causa do ambiente (Windows/Linux) que você usa localmente e o ambiente do servidor.
E sempre use File.pathSeparator ao invés das barras ("\").