Java PHP Bridge

apps

#1

Has anybody successfully gotten the PHP/Java bridge working with PHP CGI yet?

I’ve been trying with no luck myself. I’m taking a couple Java courses at school and would really love to be able to write Java classes in conjunction with my PHP scripts to get my hands wet with the language’s schematics.


#2

Ah ha! I did it!!

I don’t know how stable it is, just yet, but I’ve finally gotten the PHP/Java Bridge compiled into my CGI binary:
http://www.gpcentre.net/info.php

Now … to test it out!


#3

So, uh, Jeff; what’s the policy about running a server process on the DH servers?

As I got everything working, I found out in order to use the PHP/Java bridge, I must run a JavaBridge server. It spawns off 10 java threads (working on trying to shrink that down to 5 or less) but it doesn’t seem to take up much CPU load (after a few test runs of my script, server still at ~1.0 load average).

Am I allowed to run the server process through nohup with the 10 threads? Or less (if I can figure out how to shrink it’s thread count)?

I’ve recently started a Java Class and I want to use the PHP/Java bridge to write some kind of mini-app Catalog system for my near 300 DVD collection, to get my into the flow of Java. I’d rather just jump to JSP, but don’t have anywhere near the funds required to purchase your dedicated server plans. :frowning:

PS: Did you know you’re using a very (three years) old Java on your servers? 1.4.0_01!


#4

For development/learning stuff like you’re doing, why not install and run it at home? You can run whatever you want there, plus it’ll be a lot easier to work with when you don’t have to upload your files just to test things.


If you want useful replies, ask smart questions.


#5

Cause I want to create something that will be used, this includes public access. My ISP isn’t too thrilled with me making a server, so I keep my local webserver a development only server, accessable only by select users/ips.


#6

We don’t technically allow any persistent processes of any kind and we definitely don’t provide any support or guarantees about their performance. That said, we tend to take a mostly laissez-faire stance about it. If it doesn’t cause a problem we’ll leave it alone. Note that you are sharing the server with a few hundred other people so even a small amount of continuous server load could present a problem.

I personally wouldn’t recommend setting up a persistent process that your website requires to run because it may be killed or shut down at any time without notice and it obviously won’t start up again if the server is restarted.

Regarding our Java version, it hasn’t been updated in awhile as you noticed. What version is the one people are using now? I looked at Sun.com and it wasn’t totally apparent which one was appropriate. We can try to upgrade the version we have.

  • Dallas
  • DreamHost Head Honcho/Founder

#7

Current version of 1.4 is 1.4.2_08, but most have been migrating to Java 1.5.0_02 (aka Java5), including my place of work–a government facility with high demand on security. My class, at UO. Phoenix, currently uses Java5 as their primary language.

As for keeping things updated. I find that hard to believe. You’re still on Apache 1.3.31! :stuck_out_tongue:
(while I’ll add it was released in May '04, it’s still not 2.x! :()

Persistent processes are easily checkable through web interfaces. Especially this one which PHP does the check for me: http://www.gpcentre.net/info.php (bottom line of the ‘java’ block). I’ve been looking at the ability to add Java by dynamically starting a process per request, but had little luck. Until recently, the Bridge failed to compile correctly until I installed Java5 into my home directory.

Right now, I would prefer to start up the process on each request, but I just hadn’t had much success with that at this time. And I’ve just found out the 10 process apperently is Java doing it’s own thing, unreleated to the bridge server. /ponders…


#8

Apache 2 and Apache 1 are still both being developed as not all of the modules in use are available for Apache 2 yet. Apache 1 is not obsolete, by any means. We do have Apache 2 running in a few places now. I checked on the status of things Apache 2 and it looks like the last non-Apache 2 module in our way is no longer a factor so the upgrade is tentatively slated for later this year. We have some more important major upgrades to work on first.

I’ll put the java upgrade on our todo list, but it may be a little while. Java is not used by that much of our customer-base.

  • Dallas
  • DreamHost Head Honcho/Founder

#9

This is true, but I think that’s purely due to the fact that JSP and J2EE isn’t supported on your traditional webhosting packages.

If you’d had them options, I think you’ll see a big difference in use of Java.

Remember, Java (on the web) is mainly used for Applets, which is a client side application, and your average Java Application requires a GUI (not available on your servers unless you support X forwarding; which I would assume not).

Since there are no Java server side applications supported, there is no real reason to use Java on the server, except for minor backend processing. And even then, Perl tends to provide a better means for that.

And thanks. :slight_smile:

I’m not too worried about it at this time. It’s using maybe 30 megs? on my site. And given I have like 11 gigs, I don’t expect to run out of room anytime soon. lol


#10

We used to support jserv, but all the current JSP and J2EE implementations we’ve seen don’t work for shared hosting servers because they don’t provide any mechanism to isolate each user from each other. We’d have to run a separate copy of the back-end server for each user and that would be too resource intensive.

If you know of anything that may do what we need, let us know and we’ll look into it. We don’t get very many requests for it at all.

I agree that we’d probably see some more people using java if we supported it, but it’s a catch-22 because we can’t dedicate the people-time to setting it up and supporting it unless we know for sure we’ll get enough people using it. We have to choose the ways we use our resources carefully.

  • Dallas
  • DreamHost Head Honcho/Founder

#11

I can understand that. The only reason I didn’t make the request was due to the FAQ simply stated it’s not supported.

I don’t know much about the backend processing for JSP/J2EE as my choice of using PHP/Java was purely based on the fact you didn’t support JSP, so thus no point in learning it on a production system.

However, if I do come acroess something, I’d be sure to let you know.
(Not likely since the only real production JSP server I know is WebLogic and Tombcat. Weblogic’s too big and requires what you’ve stated and I’m sure you’ve already looked into Tombcat)


#12

I don’t do any of Java development on my DH-hosted site only because a current JDK and servlet engine aren’t installed on my server (dali). While I certainly don’t mind having had to use Python to develop cgi scripts for some projects I’ve released on SourceForge, I make a living writing server-side Java code and have a lot more experience with Java. I’m toying with an idea for a cool new open source project that I would like to run on my DH server, but I want to develop it in Java.

The main Tomcat configuration file, server.xml, allows you to specify virtual servers in a way that is similar to how Apache httpd does it. Tomcat also comes with an HTML management console that allows you to deploy web applications. I’ve never had to set Tomcat up to work with virtual servers, so I don’t know how hard it would be to configure Tomcat so that different users wouldn’t accidentally stomp on each other.

Another challenge is that hot deployment of web applications on Tomcat seems to have memory leak problems (i.e., objects not being properly marked for garbage collection) after a few tens of hot deploys. This is typically only a problem if you use the client vm. On a server, you should use the -server jvm argument.

At work, we use clusters of servers and we wrote our own load balancer, so we recycle Tomcat on each server, one after another, during a web app deployment. This may be overkill, but it allows us to do rolling upgrades with no downtime for any of our clients.

Tomcat 5 comes with a load balancer. I haven’t compared it to the one we wrote, but it may have similar capabilities.

There are a lot of companies out there that provide servlet hosting. Just search on “servlet hosting” to find a list of them. The main two I have been looking at are:
http://www.jsp-servlet.net/
http://www.javaservlethosting.com/

though I would obviously prefer to keep everything here.

Robert
http://www.wombatnation.com/


#13

This is excellent information. Thank you!
We have looked at tomcat before, but not recently. It sounds like it’s worth another look.

  • Dallas
  • DreamHost Head Honcho/Founder

#14

Would it really be beto resource intensive with a separate instance of Java for each user?
I think the best solution would be to implement FastCGI in Java. There is a single-thread implementation within the FastCGI SDK but we would need a multithreaded version.

Also Mono xsp already have an FastCGI implementation that could be used to run CIL-based web applications.

High performance JVM:

Java accellerator:

Also if there is no existing solution for this why not use kickstarter to fund a project and fun it on odesk or similar site. I can not start a kickstarter project because I am not american, however DreamHost can… And I would be happy to participate in such a project.


#15

Wow, the post you’re replying to is super old! I’ll step in here…

At this point, our recommendation is that our customers upgrade to a VPS or Dedicated Server to run Java applications. While it’s not out of the realm of possibility that we might support Java server applications on shared hosting someday, the reality is that most Java applications require more server resources (or special configuration) than it’d be possible for us to offer on shared hosting anyway.