This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 228181 - Mapping of URL to file does not work correctly in Maven project when running on mobile device
Summary: Mapping of URL to file does not work correctly in Maven project when running ...
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 7.4
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on: 221791
Blocks: 229223
  Show dependency tree
 
Reported: 2013-04-02 20:35 UTC by Petr Jiricka
Modified: 2013-05-13 09:39 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Hotfix that works around this issue (935 bytes, text/plain)
2013-04-05 11:23 UTC, Petr Jiricka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2013-04-02 20:35:21 UTC
1. Run the tyrus auction sample on Android device
2. Enable select mode and select an element

=> DOM tree window pops up, and HTML file corresponding to the URL in browser is not selected - indicating that the mapping of URL -> file does not work.

Not sure if this is related to bug 228087.
Comment 1 Petr Jiricka 2013-04-05 11:23:19 UTC
Created attachment 133330 [details]
Hotfix that works around this issue

I am attaching a hotfix that works for me, but this is probably not the correct solution. David/Martin/Honzo, how do you think this should be fixed properly?
Comment 2 Jan Becicka 2013-04-05 13:53:55 UTC
I'd like to fix it. But I'm not able to create Maven Web Project (issue 228285)
Comment 3 Petr Jiricka 2013-04-30 13:09:03 UTC
This is really a blocker -> P2.
Comment 4 Jan Becicka 2013-05-02 07:27:21 UTC
The issue is, that Run on projects opens url in this format:
http://.../sample-auction/
ServerUrlMapping.fromServer using above mentioned url returns null.
In my opinion it should return FileObject representing index.html or it should open url in this format:
http://.../sample-auction/index.html

Should be probably fixed in BaseClientSideDevelopmentSupport
Comment 5 Petr Jiricka 2013-05-02 09:40:08 UTC
I thought that the main reason is issue 221791, no? Because in Chrome it works fine, if I recall correctly. So BaseClientSideDevelopmentSupport works well.
Comment 6 David Konecny 2013-05-02 22:01:45 UTC
Honza, can you comment on what Petr said. I thought that's the case too. ServerUrlMapping for Java Web project was enhanced a while ago to cope with URLs without index.html and that part as far as I remember works fine now.
Comment 7 Jan Becicka 2013-05-03 07:29:41 UTC
Petr is probably right.

BTW Maven and Glassfish don't like me. I'm not able to run the sample again. Maven does not see running glassfish.
Comment 8 Petr Jiricka 2013-05-03 08:28:29 UTC
Only relevant to trunk, adding 731-not-a-stopper whiteboard.
Comment 9 David Konecny 2013-05-07 07:50:10 UTC
I can reproduce now on my Android device.
Comment 10 David Konecny 2013-05-08 04:59:50 UTC
I've implemented a solution which gets rid of current hacks. I need to test it tomorrow and then I will push it.
Comment 11 David Konecny 2013-05-09 00:11:27 UTC
ed02fd3c0ca2

I implemented this by introducing a new SPI which browser can implement and perform further URL conversions. That way mobile browsers can translate URL into whatever they want. I also changed all clients (html5, EE/maven and php) to consult this new API and use converted URL if browser provides one.

This should ensure that everybody can see the same URL - JS debugger, CSS styling, etc.

I tested it and it worked fine on this testcase.
Comment 12 David Konecny 2013-05-09 23:54:24 UTC
Honza, could you review my changes please? Thanks.
Comment 13 Quality Engineering 2013-05-10 02:38:19 UTC
Integrated into 'main-golden', will be available in build *201305092300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/ed02fd3c0ca2
User: David Konecny <dkonecny@netbeans.org>
Log: #228181 - Mapping of URL to file does not work correctly in Maven project when running on mobile device
Comment 14 Jan Becicka 2013-05-10 13:11:30 UTC
(In reply to comment #12)
> Honza, could you review my changes please? Thanks.

I'm not sure, but javascript debugging does not work for me. Filed as issue 229582
Comment 15 Jan Becicka 2013-05-10 19:56:41 UTC
(In reply to comment #12)
> Honza, could you review my changes please? Thanks.

I can verify, that this change broke phonegap debugging. I know, there were ugly hacks in ServerURLMapper, but this solution unfortunately does not work with phonegap, and I'm afraid it cannot be fixed with current API.

The hack was there because of ServerURLMapping and hack was removed without replacement.

I propose to revert the change and discuss more what phonegap needs.
Comment 16 David Konecny 2013-05-13 04:47:04 UTC
Let me explain current state. I did remove hacks from ServerURLMapping and I provided SPI replacement for them. The problem with hacks in ServerURLMapping was that they could never work in all project types. The purpose of ServerURLMappingImplementation interface is to allow different project types to express how a project source file can be accessed via server URL in runtime and vice versa. And how that is implemented is very different for each project type. The PhoneGap tried to implement their own ServerURLMappingImplementation and give it priority over project ones which sometimes worked but in other cases, like this Maven issue it did not.

So I removed the hack and introduced a new SPI named BrowserURLMapperImplementation. The SPI allow any browser to further translate server URL into "browser specific URL". So for example let say there is a project source file /project/public_html/index.html. Project's ServerURLMappingImplementation is capable of translating the URL into http://localhost:123/myapp/index.html. So far so good. Each project has a browser assigned and project's ServerURLMappingImplementation must consult selected browser and ask it if it would like to further convert server URL into something else. If browser wants to perform URL conversions then its factory should implement BrowserURLMapperImplementation. That allows for example Android Device browser to perform conversion of http://localhost:123/myapp/index.html into http://192.168.0.1:123/myapp/index.html; or PhoneGap browser can convert http://localhost:123/myapp/index.html into file:///var/Applications/whatever/wwww/index.html.

Implemented like this each client of ServerURLMapping API will always get a server URL already converted by project's browser into browser specific URL. That should ensure that JS Debugger, CSS Styling, and other tooling operate on the same URLs.

The BrowserURLMapperImplementation SPI has three params:
* project
* project file being converted
* server URL corresponding to that project's file
These three params should be sufficient to perform server URL conversion to browser specific URL. The SPI's return value was inspired by what current PhoneGap and Android do: they just convert root of URL with something else. So in previous example Android should return BrowserURLMapperImplementation.BrowserURLMapper("http://localhost:", "http://192.168.0.1") and PhoneGap case should return BrowserURLMapperImplementation.BrowserURLMapper("http://localhost:123/myapp", "file:///var/Applications/whatever/wwww"). This mapping is remembered (see WebBrowser.browserMappings) and used to perform opposite conversion of browser URL back to server URL which then can be successfully converted into project's source file.

I tested it and it worked fine for Android device but PhoneGap debugging works only on iOS so I could not test it. However it should be easy to debug org.netbeans.modules.cordova.platforms.BrowserURLMapperImpl and see what it's doing.

Does it make sense? If not please describe what exact problem you are experiencing. I do not have iOS available for testing.
Comment 17 Jan Becicka 2013-05-13 09:39:01 UTC
I reverted the change locally, so I'll be ready to do some demos this week. So I'm not that nervous any more :)

OK. Now I understand how it was meant. The problem is that the mapping is immutable and phonegap is requested to provide such mapping on creation. It is not possible in phonegap, because I don't know, where the app is installed, so I need set it up during handshake in iOS impl of DebugTransport.attach.

I'll try to solve it by adding setters to BrowserUrlMappers and try to file / fix bugs.