PDA

View Full Version : Java / web.xml Remoting problem



snapple
March 22nd, 2005, 09:35 AM
Hello. Thanks in advance for any help or advice.

I am using; Java 1.5, Tomcat 5.5, openamf, fmx 2004 pro.

I bought "Flash Remoting, the definitive guide by Tom Muck". However, most documentation directly relates to the bought version of Flash Remoting and JRun 4. So i am having a little trouble getting things working myself.

I have actually got some remoting to work in Flash, a simple HelloWorld example. However, i only got this working by actually puting and compiling my Java class inside openamf (the following directory structure):

Tomcat
------->Tomcat 5.5
-------------------->webapps
------------------------------>openamf
---------------------------------------->WEB-INF
-------------------------------------------------->classes

This worked. However, from what i understand, this is not how it should acuatlly be achieved. What i should actually have (i think) is, my own completely self-contained webapp, and point it to the remoting gateway.

So what i did was:

1) Copy openamf.jar file into the lib directory of my webapp.
2) add the following XML to my own webapps web.xml file (inside WE-INF).




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>

<servlet>
<servlet-name>foo</servlet-name> <!-- mapping name below -->
<servlet-class>ByeByeWorld</servlet-class> <!-- name of class -->
</servlet>
<servlet-mapping>
<servlet-name>foo</servlet-name> <!-- finds same name above and looks up the class -->
<url-pattern>/ByeByeWorld</url-pattern> <!-- the url that can be typed in the browser -->
</servlet-mapping>
<!-- this is what i added -->

<servlet>
<servlet-name>FlashGatewayServlet</servlet-name>
<servlet-class>../openamf/gateway</servlet-class><!-- HOW DO I GET INTO OEPNAMF FROM HERE? -->
</servlet>
<servlet-mapping>
<servlet-name>FlashGatewayServlet</servlet-name>
<url-pattern>../../openamf/org.openamf.DefaultGateway</url-pattern>
</servlet-mapping>

</web-app>




Area of confusion...

How come i can type http://localhost/openamf/gateway into my browser and it (as it should do) return a blank page (Where is the gateway, i can't see anything directly relating to it inside the openamf servlet?) Secondly, inside the <servlet-class></servlet-class> tag, is this what points to the actual remoting gateway, is this what makes remoting work and hence i should 'point' my webapp to it?

So i suppose my main question is:

What goes inside the <servlet-class></servlet-class> tags that are meant to find the remtoing gateway, inside my webapps web.xml? (assuming i already have the other <servlet-class> tags set-up to point to the actual Java class that i wrote) ?

Massive thanks for any help, really is appreciated.

Regards, snapple :)

snapple
March 22nd, 2005, 12:37 PM
I solved it! Between the two books i bought and the internet there is absolutely ****-all documentation on openamf and Tomcat / Flash Remoting. Turns out i had to a whole load of stuff which was simply not mentioned. However, i think this was actually due to the .war file that comes downloaded with openamf (well actually it doesn't, you have to get the one with the openamfexamples.zip), not containing all of the correct .jar files. As soon as i moved (quite literally copied and pasted) all the .jar files from openamf servlet, into my own WEB-INF directory, it all worked!!!!

Just a word of warning if anyone else is going through the same problem(s). Read the README.txt files (it states you have to include the openamf-config.xml and the build-webservice.xml files in your WEB-INF file..make sure you do (i could not find this stated anywhere else)

Regards, snapple :)

CyanBlue
March 22nd, 2005, 09:58 PM
snapple??? :D

snapple
March 23rd, 2005, 03:40 AM
Hello CyanBlue. Well, i posted over here because the remoting forum over in Actionscript.org (although i did post over there too) is fairly quiet, and i was getting annoyed with the lack of clear documentation for Remoting / Tomcat and Java. Everyone seems to be using amfphp, but i guess thats because it is a lot easier to setup and does not require creating and editing 3 XML files to make your app work...that and there is loads of documentation for amfphp compared to openamf.

Regards, snapple :)

CyanBlue
March 23rd, 2005, 04:23 PM
Hey, man... I wasn't asking you why you posted here... I was just glad to see you... That's all... :)

I totally hear you that there aren't many places where you can ask question on that combination... Heck, I don't even know how that works... ;)

snapple
March 23rd, 2005, 07:25 PM
Well if you ever need a little bit of Java / Tomcat / Flash Remoting advice, i'd be more than happy to try and pass on what i know (which isn't much so far, but it's better than battling away with no or very little documentation), i mean, the truck loads of php advice you've given me, it's the least i could try and do.

Although with all the problems that go with not letting Macromedia rip you off by trying to make you by remoting and JRUN4, such as:

http://radio.weblogs.com/0113514/2002/11/17.html#a12

I don't know how useful it can be.

Regards, snapple :)

CyanBlue
March 23rd, 2005, 08:41 PM
Hehe... I have done Java for about a year or so... and I 'really' hated it... Don't know why, but I just didn't like it at all... I am just surprised that I have actually done that for a year... Well... That's part of the reason why I don't like AS 2.0, I presume... :D

The link looks interesting... If I remember correctly, it is called FlashOrb or something that is parallel to AMFPHP, right??? I think it was somewhat expensive... Or do you use something else???

PHP... Hm... I've learned great deal while I did that, so I owe you for that... ;)

snapple
March 24th, 2005, 04:20 AM
I use Tomcat 5.5 instead of JRun 4 and i use openamf instead of Macromedia's remoting. I dislike the microsoft style closed source from macromedia, i mean, they are the ones who want to push RIA's and change the whole focus of flash, and try and make it more development orientated (more Java orientated i guess), yet they charge a fortune for the tools to do it. Which is pretty pointless. There a couple of advatnages of using JRun 4 (namely the steup doesn't take a day when your first doing it), but Tomcat is a bloody nice server. I think a good combo is Java 1.5, Tomcat 5.5 and fmx 2004. Put all those together and you have one big fustrating day...with a headache too.

I thought it would be a good way to try and revive the remoting forum over at as.org, so far its more lively than it has been for a while.

What kind of Java work did you do CyanBlue?

Regards, snapple :)

CyanBlue
March 25th, 2005, 03:06 PM
OpenAMF... Ah... Yeah... I reckon that name... :)

Me, Java... Not much actually... Did some apps with Swing... Just as I do the same thing in Flash... I guess that's pretty much it... ;)

The way I see it, Remoting won't be very popular subject for the normal users... They do need good reason to go that far, but the argument is somewhat weak for most of the users... That's my 2 cents... :rambo: