Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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!

share|improve this question

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
Thanks a lot, that sounds like what we need! :) – Davor Jun 12 at 16:04
@Davor You are welcome, happy to help – matheszabi Jun 12 at 17:26

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.

share|improve this answer
My host only supports PHP and it's a shared server so I can't just install a J2EE server there... Not knowing about Java much maybe this is a silly question but can't I just use a Java host like cloud.google.com/products and set this in the define()? – Davor Jun 12 at 13:25
@Davor "most host only supports PHP" - if you search for PHP free hosting. For me most host has 2GB to 32 GB memory only for my J2EE app :) Anyway need at least 128 MB for java + OS requirements. Google app engine is a different from a PHP hosting and has his own limitations. If you want to stick with free solutions: take a free PHP hosting, do HTTP POST or GET to AppEngine Server, where you have to write your AppEngine App and running on his environment. Take care of AppEngine Limitations! – matheszabi Jun 12 at 14:25
our host is not free but we have neither the skills nor the money to go for our own dedicated server where we could setup all we want. If we use jvmhost.com for example, can we get the J2EE server there? I still don't understand if that is the right way or if the J2EE server is something different... – Davor Jun 12 at 14:36
@Davor "we have neither the skills nor the money to go for our own dedicated server where we could setup all we want." => you need help from somebody else. If for an answer and 1 comments any of those isn't appreciated by a free upvote, than I am sure I am not the right person to work for you / your company at my hourly rates :) Try to explain why need Java, I am not really sure when you really need it. - only a few case are, where is justifyed the PHP + Java. I would suggest to rethink / redesign the app architecture based on knowledge or get sponsor to have higher budget. – matheszabi Jun 12 at 14:51
We need it because there are very little other options to parse PDF files with PHP and this is what several people have recommended we use. So we only need this for one small (but crucial) part of our application. I appreciate your effort and maybe I wasn't clear enough but I still don't understand where we can get a J2EE server that will work with the bridge: will jvmhost.com or equivalent be what we need? And in this case would we just use define("JAVA_HOSTS", "http//www.myjavaurl.com:8080"); pointing to the URL linked to that java server? – Davor Jun 12 at 15:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.