jalview / jalview-js

JavaScript artefacts and deployment documents for JalviewJS
https://jalview.github.io/jalview-js/
GNU Affero General Public License v3.0
13 stars 5 forks source link

Not all loading paths use j2sPath #5

Open smoretti opened 4 years ago

smoretti commented 4 years ago

Hi

when I open locally JalviewJS.html everything works perfectly.

Unfortunately I have to use Jalview.js not in the root folder of the application. So my new html file specifies the right path <script src='/jalview.js/swingjs/swingjs2.js'></script> and j2sPath: '/jalview.js/swingjs/j2s', but the loading fails at some point and it looks the path redefinied is not taken as relative.

Here is system.out

`J2SApplet exec JalviewJS start applet null swingjs.api.Interface creating instance of javajs.util.AjaxURLStreamHandlerFactory get parameter: language = null get parameter: name = JalviewJS get parameter: syncId = 692180816133788 JSApp initialized JSAppletViewer initializing2 JSToolkit initialized JSGraphicsConfiguration initialized swingjs.api.Interface creating instance of swingjs.JSGraphicsEnvironment JSGraphicsEnvironment initialized swingjs.api.Interface creating instance of swingjs.JSScreenDevice JSScreenDevice initialized JSAppletViewer thread run1 mode=0 status=0 JSAppletViewer thread run1 mode=1 status=1 JSAppletViewer runloader get parameter: main = jalview.bin.Jalview swingjs.api.Interface creating instance of swingjs.JSApplet swingjs.api.Interface creating instance of swingjs.plaf.HTML5LookAndFeel JalviewJS loaded JSAppletViewer thread run1 mode=1 status=76 JalviewJS running jalview.bin.Jalview Running main(args) in class jalview.bin.Jalview Java version: 1.6-1.8 null Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0 Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0 JSUtil getting Java resource sun/util/resources/CalendarData.properties JSUtil caching bytes for /jalview.js/swingjs/j2s/sun/util/resources/CalendarData.properties swingjs.api.Interface creating instance of java.util.PropertyResourceBundle JSUtil getting Java resource sun/util/resources/CalendarData_en.properties JSUtil caching bytes for /jalview.js/swingjs/j2s/sun/util/resources/CalendarData_en.properties

In the browser console I can see this: GET http://dev.../jalview.js/swingjs/swingjs2.js J2SApplet load JalviewJS loadClazz... swingjs2.js:12881:12 J2SApplet load JalviewJS start applet... swingjs2.js:12881:12 J2SApplet exec JalviewJS loadClazz null -- OK swingjs2.js:12832:12 GET http://dev.../jalview.js/swingjs/j2s/core/corejvexamplefile.z.js J2SApplet exec JalviewJS start applet null -- OK swingjs2.js:12832:12 JalviewJS loaded /jalview.js/swingjs/j2s/core/corejvexamplefile.z.js:3134:51 JalviewJS running jalview.bin.Jalview /jalview.js/swingjs/j2s/core/corejvexamplefile.z.js:3134:51 GET http://dev.../jalview//jalview.js/swingjs/j2s/sun/util/resources/CalendarData.properties GET http://dev.../jalview//jalview.js/swingjs/j2s/sun/util/resources/CalendarData_en.properties

The last 2 gets don't use the redefined path.

How can I fix this?

foreveremain commented 4 years ago

The console looks like it is reporting the correct resource URL, but the GET has an additional /jalview at the beginning. Do you see 404 responses for those resources in the debugger's Network tab ?

smoretti commented 4 years ago

Yes, I see 404 responses for those resources

foreveremain commented 4 years ago

Could you try adding ?j2snocore - if the 404 doesn't happen then the corefile is at fault (e.g. with http://www.jalview.org/jalview-js/JalviewJS.shtml?j2snocore).

smoretti commented 4 years ago

It works. I tried to open the page with my own information in URL and jalview.js doesn't like that. i.e. /jalview/ENSGT00390000005194.1.Euteleostomi.aa.fas

If I use /jalview? Jalview opens itself as it should. So what is the right way to load alignment, tree and annotation files in jalview.js ?

I still have some 404 errors but they don't look detrimental:

foreveremain commented 4 years ago

OK. So the core file wasn't preserving the runtime value of j2sPath - not good. We will do some testing under: https://issues.jalview.org/browse/JAL-3516

Re remaining 404s:

Re passing files: You've a couple of options. Either pass command line args via the Info block's 'args' key, or for the alpha release jalview treats the first argument passed to the URL as a URLencoded command line (http://www.jalview.org/help/html/features/clarguments.html), so rather than /jalview/ENSGT00390000005194.1.Euteleostomi.aa.fas you can try '/jalview/?open%20ENSGT00390000005194.1.Euteleostomi.aa.fas'

So what is the right way to load alignment, tree and annotation files in jalview.js ? If you are happy with the URL argument mechanism then construct a jalview command line like: "open annotations tree " e.g. https://www.jalview.org/jalview-js/JalviewJS.shtml?open%20/examples/uniref50.fa%20tree%20/examples/plantfdx.nw%20annotations%20/examples/plantfdx.annotations or with nocore: https://www.jalview.org/jalview-js/JalviewJS.shtml?open%20/examples/uniref50.fa%20tree%20/examples/plantfdx.nw%20annotations%20/examples/plantfdx.annotations

However - it looks like both trees and annotation file parsing aren't working yet for this version! @gmungoc - do we have an issue covering loading trees and annotations in JalviewJS yet ?

gmungoc commented 4 years ago

Is it maybe simply that neither tree nor annotations file is in place yet at https://www.jalview.org/jalview-js/examples/? (Though having said that, I seem to reproduce this error locally where I do have these files.)

foreveremain commented 4 years ago

Ahem - got the newick path wrong, but the annotations path does exist: https://www.jalview.org/examples/plantfdx.annotations - I see Jalview is attempting to parse an annotation file but throwing an error in the tcoffee score file parsing routine.

This is off topic so I'm opening another gh issue: #6 for annotation files, and #7 for tree loading.

smoretti commented 4 years ago

Thanks I will try both loading methods. Do you have examples for the Info block's 'args' key with alignment, tree and annotation files?

foreveremain commented 4 years ago

the args key takes a string that is interpreted as the Jalview.main command line. Notwithstanding #6, just add this key to the Info block: args:"-open examples/uniref50.fa -tree examples/ferredoxin.nw -annotations examples/plantfdx.annotations" Those URLs can be service endpoints, of course.

foreveremain commented 4 years ago

retested with latest build https://builds.jalview.org/browse/JB-GJB0-57/artifact Corefile is still a problem, and for ?j2snocore there is also an exception raised because the j2s classloader logic doesn't recognise j2spath as an absolute path, and just appends it to the document location for direct calls like class.getResource("....")

gmungoc commented 4 years ago

Issue with loading annotation file was in Jalview code not SwingJS - resolved under https://issues.jalview.org/browse/JAL-3603

smoretti commented 4 years ago

Thanks So nothing to update in jalview-js right?

foreveremain commented 4 years ago

@smoretti - please take a look at https://github.com/jalview/jalview-js/tree/Release_2_11_1_js - this is the latest from JalviewJS/develop and might fix the J2S server problem.

foreveremain commented 2 years ago

Tagging @warownia1 - re the swingJS getResource() issue

foreveremain commented 2 years ago

I've hit this issue for the new Jalview site - and found a workaround: If j2sPath is set to a complete URL then everything seems to just work. So for a server where JalviewJS's j2s directory is at /jalview-js/swingjs/j2s, it can be used from pages in any other path by specifying: j2sPath: window.location.origin+'\/jalview-js/swingjs/j2s'