[oXygen-sdk] Jersey seems to return Oxygen's HttpExceptionWithDetails class?

Adam Retter adam.retter at googlemail.com
Mon Apr 18 08:06:56 CDT 2016


Hi Alex I'm afraid that won't work for me as the same sever URIs will be
used both with my plugin and with other Oxygen features like WebDav. Is
there anyway to to catch the exception? if I put a try catch around it, it
seems to not be caught!

I think maybe this is because it's a different HttpDetailsWithException
which has been obfuscated when compared to the one I see in the SDK.
On 18 Apr 2016 7:52 am, "Alex Jitianu" <alex_jitianu at sync.ro> wrote:

> Hi Adam,
>
> Oxygen installs it's own protocol handler for "http". As far as I can see,
> the problem would be that the
> ro.sync.net.protocol.http.WebdavHttpURLConnection.getResponseCode() method
> throws an exception instead of returning the 404 code. I'll add an issue
> for us to fix this. In the mean time I recommend using the Targeted URL
> Stream Handler [1] plugin extension. From this extension you can decide to
> use the SUN protocols when connecting to Jersey:
>
> *public* *class* CustomTargetedURLStreamHandlerPluginExtension
>   *implements* TargetedURLStreamHandlerPluginExtension {
>
>   *@Override*
>   *public* *boolean* canHandleProtocol(String protocol) {
>     *boolean* handleProtocol = false;
>     *if* ("http".equals(protocol) || "https".equals(protocol)) {
>       *// This extension handles both HTTP and HTTPS protocols*
>       handleProtocol = true;
>     }
>     *return* handleProtocol;
>   }
>
>   *@Override*
>   *public* URLStreamHandler getURLStreamHandler(URL url) {
>     *// This method is called only for the URLs with a protocol *
>     *// for which the canHandleProtocol(String) method returns true (HTTP and HTTPS)*
>
>     URLStreamHandler handler = null;
>
>     String host = url.getHost();
>     String protocol = url.getProtocol();
>     *if* (*"**slaws.info <http://slaws.info>"**.equals(host)*) {
>       *// When there are connections opened from some_host, the SUN HTTP(S) *
>       *// handlers are used*
>       *if* ("http".equals(protocol)) {
>         *handler = **new** sun.net.www.protocol.http.Handler();*
>       } *else* {
>         handler = *new* sun.net.www.protocol.https.Handler();
>       }
>     }
>     *return* handler;
>   }
> }
> }
>
>
> [1]
> http://oxygenxml.com/doc/versions/17.1/ug-editor/#concepts/targeted-url-handler-plugin.html
>
> Best regards,
> Alex
> --
> Alex Jitianu
> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com
>
> On 4/17/2016 4:44 AM, Adam Retter wrote:
>
> I am trying to use Jersey 2.22.2 from inside my Oxygen plugin, but
> when I use a URL which my server doesn't recognise and results in a
> 404, then for a reason I don't understand Jersey seems to be throwing
> me Oxygen's HttpExceptionWithDetails.
>
> Any ideas how I can get Oxygen not to override Jersey's error
> handling? The stacktrace looks like:
>
> Exception in thread "AWT-EventQueue-0"
> javax.ws.rs.ProcessingException:
> ro.sync.net.protocol.http.HttpExceptionWithDetails: 404 Not Found for:http://slaws.info/upload.php
> at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:287)
> at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255)
> at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
> at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681)
> at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
> at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
> at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
> at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
> at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)
> at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:437)
> at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:343)
> at org.humanistika.oxygen.tei.authorizer.remote.impl.JerseyClient.uploadSuggestion(JerseyClient.java:157)
> at org.humanistika.oxygen.tei.authorizer.TeiAuthorizer$AddNewSuggestionCIValue.uploadSuggestion(TeiAuthorizer.java:166)
> at org.humanistika.oxygen.tei.authorizer.TeiAuthorizer$AddNewSuggestionCIValue.getInsertString(TeiAuthorizer.java:145)
> at ro.sync.contentcompletion.g.x(Unknown Source)
> at ro.sync.contentcompletion.f.ab(Unknown Source)
> at ro.sync.contentcompletion.xml.k.gpm(Unknown Source)
> at ro.sync.contentcompletion.l.j.spm(Unknown Source)
> at ro.sync.contentcompletion.l.j.aom(Unknown Source)
> at ro.sync.contentcompletion.l.j.processKeyEvent(Unknown Source)
> at ro.sync.contentcompletion.l.u.processKeyEvent(Unknown Source)
> at java.awt.Component.processEvent(Component.java:6312)
> at java.awt.Container.processEvent(Container.java:2236)
> at java.awt.Component.dispatchEventImpl(Component.java:4891)
> at java.awt.Container.dispatchEventImpl(Container.java:2294)
> at java.awt.Component.dispatchEvent(Component.java:4713)
> at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
> at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
> at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
> at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
> at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
> at java.awt.Component.dispatchEventImpl(Component.java:4762)
> at java.awt.Container.dispatchEventImpl(Container.java:2294)
> at java.awt.Window.dispatchEventImpl(Window.java:2750)
> at java.awt.Component.dispatchEvent(Component.java:4713)
> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
> at java.awt.EventQueue.access$500(EventQueue.java:97)
> at java.awt.EventQueue$3.run(EventQueue.java:709)
> at java.awt.EventQueue$3.run(EventQueue.java:703)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
> at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
> at java.awt.EventQueue$4.run(EventQueue.java:731)
> at java.awt.EventQueue$4.run(EventQueue.java:729)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
> at ro.sync.ui.application.ApplicationLauncher$_b$1.dispatchEvent(Unknown Source)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
> at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
> Caused by: ro.sync.net.protocol.http.HttpExceptionWithDetails: 404 Not
> Found for: http://slaws.info/upload.php
> at ro.sync.net.protocol.http.b.d.cb(Unknown Source)
> at ro.sync.net.protocol.http.b.d.j(Unknown Source)
> at ro.sync.net.protocol.http.abstraction.o.q(Unknown Source)
> at ro.sync.net.protocol.http.abstraction.o.f(Unknown Source)
> at ro.sync.net.protocol.http.WebdavHttpURLConnection.getInputStream(Unknown
> Source)
> at ro.sync.net.protocol.http.WebdavHttpURLConnection.getResponseCode(Unknown
> Source)
> at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:394)
> at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)
> ... 53 more
>
> Thanks Adam.
>
>
>
>
> _______________________________________________
> oXygen-sdk mailing list
> oXygen-sdk at oxygenxml.com
> https://www.oxygenxml.com/mailman/listinfo/oxygen-sdk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.oxygenxml.com/pipermail/oxygen-sdk/attachments/20160418/ccfd5fb4/attachment.html>


More information about the oXygen-sdk mailing list