Accessing Java HttpServer from PHP;

Hello all,
I have created an httpserver using 'com.sun.net.httpserver'. Everything works fine except one thing.
When i make this simple call from PHP (http://localhost:8081/something outputs an XML file):-
$url = 'http://localhost:8081/something'; 
$xml = simplexml_load_file($url); 
print_r($xml); Nothing appears and it times out after sometime.
However, while the browser is 'trying' to get the result (from PHP file) if i 'stop' my HttpServer (Java) the result suddenly appears. I am very sure i close all the streams i opened. Does anyone have any idea?
Thanks
Neville

So on doing some debugging i realized that the http thread that started executing may have not exited correctly. That may explain the fact that when i shut the java server down explicitly while the 'php' code waits for some response, the response suddenly appears.
While creating the server i am using:-
server.setExecutor(Executors.newCachedThreadPool());In ThreadPoolExecutor.class
Runnable getTask() { ....
if (state == SHUTDOWN)  // Help drain queue
    r = workQueue.poll();
else if (poolSize > corePoolSize || allowCoreThreadTimeOut)
    r = workQueue.poll(keepAliveTime, TimeUnit.NANOSECONDS);
else
   r = workQueue.take();
if (r != null)
    return r;
if (workerCanExit()) {
...Using the debugger tool took me to the class ThreadPoolExecutor.class which seems to be the bottleneck; This condition is true (poolSize > corePoolSize || allowCoreThreadTimeOut(=false)) and it starts polling. I think maybe this is causing the problem and if it exited maybe the result would appear. Even if the corePoolSize is more than poolsize it seems to be getting stuck in r = workQueue.take();.
I dont know how it works ok with a browser but hangs when PHP request comes into the picture. Strange...
Thanks
Neville

Similar Messages

  • (how) can I access Java APIs from web-page-hosted JavaScript?

    Can I access Java APIs from a web-page via JavaScript if I have a JRE installed on the client machine? And if so, how?
    Thanks in advance for your time and consideration.

    John L. wrote:
    Can I access Java APIs from a web-page via JavaScript if I have a JRE installed on the client machine? And if so, how?As far as I can remember that was actually possible in the very first versions of Netscape because Netscape really wanted to pretend Javascript and Java were meant to be used together. But they soon removed that functionality. Can you guess why?
    Because people were using the File/IO classes to easily steal or remove files on the harddrive, among other such niceties. You do NOT want to have such control from a web application. People will abuse it.

  • Accessing java objects from within javascript

    Hello,
    Anyone with an idea of a useful toolkit for accessing java objects from within javascript will be much appreciated.
    Thanks in advance,
    Antana.

    What do you mean by accessing Java objects? Do you mean interacting with an applet via JavaScript? Something else?

  • Accessing Java Classes from Forms

    Is is possible to access a Java class from Forms? I have been
    creating an Active X control that returns a Java object, and from
    that I can call methods on that object, but I would really like
    to do that without having and Active X control in the mix. Any
    suggestions?
    null

    Oracle Developer Team wrote:
    : Robert Nocera (guest) wrote:
    : : Oracle Developer Team wrote:
    : : : hey robert -
    : : : Developer 6.0 provides this ability for web deployment.
    You
    : : can
    : : : insert your own custom Java components into your
    application
    : : and
    : : : they will appear in the application when it is run via the
    : web.
    : : : If you look at the documentation for 6.0, there are a few
    : : : section son Pluggable Java Components and JavaBeans that
    : : : describes what is provided and how you use the interfaces
    : and
    : : : classes we provide.
    : : : A whitepaper on this topic will be posted to the OTN
    : shortly,
    : : as
    : : : well as some samples that illustrate how to go about doing
    : it.
    : : : cheers!
    : : : -Oracle Developer Team-
    : : Thanks for the quick response. Is there any way to access
    : those
    : : classes without being in a web deployment. That's probably
    : not
    : : totally out of the question, but what we had in mind was
    : adding
    : : some Java Functionality (actually connectictivity to some
    EJBs
    : : that we have) to existing forms. Currently there forms are
    : not
    : : deployed in a "web" environment and are just run from the
    : forms
    : : runtime engine.
    : : -Rob
    : hey again robert -
    : there's no easy way (yet!) to call out from forms runtime
    : process to a Java application.
    : We've played around some with creating an ORA_FFI interface to
    : JNI and then wrappering this with PL/SQL code. We've been able
    : to make calling into an EJB running in 8i from a forms runtime
    : work using this approach.
    : Let me know if this is of interest to you and I can post the
    : stuff we've currently got. It's no more than a simple demo and
    : is not complete. It requires quite a bit of manual coding on
    : the PL/SQL side since the interface emulates JNI (FindClass,
    : GetMethodID, CallMethodID, etc.).
    : cheers!
    : -the Oracle Developer Team-
    I'd be interested in this ORA_FFI doc you've been playing with.
    Would you please email it to me or post it.
    null

  • WPC: Access Java beans from XSL

    Hi,
    How can we access custom Java beans from within the XSLs used to render WPC webforms? Do we have to implement a custom XSLT Helper? I am able to access standard Java classes using the <xmlns> tag but when I try to reference our custom classes the WPC editor throws a ClassNotFound exception. Any help will be appreciated.
    Thanks and Regards,
    Shibendra

    Hi,
    How can we access custom Java beans from within the XSLs used to render WPC webforms? Do we have to implement a custom XSLT Helper? I am able to access standard Java classes using the <xmlns> tag but when I try to reference our custom classes the WPC editor throws a ClassNotFound exception. Any help will be appreciated.
    Thanks and Regards,
    Shibendra

  • Accessing java classes from javascript

    Hi,
    I have the following javascript function
    function testjava {   
        var myString = new java.lang.String("Hello world"); // line 1
        alert("len:"+myString.length()); // line 2
    }It gives me a error at line 1 saying "'java' is undefined" in IE browser 5.5 sp2. But, both the lines execute correctly in netscape 6.
    Can someone please help..
    Thanks,
    Vijay.

    It seems that IE 5.5 doesn't support accessing java classes in JavaScript, so try to install IE 6 to see if it works or maybe, you doesn't have installed propertly support for JVM in IE.

  • Access Java object from Javascript

    Hi
    I'm trying to invoke a Java object from Javascript (scriptengine and all that).
    I want to add scripting features to a GeneXus Java generated app... and I have very basic skills on java too. Sorry for that ;o).
    This is the java code to pass "params" to the scriptengine:
    engine.put("remoteHandle",remoteHandle);
    engine.put("context", context); The remoteHandle (int) and context (com.genexus.ModelContext) pass trough all the gx-java generated programs.
    This javascript works fine:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle).execute( ) ;The remoteHandle conversion is ok (javascript-number to int). The context is optional.
    But if I want to pass context:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle, context).execute( ) ;Fails with this:
    "javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Java constructor for 'uftestjs' with arguments 'number,javax.script.SimpleScriptContext' not found."
    Obviously, no conversion is possible with context (javax.script.SimpleScriptContext to com.genexus.ModelContext).
    There is some way to reference de original context, by the object Id??? or something like that???
    Thanks in advance for any replies!!!
    Greetings from Chile. (I hope you can understand my english!)

    Hi
    Well, since this topic is about java programming I think the place is right here.
    (I use some tricks to embed java statements in genexus objects...)
    I will try to get some help at Artech (GX) on how to build something... to get the conversion needed.
    But they are not focussed on support this kind of questions.
    Anyway, I want to know: do I can to reference an object by the objId?
    I want to code something like this:
    com.genexus.ModelContext context =
                     (com.genexus.ModelContex)getTheObjectFromTheJVM(theObjectId);(powered by google translator, ha!)

  • Accessing Java objects from C++ client

    I have a number of Java CORBA server objects that I have deployed to an 8.1.7 database.
    I can invoke these objects from a Java client with no problem, but I also need to access them from a C++ client.
    I have used idl2cpp from VisiBroker for C++ (version 4.5) to generate the client stubs, and I've downloaded the interop.tar file from http://technet.oracle.com/products/oracle8i/htdocs/jserver_faq/interop.tar
    The problem that I have is that I have not been able to build a client program because login.lib from interop.tar generates conflicts at link time. I've tried everything that I can think of, but I always end up with either missing references or multiply defined symbols. I've tried building using both MS Visual C++ and Borland C++Builder, but with no success.
    Has anybody succeeded in building a C++ client? Surely it shouldn't be this difficult?
    Thanks,
    Tony

    Thank u for taking care of me
    But the hint given by u is not apt to my query.
    If any new suggestion pls send again

  • Access java properties from C++/JNI program

    Hello all,
    Is it possible to access the Java properties of a JNI VM from a C++ program?
    If so, could the code or process be explained to me.
    I want to be able to identify a specific VM that is retrieved by the JNI_GetCreatedJavaVMs
    call. I set a user property when the VM was created, and would like to verify its value
    before calling AttachCurrentThread.
    Thanks in advance.
    Mark

    Are you saying that you set a system property (via System.setProperty() or -D)?
    If so, just use the JNI invocation API to call System.getProperty().
    Without error checking, that looks something like this:bool isMySystem( JNIEnv* env ) {
      const string PropertyName = "IsMySystem";
      jclass systemClass = env->FindClass( "java/lang/System" );
      jmethodID getPropertyMethod = env->GetStaticMethodID( systemClass, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;" );
      jstring propertyNameString = env->NewStringUTF( PropertyName.c_str() );
      jstring propertyString = env->CallStaticObjectMethod( systemClass, getPropertyMethod, propertyNameString );
      if ( propertyString == 0 ) {
        return false;
      const char* property = env->GetStringUTFChars( propertyString, 0 );
      boolean isMine = ! strcmp( property, "Yes" );
      env->ReleaseStringUTFChars( propertyString, property );
      return isMine;
    }Using Jace, http://jace.reyelts.com/jace (a free, open-source toolkit), this would look more like:bool isMySystem() {
      String property = System::getProperty( "IsMySystem" );
      return property.isNull() ? false : prop == "Yes";
    }In the end, Jace ends up making all of the exact same calls, but you can see how much easier it is to use.
    God bless,
    -Toby Reyelts

  • How to access Oracle DB from PHP on 10.5 server?

    I am writing a PHP-based application that needs to pull data from an Oracle database... the app is hosted on a G5 server running 10.5.3.
    Has anyone had any success building Oracle support into PHP on Leopard? Does anyone happen to know of a good howto to follow?
    Any and all help is greatly appreciated.
    Thanks,
    ~s

    Hi swati,
    1. for this u will also require help of basis team.
    2. these are the steps.
    a) make an entry in DBCON
    b) make connection string
    (on the physical application server,
    so that it can connect to secondary database)
    (this will be done by basis team,
    in which, they will specify the
    IP address of the secondary database server,
    the DATABASE ID, and the port number)
    c) then using open sql / native sql,
    we can use the secondary database connection,
    just like normal.
    d) if we use open sql,
    then there must be Y/Z table on
    sap as well as secondary database,
    and the field names , their type all should be identical.
    regards,
    amit m.

  • Again Issue with installing php 5.3.0 and accessing ABAP code from php

    I have the following initial set up:
    1.Downloaded u201CApache Friends XAMPP (Basis Package) version 1.7.2u201D.
    With this I got :
    Apache 2.2.12 (IPV6 enabled)
    MySQL 5.1.37 (Community Server) with PBXT engine 1.0.08-rc
    PHP 5.3.0 + PEAR (PEAR, Mail_Mime, MDB2, Zend)
    2.Installed the above XAMPP package.
    3.created a local test.php file and placed in htdocs folder
    3.Started the Apache server and executed the test.php file from u201Chttp://localhost/test.phpu201D. it runs absolutely fine. I can see the output in my browser. (just did an "Hello world" coding)
    4.Now I downloaded the SAPRFC (saprfc-1.4.1.All.zip)  package.
    5.In this, I got u201Cphp_saprfc_530.dllu201D which I added to my extension file where all the other dll files are present.
    6.Then I opened the u201Cphp.iniu201D file and added the above saprfc dll file to the extension directory   as u201Cextension=php_saprfc_530.dllu201D.
    7.Now I installed u201Cvcredist_x86.exeu201D.
    8.Finally I started the apache server afresh. I get the following message and the apache server is started.
    "PHP StartUp: saprfc: Unable to initialize module
      Module compiled with build ID=API20090626,TS
      PHP compiled with build ID=API20090626,TS,VC6
      These options need to match"
    i have SAPGUI installed on my PC.
    details of SAPGUI is
    release: final release 710
    file version: 7100.4.15.1047
    build: 1108370
    patch level: 15
    hotfix : 1
    Somebody please help me solve this.
    Thanks in advance,
    Pramod
    Edited by: PramodShankar B on Dec 11, 2009 11:53 AM
    Edited by: PramodShankar B on Dec 11, 2009 11:56 AM

    Pramod:
    I'm not sure which version do you need...but I would recommend you some trial an error...download the package 1.4 (All zip versions and try to find the one that suits you)...that's what I did for my PHP 5.2.4 because both PHP and the SAPRfc must have been compiled with exact the same ID.
    Greetings,
    Blag.

  • Accessing Java Classes from Webservice Stubs

    So far I have been able to call a web service and copy the appropriate directories and files to the designated class path.  I can also successfully access a class file like this:
    MyObject = CreateObject("java", "ca.x.y.z.TestCollection.TestItem");
    However, whenever I try to do something with that variable, I get a white screen.  Any text that should have appeared before the command, will appear, but nothing appears afterwards, not even debugging info.  Here are a couple of commands that will cause this to happen.
    <cfdump var = "#MyObject#">
    MyObject = CreateObject("java", "ca.x.y.z.TestCollection.TestItem").init();
    x = MyObject.init();
    Anybody have any ideas?

    Ah, nothing like a fresh set of eyes to remind of the fundamentals.  Thank you for that.
    I actually could create a normal error by calling a method incorrectly.  I would see the grey box and my debgging info would appear.  However, if I did something I expected to succeed, it would seem to stop.  Any text above that command would appear.  No error message, no de-bugging.
    But I didn't think to look in our error log.  I see things like:
    Could not initialize class com.microsoft.schemas._2003._10.Serialization.Arrays.ArrayOfstring
    or
    org.apache.axis.description.TypeDesc.(Ljava/lang/Class;Z)V
    At least it's not a mystery anymore.  Thanks again for suggesting the error log.

  • Accessing  java service from c++ client through wsdl

    Java service is deployed in SOAP. It has to be accessed by the client program written in c++ language. It should be done through WSDL.
    If anyone had previously faced or came to know abt this problem.
    Pls inform me abt the process.

    Thank u for taking care of me
    But the hint given by u is not apt to my query.
    If any new suggestion pls send again

  • Accessing java fields from c++

    I have created a JNI app that needs to access the fields of the java object but when I try to access them I get an error message saying "no such field."
    When I created my header file with javah I got (JNIEnv *, jclass and jobject) as my parameter list not JNIEnv * and jobject like all the documentation does.
    then i try to access the fields with :
    fidZone = env->GetFieldID(cls, "zone","I");
    which generates the error mentioned.
    Any suggestions will be greatly appreciated.
    Cheers.

    1. Here is the native code:
    #include <jni.h>
    #include <stdio.h>
    #include "worldfl.h"
    //header for external DLL I want to access
    #include "GDAit.h"
    JNIEXPORT jlong JNICALL
    Java_worldfl_TransProjectPt(JNIEnv *env, jclass cls, jobject obj)
    jfieldID fidx, fidy, fidStr, fidZone, fidTrDir;
    long zone, agd2gda, iResult = 0;
    double transX, transY, newX, newY, accX, accY;
    /* GET the X & Y values of the coords in the world file */
    cls = env->GetObjectClass(obj);
    printf("%ld\n", cls);
    if (cls != NULL)
    fidZone = env->GetFieldID(cls, "zone","I");
    fidTrDir = env->GetFieldID(cls, "agd2gda","I");
    fidx = env->GetFieldID(cls, "transX","D");
    fidy = env->GetFieldID(cls, "transY","D");
    /*fidStr = env->GetFieldID(cls, "filename","Ljava.lang.String");*/
    transX = env->GetDoubleField(obj, fidx);
    transY = env->GetDoubleField(obj, fidy);
    zone = env->GetDoubleField(obj, fidZone);
    agd2gda = env->GetDoubleField(obj, fidTrDir);
    iResult = 0;//TransProjPt("f:\\coordcalcs\\A66 National (13.09.01).gsb", agd2gda, transX, transY, zone, &newX, &newY, &accX, &accY);
    else
    printf("Class is NULL\n");
    //env->GetDoubleField(obj, fidx) = newX;
    //env->GetDoubleField(obj, fidy) = newY;
    return(iResult);
    2. Yes it is defined as static
    private native static long TransProjectPt(worldRead wr);

  • How to access java arraylist from xslt v1?

    Hi everybody,
    I have a problem using xsl trasformation and an object that contains nested arraylistes.
    the object is structured in this way
    Request
    |---id
    |---event
    |---ListOfComponent
    |------*<List>component*
    |---------idComponent
    |---------description
    |---------*<List>properties*
    |-------------name
    |-------------value
    I'm able to get the values of id and event in this way: Request.id and Request.event;
    I'm not able to get the values of the idComponent and the name values of the list subobjects: Request.ListOfComponent.component[0].idComponent;
    When I execute the application that call the xsl trasformation i get an exeption not a vector or an array.
    So, I would like to know if is possible and if yes how can I do!
    thanks!
    Edited by: EttoreMI on 10-nov-2011 7.21
    Edited by: EttoreMI on 10-nov-2011 7.21

    Since I'm using an HP product right now I can only the exeption without stack
    Unexpected exception: java.lang.Exception: Cannot create a new transformer instance: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Illegal value: objInput.listOfComponent.component[0].idAppuntamento used for QNAME attribute: name
    localhost.localdomain     Nov 10, 2011 9:54:12 AM     TransformXML     Running Errorhandler ID #682. Workflow: 'inserisciAppuntamento', Step: 'TransformXML', com.hp.ov.activator.mwfm.component.WFException: Cannot create a new transformer instance: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Illegal value: objInput.listOfComponent.component[0].idAppuntamento used for QNAME attribute: name
    here the xsl trasformation that I wrote
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:param name="JOB_ID" />
    <xsl:param name="objInput"/>
    <xsl:param name="objInput.requestId"/>
    <xsl:param name="objInput.idOdl"/>
    <xsl:param name="objInput.evento"/>
    <xsl:param name="objInput.azione"/>
    <xsl:param name="objInput.listOfComponent.component[0].idAppuntamento"/>
    <xsl:template match="/">
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:px="http://px_request.hp.com/">
    <soapenv:Header>
         <JOB_ID><xsl:value-of select="$JOB_ID"/></JOB_ID>
    </soapenv:Header>
    <soapenv:Body>
    <px:Request>
    <requestId><xsl:value-of select="$objInput.requestId"/></requestId>
    <idOdl><xsl:value-of select="$objInput.idOdl"/></idOdl>
    <evento><xsl:value-of select="$objInput.evento"/></evento>
    <azione><xsl:value-of select="$objInput.azione"/></azione>
    <listOfComponent>
    <component type="Appuntamento">
    <pratica><xsl:value-of select="$objInput.listOfComponent.component[0].pratica"/></pratica>
    <idAppuntamento><xsl:value-of select="$objInput.listOfComponent.component[0].idAppuntamento"/></idAppuntamento>
              <property>
    </property>
    <component/>
    </component>
    </listOfComponent>
    </px:Request>
    </soapenv:Body>
    </soapenv:Envelope>
    </xsl:template>
    </xsl:stylesheet>
    I hope it is helpful in order to understand

Maybe you are looking for

  • Multiple shared services installs in the same environment?

    In IOP 11.1.2 and beyond, shared services handles user authentication, to take advantage of Active Directory. Can you install EPM shared services on 2 nodes in the same environment (failover in case one goes down)? Is this possible or recommended? Th

  • Alv output with pushbuttons

    Hi all , how can i get alv out put with two push buttons?

  • Intermittent "Access to account "(Account Name)" is not permitted."?

    A couple times today I got the following message: "Access to account "(Account Name)" is not permitted. The server responded: "HTTP/1.1 403 Forbidden" to operation CalDAVAccountRefreshQueueableOperation." I replaced the real account name with (Accoun

  • ERROR:XRFC-Document has no valid From-header information

    Hi, I am trying to invoke a business connector service using RFC-XML document.      This service invokes one rfc which stores data in the SAP table.     But while executing this service with RFC-XML i got error as "com.wm.pkg.sap.BCException: com.sap

  • Doubt About ASM

    Hi All, I have some doubts about ASM. I have installked ASM on my linux box and created two databases which are totaly using ASM. I created controlfile on local file system only. 1. Suppose I want to remove my one database. I just shut abort the data