سؤال

I have a PHP website www.mysite.com and I want to use the PHP/Java bridge. I've installed tomcat on my computer and it works on localhost. But when I try to use it on my PHP server, this is the error I get:

Fatal error: Uncaught Could not connect to the JEE server 127.0.0.1:8080. Please start it. Or define('JAVA_HOSTS',9267); define('JAVA_SERVLET',false); before including 'Java.inc' and try again.

Now, I am not too surprised: my computer is not supposed to serve as a JEE server for the live application. But being very unfamiliar with Java, I am not sure what steps to take to fix this error: how can I get a JEE server? Is it just getting a java host like I would get a PHP host? And which parts of the bridge need to be on the PHP server and which on the JEE server?

This appears to be what I need to define where the JEE server is - but I am not sure what the terms really mean in the Java world.

define("JAVA_HOSTS", "127.0.0.1:8080");
define("JAVA_SERVLET", "/JavaBridge/servlet.phpjavabridge");

Thanks!

هل كانت مفيدة؟

المحلول

based on what you need: forget the PHP java bridge for now.

  1. Do a HTTP POST to Java server from PHP, you can find many examples. Unfortunately you will need to send the PDF ( in Body) over the network, which can be slow.
  2. Write an AppEngine app, which takes the POST and gets the PDF from body ( pdf file transfered over HTTP to Java hosting) -here you can find many examples.
  3. Parse the PDF file, convert to text. Here you will find many examples on API documentation of your PDF manipulation library
  4. at response parameter send back the text in Java side
  5. at PHP get the Text, do what you want / HANDLE THE LOST CONNECTION TO JAVA SERVER AND TO SLOW RESPONSE ON PHP SIDE!!!

As I remember the AppEngine can schedule a POST to your PHP, in case of taking to long the parsing. I did with a cron job? -can't remember, but I did a connection to outside, however AppEngine hosting is different from PHP, isn't just an FTP upload file, but there are tutorials how to do it from Eclipse.

نصائح أخرى

On that lib it is installed a Java EE server to the same machine as the PHP, but in diff port. Java server default port it is 8080. I think the PHP just makes a TCP/IP communication from port 80 to 8080. On the given example the same machine is used for both servers, this architecture should support installations on diff machines, but need to make proper configurations and of course it will be a lot slower the bridge, but it wil work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top