Erro ao carregar imagem no servidor de produção

7 views
Skip to first unread message

Lessandro Notaroberto Pyrâmides

unread,
Nov 21, 2014, 5:34:05 PM11/21/14
to jav...@googlegroups.com, jav...@googlegroups.com, javano...@googlegroups.com

Pessoal, boa noite.

Depois de muito lutar e relutar, consegui fazer o redirecionamento da porta 8080 para 80

com o iptables, e configurei no standalone.xml para ao invés de carregar a tela de welcome

padrão do jboss (Wildfly 8.1), ele simplesmente redireciona para a página principal da aplicação.

O mais interessante é que a página principal em si e as demais páginas estão carregando sem

maiores problemas, inclusive as imagens da página principal, mas ao tentar carregar uma

página detalhe que também possui outras imagens, estou obtendo o seguinte erro:

 

2014-11-21 17:03:15,619 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-14) java.io.IOException: Server returned HTTP response code: 502 for URL: http://www.encontreaqui.com:80/imageUserDownload

                at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)

                at br.com.pyramides.service.impl.user.UserImageServiceImpl.downloadImage(UserImageServiceImpl.java:57)

                at br.com.pyramides.service.impl.user.UserImageServiceImpl$$FastClassByCGLIB$$d4e8a00e.invoke(<generated>)

                at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

                at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:618)

                at br.com.pyramides.service.impl.user.UserImageServiceImpl$$EnhancerByCGLIB$$998f4c45.downloadImage(<generated>)

                at br.com.pyramides.controller.ProductBookingBean.getImage(ProductBookingBean.java:239)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:606)

                at javax.el.ELUtil.invokeMethod(ELUtil.java:308)

                at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)

                at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)

                at com.sun.el.parser.AstValue.getValue(AstValue.java:136)

                at com.sun.el.parser.AstValue.getValue(AstValue.java:204)

                at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)

                at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)

                at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)

                at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:228)

                at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:89)

                at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)

                at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)

                at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:115)

                at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)

                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857)

                at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)

                at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)

                at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)

                at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:115)

                at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)

                at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)

                at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:115)

                at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)

                at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)

                at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:115)

                at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)

                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857)

                at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:599)

                at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)

                at javax.faces.component.UIComponent.visitTree(UIComponent.java:1690)

                at javax.faces.component.UIComponent.visitTree(UIComponent.java:1701)

                at javax.faces.component.UIComponent.visitTree(UIComponent.java:1701)

                at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:406)

                at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:325)

                at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)

                at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)

                at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)

                at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)

                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857)

                at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:435)

                at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)

                at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

                at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

                at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:169)

                at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

                at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

                at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)

                at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)

                at br.com.pyramides.filters.MultipartRequestFilter.doFilter(MultipartRequestFilter.java:32)

                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

                at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

                at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)

                at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)

                at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:64)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)

                at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)

                at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)

                at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)

                at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)

                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

                at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)

                at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

                at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)

                at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)

                at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

                at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

                at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)

                at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

                at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)

                at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)

                at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)

                at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)

                at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

                at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

                at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)

                at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)

                at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)

                at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)

                at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)

                at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

                at java.lang.Thread.run(Thread.java:724)

 

Quem já tiver tido esse problema e puder me dar uma ajuda.

Abraços,

Att,

--------------------------------------------------------------------------------------------------
Lessandro Notaroberto Pyrâmides
Analista de Sistemas Java Web e Android

Bacharelado em Sistemas de Informação - FMG
MBA em Gestão de Projetos em TI – UFJF
MSN: 
lessa...@hotmail.com
Emails: 
lessandron...@gmail.com / lessa...@hotmail.com
Tels: +55 (32) 9108-6144 / +55 (32) 8871-3868
Juiz de Fora - MG
--------------------------------------------------------------------------------------------------

 

Vagner Araujo

unread,
Nov 23, 2014, 4:51:38 AM11/23/14
to jav...@googlegroups.com, jav...@googlegroups.com, javano...@googlegroups.com
Então,

sem um trecho de código fica meio difícil tentar orientar para uma possível solução... Você poderia tentar investigando o que tem nessa linha 57...

br.com.pyramides.service.impl.user.UserImageServiceImpl.downloadImage(UserImageServiceImpl.java:57)

--
Vagner Araujo

Lessandro Notaroberto Pyrâmides

unread,
Nov 23, 2014, 4:52:56 AM11/23/14
to jav...@googlegroups.com, jav...@googlegroups.com, javano...@googlegroups.com

Boa noite.

Alguém faz ideia porque esse problema ocorre? Localmente funciona...

Att,

Lessandro

Lessandro Notaroberto Pyrâmides

unread,
Nov 23, 2014, 1:39:42 PM11/23/14
to jav...@googlegroups.com, jav...@googlegroups.com, javano...@googlegroups.com

Estou encaminhando o trecho do código  que realiza o download da imagem para melhor avaliação:

 

@Service

public class UserImageServiceImpl extends GenericServiceImpl<UserImage, Long>

       implements UserImageService {

 

    @Override

    public String downloadImage(Long userId, String imageName, int width, int height, String serverPath) throws IOException {

      

       Map<String, String> params = new HashMap<String, String>();

       params.put("id", String.valueOf(userId));

       params.put("imageName", imageName);

       String urlPost = FacesUtils.getApplicationPath().concat("/imageUserDownload");

       HttpURLConnection urlConnection = HttpServletUtil.sendPostRequest(urlPost, params); //Dispara o servlet que está abaixo

       InputStream is = urlConnection.getInputStream();

      

       String userImagePath = Constants.BAR_SEPARATOR

             .concat(Constants.APP_IMAGE_PATH)

             .concat(Constants.USER_FOLDER)

             .concat(String.valueOf(userId)

             .concat(Constants.BAR_SEPARATOR));

 

       String appImageName = !imageName.isEmpty() ? imageName : Constants.NO_IMAGE;

 

       String imagePath = serverPath.concat(userImagePath);

      

       if (!new File(imagePath.concat(appImageName)).exists()) {

           byte[] file = IOUtils.toByteArray(is);

           byte[] image = this.imageService.resizeImage(file, width, height);

           imageService.generateDiskImage(image, imagePath, appImageName);

       }

 

       return Constants.BAR_SEPARATOR.concat(FacesUtils.getExternalContext().getContextName())

             .concat(userImagePath.concat(appImageName));

    }

}

 

@WebServlet(urlPatterns = "/imageUserDownload", loadOnStartup = 1, asyncSupported = false)

public class UserImageServletServiceImpl extends HttpServlet {

 

    @Override

    protected void doPost(HttpServletRequest request,

           HttpServletResponse response) throws ServletException, IOException {

 

       BufferedInputStream in = null;

       BufferedOutputStream output = null;

       ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());

       ParameterServiceImpl parameterService = applicationContext.getBean("parameterServiceImpl", ParameterServiceImpl.class);

       String path = parameterService.findByName(Constants.USER_IMAGE_PATH).getValue();

 

       try {

 

           if (request.getParameter("id") != null) {

 

             String userId = request.getParameter("id").toString();

             String imageName = request.getParameter("imageName") != null

                    ? request.getParameter("imageName").toString() : new String();

 

             File file = new File(path.concat(userId).concat(

                    Constants.BAR_SEPARATOR.concat(imageName)));

 

             if (imageName.isEmpty() || !file.exists()) {

                 file = new File(path.concat(Constants.NO_IMAGE));

             }

 

             // Get content type by filename.

             String contentType = getServletContext().getMimeType(file.getName());

 

             // Check if file is actually an image (avoid download of other

             // files by

             // hackers!).

             // For all content types, see:

             // http://www.w3schools.com/media/media_mimeref.asp

             if (contentType == null

                    || (contentType != null

                    && (!contentType.endsWith("png")

                    && !contentType.endsWith("jpg") && !contentType.endsWith("jpeg")

                    && !contentType.endsWith("bmp")))) {

                 // Do your thing if the file appears not being a real image.

                 // Throw an exception, or send 404, or show default/warning

                 // image,

                 // or just ignore it.

                 response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.

                 return;

             }

 

             // Init servlet response.

             response.reset();

             response.setBufferSize(DEFAULT_BUFFER_SIZE);

             response.setContentType(contentType);

             response.setHeader("Content-Length", String.valueOf(file.length()));

             response.setHeader("Content-Disposition", "inline; filename=\"".concat(file.getName())

                    .concat("\""));

             response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.

             response.setHeader("Pragma", "no-cache"); // HTTP 1.0.

             response.setDateHeader("Expires", 0); // Proxies.

 

             in = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);

             output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);

             lerArquivo(in, output);

           } else {

             // Do your thing if the image is not supplied to the request

             // URI.

             // Throw an exception, or send 404, or show default/warning

             // image,

             // or just ignore it.

             response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.

             return;

           }

 

       } catch (Exception ex) {

           log.error(ex.getMessage());

       } finally {

           // Gently close streams.

           close(output);

           close(in);

       }

    }

 

    /**

     * o conteúdo do arquivo.

     * @param in Stream de entrada

     * @param output Stream de saída

     * @throws IOException Exception

     */

    private void lerArquivo(BufferedInputStream in, BufferedOutputStream output)

           throws IOException {

       // Write file contents to response.

       byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];

       int length;

       while ((length = in.read(buffer)) > 0) {

           output.write(buffer, 0, length);

       }

    }

 

    // Helpers (can be refactored to public utility class)

    private void close(Closeable resource) {

       if (resource != null) {

           try {

             resource.close();

           } catch (IOException e) {

             // Do your thing with the exception. Print it, log it or mail

             // it.

              log.error(ex.getMessage());

           }

       }

    }

}

 

Vou dar uma lida também nesse link que o amigo enviou.

Abs,

Lessandro

 

Enviada em: domingo, 23 de novembro de 2014 09:49
Para: jav...@googlegroups.com
Cc: jav...@googlegroups.com; javano...@googlegroups.com

Assunto: Re: [javasf] RES: Erro ao carregar imagem no servidor de produção

 

Olá Lessandro, vou dar um tiro no escuro, não tem a ver com proxy em prod:
How to fix error 502 status

 

 

image

 

 

 

 

 

How to fix error 502 status

I am using Jsoup Java HTML parser to fetch images from a particular URL. But some of the images are throwing a status 502 error code and are not saved to my machine...

Visualizado por Yahoo

 

 

 

 


Att, 

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS

 

--
Você recebeu essa mensagem porque está inscrito no grupo "javasf: JavaServer Faces Group" dos Grupos do Google.
Para cancelar inscrição nesse grupo e parar de receber e-mails dele, envie um e-mail para javasf+un...@googlegroups.com.
Acesse esse grupo em http://groups.google.com/group/javasf.
Para ver essa discussão na Web, acesse https://groups.google.com/d/msgid/javasf/004e01d006bd%24bcd7f6c0%243687e440%24%40gmail.com.
Para mais opções, acesse https://groups.google.com/d/optout.

 

--
Você recebeu essa mensagem porque está inscrito no grupo "javasf: JavaServer Faces Group" dos Grupos do Google.
Para cancelar inscrição nesse grupo e parar de receber e-mails dele, envie um e-mail para javasf+un...@googlegroups.com.
Acesse esse grupo em http://groups.google.com/group/javasf.
Para ver essa discussão na Web, acesse https://groups.google.com/d/msgid/javasf/1067712075.4230986.1416743348188.JavaMail.yahoo%40jws10644.mail.bf1.yahoo.com.
Para mais opções, acesse https://groups.google.com/d/optout.

Lessandro Notaroberto Pyrâmides

unread,
Nov 23, 2014, 1:39:43 PM11/23/14
to jav...@googlegroups.com, jav...@googlegroups.com, javano...@googlegroups.com

Esqueci de incluir a classe HttpServletUtil, onde o método sendPostRequest  talvez seja importante para análise nesse

momento:

 

    /**

     * Makes an HTTP request using POST method to the specified URL.

     * @param requestURL the URL of the remote server

     * @param params A map containing POST data in form of key-value pairs

     * @return An HttpURLConnection object

     * @throws IOException thrown if any I/O error occurred

     */

    public static HttpURLConnection sendPostRequest(String requestURL,

           Map<String, String> params) throws IOException {

       URL url = new URL(requestURL);

       httpConn = (HttpURLConnection) url.openConnection();

       httpConn.setUseCaches(false);

 

       httpConn.setDoInput(true); // true indicates the server returns response

 

       StringBuffer requestParams = new StringBuffer();

 

       if (params != null && params.size() > 0) {

 

           httpConn.setDoOutput(true); // true indicates POST request

 

           // creates the params string, encode them using URLEncoder

           Iterator<String> paramIterator = params.keySet().iterator();

           while (paramIterator.hasNext()) {

             String key = paramIterator.next();

             String value = params.get(key);

             requestParams.append(URLEncoder.encode(key, "UTF-8"));

             requestParams.append("=").append(URLEncoder.encode(value, "UTF-8"));

             requestParams.append("&");

           }

 

           // sends POST data

           OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());

           writer.write(requestParams.toString());

           writer.flush();

       }

 

       return httpConn;

    }

 

Att,

Lessandro

 

De: Lessandro Notaroberto Pyrâmides [mailto:lessandron...@gmail.com]

Enviada em: domingo, 23 de novembro de 2014 14:37
Para: 'jav...@googlegroups.com'
Cc: 'jav...@googlegroups.com'; 'javano...@googlegroups.com'

Assunto: Re: [javasf] RES: Erro ao carregar imagem no servidor de produção

Olá Lessandro, vou dar um tiro no escuro, não tem a ver com proxy em prod:
How to fix error 502 status

 

 

image

 

 

 

 

 

How to fix error 502 status

I am using Jsoup Java HTML parser to fetch images from a particular URL. But some of the images are throwing a status 502 error code and are not saved to my machine...

Visualizado por Yahoo

 

 

 

 


Att, 

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS

 

Em Sábado, 22 de Novembro de 2014 23:35, Lessandro Notaroberto Pyrâmides <lessandron...@gmail.com> escreveu:

 

--

Você recebeu essa mensagem porque está inscrito no grupo "javasf: JavaServer Faces Group" dos Grupos do Google.
Para cancelar inscrição nesse grupo e parar de receber e-mails dele, envie um e-mail para javasf+un...@googlegroups.com.
Acesse esse grupo em http://groups.google.com/group/javasf.
Para ver essa discussão na Web, acesse https://groups.google.com/d/msgid/javasf/004e01d006bd%24bcd7f6c0%243687e440%24%40gmail.com.
Para mais opções, acesse https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages