You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@gmx.at> on 2015/05/16 15:25:13 UTC
Buffered Image - shared resource
Hi all,
how is it possible to assign a shared image resource to a bufferedImage?
The shared resource reference is „image“ which is a file folder serving different images, which are specified via page parameters.
final PageParameters params = new PageParameters();
params.set("fileName", "image.jpg“);
BufferedImage bi = …
Thanks, Chris
Re: Buffered Image - shared resource
Posted by Chris <ch...@gmx.at>.
Hi Martin,
when reading an image as shared resource as follows,
String relativeUrl = RequestCycle.get().urlFor(WicketApplication.get().getSharedResources().get("images"), params).toString();
URL url = new URL(RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(relativeUrl)));
ImageIO.read(url.openStream());
I am getting a Connection Refused error. On the localhost, it works - the error is related to the app deployed on the server.
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1167)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1103)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:997)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:931)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at java.net.URL.openStream(URL.java:1038)
at mycompany.pages.QRResource.getImageData(QRResource.java:80)
at org.apache.wicket.request.resource.DynamicImageResource.newResourceResponse(DynamicImageResource.java:153)
at org.apache.wicket.request.resource.AbstractResource.respond(AbstractResource.java:498)
at org.apache.wicket.request.handler.resource.ResourceRequestHandler.respond(ResourceRequestHandler.java:75)
at org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler.respond(ResourceReferenceRequestHandler.java:108)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
> Am 16.05.2015 um 23:20 schrieb Martin Grigorov <mg...@apache.org>:
>
> Hi,
>
> Check http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/.
> You may use Wicket's Session to decide what to serve for different users.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Sat, May 16, 2015 at 8:14 PM, Chris <ch...@gmx.at> wrote:
>
>> Hi all,
>>
>> I would like to combine several shared image resources into a new dynamic
>> image resource. The image itself should not be displayed on a Wicket page
>> but its URL is needed as input to a JS script.
>> Is there a quick way to read the shared image resources (other then via
>> RequestCycle.get().urlFor(new SharedResourceReference("images"),
>> params).toString() and using the URL for ImageIO.read(url)?
>>
>> How can I get the URL of the newly created image resource? As the URL
>> should be unique for each session/user I think that I cannot mount it.
>>
>> br Chris
>>
>>
>>
>>> Am 16.05.2015 um 15:25 schrieb Chris <ch...@gmx.at>:
>>>
>>> Hi all,
>>>
>>> how is it possible to assign a shared image resource to a bufferedImage?
>>>
>>> The shared resource reference is „image“ which is a file folder serving
>> different images, which are specified via page parameters.
>>> final PageParameters params = new PageParameters();
>>> params.set("fileName", "image.jpg“);
>>> BufferedImage bi = …
>>>
>>> Thanks, Chris
>>>
>>>
>>>
>>
>>
Re: Buffered Image - shared resource
Posted by Chris <ch...@gmx.at>.
Hi Martin,
at localhost, the mounting of the resource works, but not at the server (cannot find the image).
Do you know a tip why this only works at localhost?
ResourceReference r = new ResourceReference("facebook") {
@Override
public IResource getResource() {
return new QRResource(user);
}
};
WebApplication.get().mountResource("/facebook/test.png", r);
Thanks, Chris
> Am 16.05.2015 um 23:20 schrieb Martin Grigorov <mg...@apache.org>:
>
> Hi,
>
> Check http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/.
> You may use Wicket's Session to decide what to serve for different users.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Sat, May 16, 2015 at 8:14 PM, Chris <ch...@gmx.at> wrote:
>
>> Hi all,
>>
>> I would like to combine several shared image resources into a new dynamic
>> image resource. The image itself should not be displayed on a Wicket page
>> but its URL is needed as input to a JS script.
>> Is there a quick way to read the shared image resources (other then via
>> RequestCycle.get().urlFor(new SharedResourceReference("images"),
>> params).toString() and using the URL for ImageIO.read(url)?
>>
>> How can I get the URL of the newly created image resource? As the URL
>> should be unique for each session/user I think that I cannot mount it.
>>
>> br Chris
>>
>>
>>
>>> Am 16.05.2015 um 15:25 schrieb Chris <ch...@gmx.at>:
>>>
>>> Hi all,
>>>
>>> how is it possible to assign a shared image resource to a bufferedImage?
>>>
>>> The shared resource reference is „image“ which is a file folder serving
>> different images, which are specified via page parameters.
>>> final PageParameters params = new PageParameters();
>>> params.set("fileName", "image.jpg“);
>>> BufferedImage bi = …
>>>
>>> Thanks, Chris
>>>
>>>
>>>
>>
>>
Re: Buffered Image - shared resource
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Check http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/.
You may use Wicket's Session to decide what to serve for different users.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Sat, May 16, 2015 at 8:14 PM, Chris <ch...@gmx.at> wrote:
> Hi all,
>
> I would like to combine several shared image resources into a new dynamic
> image resource. The image itself should not be displayed on a Wicket page
> but its URL is needed as input to a JS script.
> Is there a quick way to read the shared image resources (other then via
> RequestCycle.get().urlFor(new SharedResourceReference("images"),
> params).toString() and using the URL for ImageIO.read(url)?
>
> How can I get the URL of the newly created image resource? As the URL
> should be unique for each session/user I think that I cannot mount it.
>
> br Chris
>
>
>
> > Am 16.05.2015 um 15:25 schrieb Chris <ch...@gmx.at>:
> >
> > Hi all,
> >
> > how is it possible to assign a shared image resource to a bufferedImage?
> >
> > The shared resource reference is „image“ which is a file folder serving
> different images, which are specified via page parameters.
> > final PageParameters params = new PageParameters();
> > params.set("fileName", "image.jpg“);
> > BufferedImage bi = …
> >
> > Thanks, Chris
> >
> >
> >
>
>
Re: Buffered Image - shared resource
Posted by Chris <ch...@gmx.at>.
Hi all,
I would like to combine several shared image resources into a new dynamic image resource. The image itself should not be displayed on a Wicket page but its URL is needed as input to a JS script.
Is there a quick way to read the shared image resources (other then via RequestCycle.get().urlFor(new SharedResourceReference("images"), params).toString() and using the URL for ImageIO.read(url)?
How can I get the URL of the newly created image resource? As the URL should be unique for each session/user I think that I cannot mount it.
br Chris
> Am 16.05.2015 um 15:25 schrieb Chris <ch...@gmx.at>:
>
> Hi all,
>
> how is it possible to assign a shared image resource to a bufferedImage?
>
> The shared resource reference is „image“ which is a file folder serving different images, which are specified via page parameters.
> final PageParameters params = new PageParameters();
> params.set("fileName", "image.jpg“);
> BufferedImage bi = …
>
> Thanks, Chris
>
>
>