DownLoadServices

I am trying to use isResourceCached method. But even though my jar file is cached it always returb me false. I tried using null and empty string as version which is 2nd parameter to this method.
Any ideas?
I did not understand how do I use "part" APIs.
Any one has any experience with these APIs?
Thanks

Did you find a solution for this? I'm having the same problem.

Similar Messages

  • DownloadService.loadResource for external jars for 1.6.0-19+

    First, be kind with my english, i'm french (nobody's perfect...)
    I have a JNLP into which i declare a signed jar resource main.jar. This application retreive at execution a list of signed jar names (+a.jar, b.jar+...) that i dynamically load on my need through DownloadService.loadResource. My a.jar, b.jar are cached and it rules! But if i made a new main.jar, a.jar and b.jar, and deploy them on my server, here what's happend:
    - main.jar is tested for modification date on server (thanks to "If-Modified-Since" HTTP header), cache date is before this date, so JWS update main.jar by downloading this new main.jar. This is the behaviour described into specs and it is perfect for me!
    - but for others resources (a.jar, b.jar) i was excpected the same behaviour but JWS does not seems to check for modification date. So a.jar and b.jar are not updated.
    So my first question: Is there a way to tell to DownloadService.loadResource to check for modification date? i could deal with jar version but this basic date checking was great for me...
    Except this cache minor problem, external jar download works just fine except i get the warning security problem [Mixing Signed and Unsigned Code |http://java.sun.com/javase/6/docs/technotes/guides/jweb/mixed_code.html].
    All my jars are signed with the same certificate, so i was a bit confused.
    Anyway, i follow indications and put the Trusted-Only: true attribut into the manifest of main.jar.
    But it leads to this exception:
    java.lang.SecurityException: Trusted-Only loader attempted to load sandboxed resource from http://monserveur/a.jar
         at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source)
         at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1400(Unknown Source)
         at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source)
         at com.sun.deploy.security.DeployURLClassPath$JarLoader.checkResource(Unknown Source)
         at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source)
         at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at my.package.a$5.run(a.java:348)
         at java.lang.Thread.run(Unknown Source)I found some posts that deal with similar problems but it does not give me a working solution. The difference seems to be the fact that i load external jars (not defined into JNLP).
    My JNLP is validated though JaNeLA.
    I cannot set a.jar, b.jar as resources into jnlp because i retreive their location during execution...
    My JNLP also declare:
    <security>
            <all-permissions/>
    </security>I think i'm a bit confused with the sandbox notion and the Trusted-Only: true attribut of the manifest. I also tried to add it to a.jar, b.jar and not main.jar but vainly. I also tried to set it on all jars but it does not work better.
    Is there a way to load external jar without having the Mixing Signed and Unsigned Code warning popup? What do i not well understand?
    Sorry to be so chatty...
    Thanks in advanced for any answer.

    So, I finally succed in finding a solution.
    But this solution seems perhaps a barbarian way to solve my problem but it works.
    The idea (as far as i understand) is that when you define "all-permission" into JNLP file, then these permission are granted for JNLP ClassLoader. When you load external jar through DownloadService.loadResource, then another classloader is used. It seems that this classloader does not inherit security policy from JNLP ClassLoader.
    My solution is to define my own policy:
    Policy.setPolicy(getAllPermissionPolicy());
        * @return a {@link Policy} with all permission granted
       private Policy getAllPermissionPolicy()
          Policy policy = new Policy() {
             private PermissionCollection m_permissionCollection;
             @Override
             public PermissionCollection getPermissions(CodeSource p_codesource)
                return getAllPermissionCollection();
             @Override
             public PermissionCollection getPermissions(ProtectionDomain p_domain)
                return getAllPermissionCollection();
              * @return an AllPermissionCollection
             private PermissionCollection getAllPermissionCollection()
                if (m_permissionCollection == null)
                   m_permissionCollection = new AllPermission().newPermissionCollection();
                   m_permissionCollection.add(new AllPermission());
                return m_permissionCollection;
          return policy;
       }For sure, you can decline this with permission you need. Here, all permission are allowed.
    I'm not quite satisfied because it's seems to be a barbarian style solution. But for now, it fits my uses => no warning popup!
    If anybody has a more proper way to deal with such an issue, i'll be glad to hear it!
    Hope it helps.

  • No progress shown sometimes when using DownloadService

    I haven't nailed down the exact situation yet, but sometimes when pulling down jars using the DownloadService the "default progress dialog" shows no progress even though the jars are being downloaded correctly from the web server. Is anyone seeing this problem as well or have any answers?
    Thanks,
    Gary

    I haven't nailed down the exact situation yet, but
    sometimes when pulling down jars using the
    DownloadService the "default progress dialog" shows
    no progress ...Like this?
    http://www.javasaver.com/testjs/jws/cache/#res3
    ...even though the jars are being downloaded
    correctly from the web server. Is anyone seeing this
    problem as well ...Not quite the same, in my case, the resources
    always download OK, but the progress dialog
    is consistently blank.
    Are you saying you can provide the URL of a JNLP
    (or screenshot) that actually shows progress?
    ...or have any answers? Not yet.

  • DownloadService.loadResource

    Hi,
    I'm not having any success getting the loadResource method for the DownloadService to work on WindowsXP using JDK1.5.
    My example is "right out of the book", JNLP file has two jars (app and content) where the app simply loads the content. When new content is published it should be downloaded automatically when the app re-starts or when interactively requested from the client.
    JNLP snippet looks like this:
    --------snip----------
         <resources>
              <j2se version="1.4+"/>
              <jar href="app.jar" main="true"/>
              <jar href="content.jar" version="1.1+"/>
    </resources>
    --------snip------------
    Java download request looks like this:
    --------snp------------
    ver = "1.1";
    URL lURL= new URL("http://localhost:8080/jnlp/app/cdc_content.jar");
    boolean cached = ds.isResourceCached(lURL, ver);
    // remove the resource from the cache
    if (cached) {
    logger.info("DownloadService: Content cache FOUND for removal");
    ds.removeResource(lURL, ver);
    //make sure that it's gone
    still_cached = ds.isResourceCached(lURL, ver);
    if (still_cached) {
    logger.info("DownloadService: Content cache FOUND AFTER removal!!");
    logger.info("DownloadService loading " lURL.toString() " " + ver);
    DownloadServiceListener dsl = ds.getDefaultProgressWindow();
    ds.loadResource(lURL, ver, dsl);          
    ----------snip--------
    Problems:
    1. The resource is found after attempted removal, i.e. stil cached
    Output is:
    DownloadService: Content cache FOUND for removal
    DownloadService: Content cache FOUND AFTER removal!
    2. When I drop a new content jar (i.e. 1.2) on the server and attempt to download it, { ds.loadResource(...)  } the download fails. The progress dialog displays "0 of 0" and does not update. Note, when I explicity reference the content.jar via http://localhost:8080/app/jnlp/content.jar? version-id=1.2, the jar is found on the server.
    3. When I close the application and drop a new content version into the server directory (i.e.1.2) and restart the app (from http://localhost:8080/app/jnlp/launch.jar) then the version 1.1 content is still loaded, not 1.2! I need to manually removed the app from my local cache and then restart it before it finds ver. 1.2 of the content at start-up
    I see vague references to similar problems in this forum and no detailed examples anywhere of how this might properly work, so any additional help will be greatly appreciated.
    thanks!
    P.S. I am also using the JnlpDownloadServlet for version differencing,

    If you just want to download content from an URL, you can use this:
         * Retrieve data from a URL and save content to destination file.
         * @param url URL to get content from.
         * @param outputDir Optional destination directory for output file.
         * @param fileName Optional name for output file.
        private void retrieveContentFromURL(URL url, String outputDir, String fileName) {
            if (url != null) {
                long t = System.currentTimeMillis();
                File file = null;
                FileOutputStream os = null;
                if (outputDir != null && fileName != null) {
                    //create output file:
                    file = new File(outputDir + File.separatorChar + fileName);
                    try {
                        os = new FileOutputStream(file);
                    } catch (FileNotFoundException fnfe) {
                        System.err.println("Can't create output file: "+fnfe);
                        return;
                //read data from HTTP server:
                InputStream is = null;
                HttpURLConnection con = null;
                try {
                    System.out.print(fileName+": connecting ...");
                    con = (HttpURLConnection) url.openConnection();
                    if (con instanceof HttpsURLConnection) { //HTTPS URL?
                        //avoid "java.io.IOException: HTTPS hostname wrong:  should be <217.5.135.142>"
                        ((HttpsURLConnection) con).setHostnameVerifier(new HostnameVerifier() {
                            public boolean verify(String hostname, SSLSession session) {
                                return true;
                    System.out.print(" reading ...");
                    try {
                        is = con.getInputStream();
                        String contentEncoding = con.getContentEncoding();
                        if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
                            if (is.markSupported()) {
                                is.mark(2); //set marker for reset
                            try {
                                is = new GZIPInputStream(is); //reads 2 bytes to determin GZIP stream!
                            } catch (IOException ioe) {
                                if (is.markSupported()) {
                                    try {
                                        is.reset(); //try to reset stream for the already read bytes to be read again
                                    } catch (IOException ioe2) {
                                        /* Ignore failed reset */
                                System.err.println("ERROR: can't create GZIPInputStream. Reading without decompression (first 2 bytes may be lost!).");
                    } catch (IOException ioe) {
                        System.err.println("Error getting input stream. HTTP return code: "+con.getResponseCode()+" ("+con.getResponseMessage()+"). "+ ioe);
                        return;
                    if (os != null) {
                int count;
                byte[] bytes = new byte[128];
                while ((count = is.read(bytes, 0, bytes.length)) != -1) { //use full read() method for GZIPInputStream to be treated correctly
                    os.write(bytes, 0, count);     
                } catch (Exception e) {
                    System.err.println("\nError getting content from URL: " + e);
                    return;
                } finally {
                    if (is != null) { try { is.close(); } catch (IOException ioe) { ioe.printStackTrace(System.err); } }
                    if (con != null) { try { con.disconnect(); } catch (Exception e) { e.printStackTrace(System.err); } }
                    if (os != null) { try { os.close(); } catch (IOException ioe) { ioe.printStackTrace(System.err); } }
                System.out.println(" time: "+((System.currentTimeMillis() - t)/1000)+" seconds.");
            }//else: input values unavailable
        }//retrieveContentFromURL()

  • Specifying resources for DownloadService

    Hi
    According to the javadocs for the DownloadService, the loadResource() method -> Downloads the given resource, if the resource is mentioned in the JNLP file for the application. This method will block until the download is completed or an exception occurs.
    What does it mean if the reource is mentioned in the jnlp file for the application? I want to download a jar from a different web based application and have that jar be part of my application (ie: plugin a special feature based on some condition). For example, here is a code snippet for both my jnlp file and some code used to load some jar in an app from a context root of foo.
    From an app with a context root of abc.
    jnlp:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://<ip>:<port>/abc"
    href="launch.jnlp">
    <information>
    <title>abc title</title>
    <vendor>Me</vendor>
    <description>This is a description of the something</description>
    </information>
    <resources>
    <j2se version="1.2+"/>
    <jar href="abc.jar"/>
    </resources>
    <application-desc main-class="com.abc"></application-desc>
    </jnlp>
    Now, my code snippet refers to another jar (not listed in the resources of the above jnlp). The jar might even be on another server.
    try
    // determine if a particular resource is cached
    URL url = new URL("http://<ip:port>/foo/Bar.jar");
    boolean cached = ds.isResourceCached(url, null);
    // remove the resource from the cache
    if (cached) {
    ds.removeResource(url, null);
    // reload the resource into the cache
    DownloadServiceListener dsl = ds.getDefaultProgressWindow();
    ds.loadResource(url, null, dsl);
    catch (Exception e)
    e.printStackTrace();
    This appears to fail (ie: jar is not actually loaded via the service, but the download progress window does appear). If I need to list the resource in my jnlp, how can i do so in such a way that the jar can be physically downloaded from an alternate location?
    Thanks in advance.

    Hi
    As a followup, 2 more questions along the same lines...
    1) the jnlp file. When specifying the codebase attribute. Does that have to be an absolute address. Or can it be relative.
    <jnlp spec="1.0+" codebase="http://<ip[:port]>/abc" href="launch.jnlp">
    where, [:port] is optional.
    or
    <jnlp spec="1.0+" codebase="/abc" href="launch.jnlp">
    I receive an error from JWS if using the second one.
    2) Is there a way to get around from specifying the additional resources (via the resources tag) that a given application may require so that the DownloadService will be able to locate them? I specified the exact URL given in my code within my jnlp file and it did find the reource for download... but I want to drive the additional resources from a configuration standpoint so as to have a plugable application. Once the application is deployed to my application server I want to minimize my downtime (as people would have to explode my ear/war to modify the jnlp file for additional resources) in regards to installing new applications.
    Many thanks in advance.

  • Why no exception to DownloadService.loadPart Function when network is down?

    The function call to loadPart(jarlist, lisenter) hangs ( no exception) when network is down. This is not happening always.
    I am using in following manner
    DownloadService service = (DownloadService ) ServiceManager.lookup("javax.jnlp.DownloadService);
    service. loadPart(jarList, listener);
    I have tried reproducing this issue by making the network download but not able to reproduce but it has happened couple of time randomly.
    kindly help me and provide the solution if somebody has some information about this issue..
    Regards,
    Piyush

    Calling BasicService.isOffline() could be a good preliminary test. Anyway I guess DownloadService relies on HttpURLConnection, you could try playing with default timeout.
    Bye.

  • [JNLP] DownloadService and DownloadServiceListener

    Hi,
    My appologies if this has been asked before.
    Under <Java Web Start>\.javaws\cache\http\<...>
    in Win32, I can see the downloaded JNLP and JAR
    files with "some prefix" attached to those file
    names.
    What and how, e.g., javax.jnlp.DownloadService,
    javax.jnlp.DownlodServiceListener, or so, how
    can we use to determine when the download completed
    and find the actual path for the downloaded file,
    e.g., "mypackge.jar",
    PROGRAMATICALLY.
    In case there is no standard or normal way to
    accomplish this, is there a trick to do for this
    specific need?
    Regards,
    Pae

    this only works when you are using an installer jnlp
    <installer-desc>
    service = (ExtensionInstallerService)ServiceManager.lookup("javax.jnlp.ExtensionInstallerService");
    installPath = service.getInstallPath();
    I think this is what your looking for, hope it helps.

  • Loading an XML File in an Application!

    Hy Guys!
    I'm quite new on Java, so I'm missing some important knowledge, for example: how to load an XML file in an Application downloaded by Java WebStart:
    In Details:
    I'm downloading an Application which needs an XML File for setting up an Legend. As far as I know, the XMLParser needs a File as argument to parse. By Java WebStart/jnlp, I can't download the XML-File to the local machine, and trying to create an instance by the url (as String), doesn't work. So now I'm missing some information, and I hope you can help me:
    Is there a possiblility to download the XML file via the application explicitly,
    or is there a possibility to "convert" the ResourceInputStream into a "parseable" class?
    I'm happy for every suggestion ..
    some code:
    public class EvalXML extends org.xml.sax.helpers.DefaultHandler {
    /** Creates a new instance of EvalXML */
    public EvalXML() {
    * @param args the command line arguments
    public static int main(String[] args) {
    DefaultHandler handler = new EvalXML();
    SAXParserFactory factory = SAXParserFactory.newInstance();
    String url = new String();
    //String url = EvalXML.class.getClassLoader().getResource("com/msgis/res/Lcc_Test_XML_Addressen.xml").getPath();
    //String url= "msgis.jar!/com/msgis/res/Lcc_Test_XML_Addressen.xml";
    if (args[0] + "empty" != "empty") url = args[0];
    else{
    System.out.println("no argument");
    return 0;
    System.out.println("PATH: \n" + url + "\n");
    try{
    SAXParser saxParser = factory.newSAXParser();
    //saxParser.parse(new File(EvalXML.class.getClassLoader().getResource("com/msgis/res/Lcc_Test_XML_Addressen.xml").getPath()), handler);
    saxParser.parse(new File(url), handler);
    System.out.println("pascht");
    catch(Throwable t){
    System.out.println(t.getMessage());
    return 1;
    regards dominik

    Although nobody wrote back, it is the quality of a forum depends on soluted problems so:
    the following function loads the file from the server to the box:
    public boolean loadResource(String pURL){
    DownloadService ds;
    URL lURL;
    boolean lLoaded = true;
    try{
    lURL = new URL(pURL);
    try {
    ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
    } catch (UnavailableServiceException e) {
    ds = null;
    lLoaded = false;
    if (ds != null) {
    try {
    // determine if a particular resource is cached
    //URL url = new URL("http://java.sun.com/products/javawebstart/lib/draw.jar");
    boolean cached = ds.isResourceCached(lURL, "1.0");
    // remove the resource from the cache
    if (cached) {
    ds.removeResource(lURL, "1.0");
    // reload the resource into the cache
    DownloadServiceListener dsl = ds.getDefaultProgressWindow();
    ds.loadResource(lURL, "1.0", dsl);
    } catch (Exception e) {
    e.printStackTrace();
    lLoaded = false;
    catch(MalformedURLException mue)
    System.out.println(mue.getMessage());
    lLoaded =false;
    return lLoaded;
    dominik

  • JAR File Will NOT Update on WebStart!

    I want an updated jar application to run on WebStart, but it always runs the original jar file I put on the server. (The update of the jar file works fine by itself.) I have updated the .jar file as well as the .jnlp file. I have tried deleting the cache in Webstart. I have also fully reloaded WebStart, and the .jar files when nothing else worked. I even totally renamed the .jar and .jnlp files, and it still runs the original file. Everything else works smoothly.
    Any suggestions?

    If you want your application to always check for a new version, you should use the JNLP API, i think the DownloadService(http://java.sun.com/products/javawebstart/docs/javadoc/javax/jnlp/DownloadService.html) interface will do the job. Here�s an example:
    import javax.jnlp.*;
        DownloadService ds;
        try {
            ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
        } catch (UnavailableServiceException e) {
            ds = null;
        if (ds != null) {
            try {
                URL url =
                        new URL("http://java.sun.com/products/javawebstart/lib/YOURAPP.jar");
                if ( ! YourApp.isLastVersion() ) { // some method to check versions on the server....
                    ds.removeResource(url, "1.0");
                    // reload the resource into the cache
                   DownloadServiceListener dsl = ds.getDefaultProgressWindow();
                   ds.loadResource(url, "1.0", dsl);
            } catch (Exception e) {
                e.printStackTrace();
        }

  • How to locate files in cache

    I'm using JDK 6.11 on MS Windows and would like to call Runtime.getRuntime().exec() on a JWS downloaded .exe file. Therefore I need the exact path to the file in the JWS cache. I could do a file search in
    C:\\Dokumente und Einstellungen\\Stefan von Wachter\\Anwendungsdaten\\Sun\\Java\\Deployment\\cache
    but this seems to be an error prone solution. (Although it works on my system.)
    It is interesting that I can successfully call loadLibrary() for a .dll residing in the same .jar archive than the .exe .
    I don't understand why there isn't an API in javax.jnlp.DownloadService for getting the location of the downloaded files.
    There is a JNLP sample WebPad, but it doesn't show my problem because the source code for HelpSet is not available.
    There is a related forum thread
    http://forums.sun.com/thread.jspa?threadID=5319615&tstart=150
    (Problem with java web start resources (no !/ in spec) )
    but it doesn't contain a clean solution.
    Thanks for help,
    Stefan

    My installer app is now running, but not working ...
    It should be mentioned that the installer.jnlp needs a security statement for accessing files on local disk:
      <security>
        <all-permissions/>
      </security> Unfortunately I still don't see how to get a (.exe or other) file out from the .jar and copy it to a specified location on the local disk.
    It ist possible to read an image file using:
             URL icURL = getClass().getResource( "/winexeinstaller/TMLogo2.png" );
             ImageIcon myIc = new javax.swing.ImageIcon( icURL );But if I call
          FileInputStream   from = new FileInputStream( fromFile );it throws the FileNotFoundException
    SCHWERWIEGEND: fileCopy failed
    java.io.FileNotFoundException: http:\10.64.76.247\apixWithOcean\lib\WinExeInstaller.jar!\winexeinstaller\DataTransfer.zip (Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at winexeinstaller.Installer.fileCopy(Installer.java:174)
         at winexeinstaller.Installer.<init>(Installer.java:72)
         at winexeinstaller.Installer.main(Installer.java:96)These problems have been discussed here, but I don't see the solution.
    The jws Spec says:
    The installer extension is intended to install platform-specific native code that requires a more complicated
    setup than simply loading a native library into the JVM, such as installing a JRE or device driver. The installer
    executed by the JNLP Client must be a Java Technology-based application. Note that this does not limit the
    kind of code that can be installed or executed. For example, the installer could be a thin wrapper that executes
    a traditional native installer, executes a shell script, or unzips a ZIP file with native code onto the disk.So it should be possible. Could somebody tell my how?
    Thanks,
    Stefan

  • Download  resources that are not listed in the JNLP file

    There is some way to download resources that are not listed in the JNLP file, and then
    ask for them with DownloadService ? (isResourceCached)
    thanks.

    currently, the jnlp spec requires DownloadService to access only resources specified in the jnlp file..
    changing this is a proposed RFE for the next spec version:
    4908304: JWS DownloadService should not require mention in JNLP file
    /Dietz

  • Java Web Start and scheduled updates

    Is it possible to do silent updates during Nighttime(when bandwith usage is low) via the operating system level(scripted updates). So that the client already has the newest packages available at hisk computer when he comes in the morning?

    Although there is no builtin way of doing this, you could implement it youself by writing another app that
    listed all your main apps resources as lazy resources, and then, (after sleeping till the middle of the night) used the DownloadService api to load those resources.
    (if it did find new versions you would have to pop up a window telling the user to exit, and re-launch any old version of the app that was left running)

  • Web service Logon ticket

    Hi,
    Is there a way to generate a logon ticket in an EJB?
    I face the following problem: on server A(SAP ABAP) there is a web service, which I consume on server B(SAP Java AS) and create a REST, which is called from an UI5 application on server C(SAP Gateway).
    When I call the consumed service from server B via WSNavigator or EJB explorer its working. BUT when the service is called by the REST its throwing the following exception:
    Error while creating assertion ticket on demand. No logged in user found.
    Assertion ticket could not be retrieved. Error was No logged in user found.. [EXCEPTION] java.lang.IllegalStateException: No logged in user found. at com.sap.security.core.server.jaas.SAPLogonTicketHelper.createAssertionTicket(SAPLogonTicketHelper.java:496) at com.sap.security.core.server.jaas.AssertionTicketFactoryImpl.createAssertionTicket(AssertionTicketFactoryImpl.java:67) at com.sap.engine.services.wssec.srt.protocols.GetAssertionTicketPrivAction.run(GetAssertionTicketPrivAction.java:36) at com.sap.engine.services.wssec.srt.protocols.GetAssertionTicketPrivAction.run(GetAssertionTicketPrivAction.java:20) at java.security.AccessController.doPrivileged(Native Method)...
    I think it is working from WSNavigator/EJBExplorer because there I'm logged in and Logon Ticket is generated and sent to server A, but because server C communicate with server B via REST(jsonp ajax call), there is no generated Logon Ticket on server B.
    Is there a way to generate a Logon ticket or set credentials to the web service. I tried the following but its not working:
    ZCUUTLI0016BPMTYPEDOWNL test = downloadService.getZCUUTLI0016_BPM_TYPE_DOWNL();   
      Mapreq_ctx = ((BindingProvider)test).getRequestContext();
           Map> headers = new HashMap>();
    headers.put("Username", Collections.singletonList("user"));   
    headers.put("Password", Collections.singletonList("password"));
    req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
    Note: Other possible solutions are also welcome.
    Thanks,
    Ivan

    hi ivan,
    for your scenario - does the abap backend call require a real user or is a technical user sufficient? if only a technical user is required you can define one in the single service administration/ application communication configuration of your portal System.
    in order to use the logon ticket of your ajax call i think you need to configure/setup the correct sso - environment. checkout this link
    http://help.sap.com/saphelp_nw74/helpdata/en/7a/9ad1882c244de0a3a99c1e46095ab3/content.htm?frameset=/en/c4/81215150e92414e10000000a44176d/frameset.htm&current_toc=/en/ad/612bb3102e4f54a3019697fef65e5e/plain.htm&node_id=87
    regards,
    christian

  • Downloading updated jars with java webstart

    I have a web start application where I download individual data jars using the javaws DownloadService API. These jars change infrequently but do change. My initial implementation was relatively straightforward:
    String dataArchiveUrl = study.getDataArchiveUrl();
    URL url = new URL(dataArchiveUrl);
    DownloadServiceListener dsl = new MyTestDownloadServiceListener();
    ds.loadResource(url, null, dsl);This works great for the initial download and when there is no update to the data jar. The problem is that when the data jar is updated, javaws does not download the update unless I manually delete the original data jar from the web start cache. I had expected(hoped?) that loadResource would work like javaws and check the timestamp of the resource to determine if an update was needed, but that does not appear to be what happened. I have confirmed that the jar timestamps are being served accurately.
    I was able to put in a work around that checks the timestamp and, if the server timestamp is newer, removes the resource from the cache. This forces webstart to update the data jar when the timestamp is updated but is less than ideal for a couple reasons:
    (1) It seems inefficient to open up my own URLConnection to the resource. Is there a way to get webstart to handle the updating for me based on the timestamp?
    (2) The application is designed for offline use. The work around removes the data jar before downloading the new one. This would seem to open a gap where if a user starts downloading an update but gets disconnected before finishing, they won't have access to either the old or new data file. Does anyone have any ideas on closing this gap?

    I have a web start application where I download individual data jars using the javaws DownloadService API. These jars change infrequently but do change. My initial implementation was relatively straightforward:
    String dataArchiveUrl = study.getDataArchiveUrl();
    URL url = new URL(dataArchiveUrl);
    DownloadServiceListener dsl = new MyTestDownloadServiceListener();
    ds.loadResource(url, null, dsl);This works great for the initial download and when there is no update to the data jar. The problem is that when the data jar is updated, javaws does not download the update unless I manually delete the original data jar from the web start cache. I had expected(hoped?) that loadResource would work like javaws and check the timestamp of the resource to determine if an update was needed, but that does not appear to be what happened. I have confirmed that the jar timestamps are being served accurately.
    I was able to put in a work around that checks the timestamp and, if the server timestamp is newer, removes the resource from the cache. This forces webstart to update the data jar when the timestamp is updated but is less than ideal for a couple reasons:
    (1) It seems inefficient to open up my own URLConnection to the resource. Is there a way to get webstart to handle the updating for me based on the timestamp?
    (2) The application is designed for offline use. The work around removes the data jar before downloading the new one. This would seem to open a gap where if a user starts downloading an update but gets disconnected before finishing, they won't have access to either the old or new data file. Does anyone have any ideas on closing this gap?

  • Extension libs in Tomcat .war

    Hi all. After researching ANT for a bit, and the ins-and-outs of .war files, I'm feeling a bit more adventerous with deploying web apps via JWS.
    I've been studying the very good Sun/Oracle tutorials on deploying apps via Web Start, but I'm stuck on the JNLP API. I don't understand when or why I need to use the classes in the api such as DownloadService.
    I came across having to use the jnlp library when the code I would expect to work fails without error.
    (The console opens, appends nothing, closes)
    I have all my code in a try block, so it's a bit strange that catch (Exception e) catches nothing. - Or at least keeps the console open :/
    (For ease of tracking, questions will be numbered!)
    +1) Are there any java logs or anything where I can verify what is going on?+
    So, after some reseach, it most likely is because I am using extension libs in my war.
    +2) Is it?+
    I will add the jnlp file I create is made by a servlet (after taking some params etc from my JSPs).
    A copy of the generated file I have saved and hosted on the remote server, which JaNeLa verifies as follows (where jdom.jar and jaxen-1.1.3.jar are simple pointer jnlps to the jars in my /web directory along with all my other files):
    JaNeLA Report - version 10.03.10
    Report for http://hemmels.dyndns.org/WebTriad/web/jnlp.jnlp
    XML encoding not known, but declared as UTF-8
    Optimize this application for off-line use by adding the <offline-allowed /> flag.
    Downloads can be optimized by specifying a resource size for 'web/PokeTriad.jar'.
    The resource download at web/PokeTriad.jar can be optimized by removing the (default) value of download='eager'.
    Lazy downloads might not work as expected for web/PokeTriad.jar unless the download 'part' is specified.
    Downloads can be optimized by specifying a resource size for 'http:/reference.itags.org/reference/link/?url=img/OntoramaLogo-smaller.jpg'.
    Icon loading & use can be optimized by specifying the width and height for http:/reference.itags.org/reference/link/?url=img/OntoramaLogo-smaller.jpg
    Report for http://hemmels.dyndns.org/WebTriad/web/jaxen.jnlp
    XML encoding not known, but declared as UTF-8
    Downloads can be optimized by specifying a resource size for 'lib/jaxen-1.1.3.jar'.
    The resource download at lib/jaxen-1.1.3.jar can be optimized by removing the (default) value of main='false'.
    Lazy downloads might not work as expected for lib/jaxen-1.1.3.jar unless the download 'part' is specified.
    Report for http://hemmels.dyndns.org/WebTriad/web/jdom.jnlp
    XML encoding not known, but declared as UTF-8
    Downloads can be optimized by specifying a resource size for 'lib/jdom.jar'.
    The resource download at lib/jdom.jar can be optimized by removing the (default) value of main='false'.
    Lazy downloads might not work as expected for lib/jdom.jar unless the download 'part' is specified. I have added code for using a DownloadService to access these jars from the client (can't remember which page this was from):
    try{
                   DownloadService ds;
                  try {
                      ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
                      Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(
                                "DownloadService started!");
                  } catch (UnavailableServiceException e) {
                      ds = null;
                  if (ds != null) {
                      try {
                          // determine if a particular resource is cached
                          URL url = new URL("http://hemmels.dyndns.org/WebTriad/web/jdom.jar");
                          boolean cached = ds.isResourceCached(url, "1.0");
                          // remove the resource from the cache
                          if (cached) {
                              ds.removeResource(url, "1.0");
                          // reload the resource into the cache
                          DownloadServiceListener dsl = ds.getDefaultProgressWindow();
                          ds.loadResource(url, "1.0", dsl);
                      } catch (Exception e) {
                          e.printStackTrace();
                  }3) Is this right? I need to use the jnlp api to access extension libs from Tomcat?
    This confirms my suspicions with the problem stemming from libraries in my war file because now when running the app I get the following error:
    29-Oct-2010 00:35:25 runtime.PokeClient <init>
    INFO: DownloadService started!
    29-Oct-2010 00:35:25 runtime.PokeClient <init>
    SEVERE: jdom lib could not be cached!
    com.sun.deploy.net.FailedDownloadException: Unable to load resource: (http://hemmels.dyndns.org/WebTriad/web/jdom.jar, 1.0)
         at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
         at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
         at java.util.concurrent.FutureTask.run(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by:
    java.io.IOException: missing version response from server
         at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
         at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
         at java.util.concurrent.FutureTask.run(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)which is thrown when the code hits:
    DownloadService ds;
                  try {
                      ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
                      Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(
                                "DownloadService started!");
                  } catch (UnavailableServiceException e) {
                      ds = null;
                  if (ds != null) {
                      try {
                          // determine if a particular resource is cached
                          URL url = new URL("http://hemmels.dyndns.org/WebTriad/web/jdom.jar");
                          boolean cached = ds.isResourceCached(url, "1.0");
                          // remove the resource from the cache
                          if (cached) {
                              ds.removeResource(url, "1.0");
                          // reload the resource into the cache
                          DownloadServiceListener dsl = ds.getDefaultProgressWindow();
                          ds.loadResource(url, "1.0", dsl);
                          Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(
                                     "jdom lib is now cached!");
                      } catch (Exception e) {
                          Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).severe(
                                      "jdom lib could not be cached!");
                          e.printStackTrace();
                  }So before I go any further into guessing (have been googling/lurking in this forum for this problem for a week and found nothing), +4) am I along the right lines (i.e. am I trying to do something incorrectly or worse, something you can't do), or do I need to implement the "javax.jnlp.DownloadService" properly?+
    Other information would be that the jar file ("http://hemmels.dyndns.org/WebTriad/web/jdom.jar") is accessable from a browser.
    Appreciate any replies and the time spent reading.
    Edited by: 798437 on Oct 28, 2010 11:44 PM
    Spelling.
    Edited by: 798437 on Oct 28, 2010 11:45 PM
    code blocks
    EDIT: I understand the issue java.io.IOException: missing version response from server, is from versioned extensions or something, having googled this I found I need the following version.xml in the /web folder:
    <jnlp-versions>
       <resource>
          <pattern>
             <name>jaxen-1.1.3.jar</name>
             <version-id>1.0</version-id>
             <locale>en_GB</locale>
             <locale>en</locale>
          </pattern>
          <file>jaxen-1.1.3.jar</file>
      </resource>
      <resource>
          <pattern>
             <name>jdom.jar</name>
             <version-id>1.0</version-id>
             <locale>en_GB</locale>
             <locale>en</locale>
          </pattern>
          <file>jdom.jar</file>
      </resource>
    </jnlp-versions>+5) Do I need a JNLPDownloadServlet or something or this this something different, and again, am I down the wrong path?+
    Edited by: 798437 on Oct 28, 2010 11:47 PM

    All the above seems to be irrelvant.
    My console was closing because the client's stream was empty, and I was trying to read from it.
    This was causing an Exception in my client code I wasn't catching (shame on me).
    Consider it a hard lesson learnt :)

Maybe you are looking for