"La ressource demandée n'est pas disponible"
Bonjour à tous,
J'ai suivi ce tutorial afin de réaliser un service web RESTful avec NetBeans. Le service web marche correctement, mais j'ai un problème avec l'application web censée le consommer.
Je poste sur ce forum et non sur celui consacré aux services web Java car j'ai l'impression que mon problème est lié à des fonctions JavaScript qui ne sexécutent pas, technologie que je n'ai jamais utilisée auparavant.
L'application web comporte une page index.html :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>DeeJay - PlayList Community</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="./style.css" type="text/css"/>
<!-- Add the location of the MusicDB remoting scripts generated earlier:-->
<script type="text/javascript" src="../rest/Support.js"></script>
<script type="text/javascript" src="../rest/musicdb/MusicDB.js"></script>
<script type="text/javascript" src="../rest/musicdb/Playlists.js"></script>
<script type="text/javascript" src="../rest/musicdb/Playlist.js"></script>
<script type="text/javascript" src="../rest/musicdb/Songs.js"></script>
<script type="text/javascript" src="../rest/musicdb/Song.js"></script>
<script type="text/javascript" src="./main.js"></script>
</head>
<body>
...
<td class="cell ht">
<a href="javascript:showPlaylists()" class="links">
<span class="text2">Playlists</span>
</a>
</td>
...
</body>
</html> |
Un fichier style.css et un répertoire images sont utilisés dans un répertoire music placé à côté de la page index.html.
Un fichier main.js comporte plusieurs fonctions JavaScript dont la fonction ShowPlaylists() :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| var playlistsObj;
function showPlayLists() {
var app = new MusicDB();
var resources = app.getResources();
for(i=0;i<resources.length;i++) {
var resource = resources[i];
if(resource instanceof Playlists) {
playlistsObj = resource;
var style = 'otab';
var str = '<div><table class="result"><tr>';
str += '<td class="tab '+style+'"><a class="links" href="javascript:createPlayList()"><span class="text2">Create Playlist</span></a></td></tr></table></div>';
var playlists = playlistsObj.getItems();
for(i=0;i<playlists.length;i++) {
var playlist = playlists[i];
var uri = playlist.getUri();
var playlistId = playlist.getPlaylistId();
var title = playlist.getTitle();
var desc = playlist.getDescription();
//alert(uri+' '+playlistId+' '+title+' '+desc);
str += "<div id='playListsTable'><a href=\"javascript:showPlayList("+i+")\" >"+title+"</a><br/>"+desc+"</div>";
}
var node = document.getElementById('vw_pl_content');
node.innerHTML = str ;
doShowContent('vw_pl');
}
}
}
... |
Enfin, un répertoire xspf contient un player XSPF MP3 et un répertoire songs contient plusieurs fichiers xspf de description de chansons de ce type :
Code:
1 2 3 4 5 6 7 8 9 10
| <?xml version="1.0" encoding="UTF-8"?>
<playlist version="0" xmlns = "http://xspf.org/ns/0/">
<trackList>
<track>
<location>http://magnatune.com/all/07-Motorway-Nova%20Express.mp3</location>
<image>http://he3.magnatune.com/artists/img/nova_express2.jpg</image>
<annotation>Motorway</annotation>
</track>
</trackList>
</playlist> |
Le problème intervient lorsque l'application web est lancée : aucune fonction JavaScript ne s'exécute ni sous IE5 ni sous Firefox 2.
Sous IE5, lorsque je clique sur un bouton Playlists devant lancer la fonction showPlayLists(), le message "Erreur sur la page !" est affiché sur la barre de statut.
Voici les erreurs que j'obtiens avec Firebug :
Sous la première erreur, j'ai accès à un onglet Response qui contient le message suivant :
Citation:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict
.dtd"><html><head><title>Sun Java System Application Server 9.1_02 - Rapport d'erreur</title><style type
="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size
:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;
} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial
,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background
:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1
>État HTTP 404 - </h1><hr/><p><b>type</b> Rapport d'état</p><p><b>Message</b></p><p><b>Description</b
>La ressource demandée () n'est pas disponible.</p><hr/><h3>Sun Java System Application Server 9.1_02
</h3></body></html>
Voici l'extrait du fichier Support.js qui se trouve dans un dossier rest généré par NetBeans comportant la ligne 112 (en gras) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| get : function(url, mime) {
var xmlHttpReq = this.open('GET', url, mime, 0, false);
xmlHttpReq.send(null);
try {
if (xmlHttpReq.readyState == 4) {
var rtext = xmlHttpReq.responseText;
if(rtext == undefined || rtext == '' || rtext.indexOf('HTTP Status') != -1) {
if(rtext != undefined)
this.debug('Failed XHR(GET, '+url+'): Server returned --> ' + rtext);
return '-1';
}
return rtext;
}
} catch( e ) {
this.debug('Caught Exception; name: [' + e.name + '] message: [' + e.message+']');
}
return '-1';
}, |
Voici l'extrait du fichier Playlists.js qui se trouve dans un dossier rest/musicdb comportant la ligne 38 (en gras) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| init : function() {
var remote = new PlaylistsRemote(this.uri);
var c = remote.getJson();
if(c != -1) {
var myObj = eval('('+c+')');
var playlists = myObj.playlists;
if(playlists == null || playlists == undefined) {
rjsSupport.debug('playlists is undefined, so skipping init of Playlists');
return;
}
var refs = playlists.playlistRef;
if(refs != undefined) {
if(refs.length == undefined) {
this.initChild(refs, 0);
} else {
var j = 0;
for(j=0;j<refs.length;j++) {
var ref = refs[j];
this.initChild(ref, j);
}
}
} else {
rjsSupport.debug('playlistRef is undefined, so skipping initChild for Playlists');
}
this.initialized = true;
}
}, |
Si vous avez une idée de pourquoi ça ne marche pas chez moi alors que c'est censé fonctionner chez la personne qui a écrit le tutorial, je suis bien entendu preneur...
Merci à vous.