Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-22-2005, 01:25 PM   #1
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default Java / web.xml Remoting problem

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).

Quote:

<?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>/gateway</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?

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

Last edited by snapple; 03-22-2005 at 03:19 PM.
snapple is offline   Reply With Quote
Old 03-22-2005, 04:36 PM   #2
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

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

Last edited by snapple; 03-22-2005 at 10:20 PM.
snapple is offline   Reply With Quote
Old 04-04-2005, 07:09 PM   #3
ramfitme
Registered User
 
Join Date: Apr 2005
Posts: 24
Default Checking proper gateway install

Hi:

We are having a similar problem and we are not sure whether the Flash Remoting for Java installation is successful. We went through the README.txt carefully. We have modified the web.xml to include the few lines of servlet and servlet mapping (cut and paste) from README.txt. We have Tomcat and axis installed. We get a white blnak page when we try

http://tomcat_location/axis/gateway

Primary question is what is the URL to the gateway. We are having trouble with a stock quote example (keeps saying loading and nothing beyond that). So we decided to confirm that the gateway is installed fine and find the URL. We just do not know how.

How can we be sure? Is this the gateway URL to use with NetServices.setDefaultGatewayURL in our own application? Please help. Thank you.
ramfitme is offline   Reply With Quote
Old 04-04-2005, 07:57 PM   #4
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

ramfitme,

It depends on your setup. Are you using openamf, if so what came downloaded with it? Did you get openamf.jar and openamf.war or just openamf.jar?

I (much to my annoyance) only found the openamf.jar file in the download. This means that it is not possible (as it states in books on the topic) to deploy the remotingGateway / openamd.war file to Tomcat.

So what's your setup? Then i can help more efficiantly, rather than just blurting info out at you.

Regards, snapple
snapple is offline   Reply With Quote
Old 04-04-2005, 08:47 PM   #5
ramfitme
Registered User
 
Join Date: Apr 2005
Posts: 24
Default Gateway install problem

Thanks for getting back to me. We are using Tomcat 5.5 with JDK 1.5. We have Axis installed under Tomcat and it works just fine. In fact, we were able to get couple of web services working fine under Axis too until we learnt that complex objects have a problem with Flash/Axis communication. So we got Java for Flash remoting. We have carefully followed what is in the README.txt file. There they talk about a quick example of loading a name and fetching it. That works. We are getting white blank page when we try either of the following.

http://tomcat_location/axis/gateway

OR

http://tomcat_location/openamf/gateway

When we turned on the debugger in our stock quote or calculator example (these two examples worked just fine in their non- Flash remoting version), we are seeing messages like

ERROR http-8100-Processor23 org.openamf.DefaultGateway - Error in service, detail=[AMFBody: {serviceName=http://tomcat_location/axis/Calculator.wsdl, serviceMethodName=subtract, response=/1, type=ARRAY, value=[65.0, 39.0]}], ServiceRequest=[AMFBody: {serviceName=http://tomcat_location/axis/Calculator.wsdl, serviceMethodName=subtract, response=/1, type=ARRAY, value=[65.0, 39.0]}]
org.openamf.invoker.ServiceInvocationException: file:/xxx/tomcat5/webapps/axis/WEB-INF/build-webservice.xml:63: Java returned: 1
ramfitme is offline   Reply With Quote
Old 04-04-2005, 08:49 PM   #6
ramfitme
Registered User
 
Join Date: Apr 2005
Posts: 24
Default Gateway install problem - contd.

We do have openamf.jar copied into our application WEB-INF/lib i.e. .../axis/WEB-INF/lib
ramfitme is offline   Reply With Quote
Old 04-04-2005, 09:15 PM   #7
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

If the server is returning a blank page, this means that the remoting gateway is setup correctly. Personally i put openamf.jar in the Tomcat > common > lib directory. And you say you've put the build-webservice.xml and openamf-config.xml files in the applications WEB-INF directory?

To me it does not sound like a remoting problem. Your setup appears to be correct and working.

My best advice would be to get a simple 'helloWorld' example up and running! Make sure you have your web.xml file setup correctly, that us, make sure you include this at the top of your web.xml including/on top of your existing content of the applications web.xml

Code:
<servlet>
		<servlet-name>DefaultGateway</servlet-name>
		<display-name>DefaultGateway</display-name>
		<description>DefaultGateway</description>
		<servlet-class>org.openamf.DefaultGateway</servlet-class>
		<init-param>
			<param-name>OPENAMF_CONFIG</param-name>
			<param-value>/WEB-INF/openamf-config.xml</param-value>
			<description>Location of the OpenAMF config file.</description>
		</init-param>
	</servlet>
Make sure that your url is returning blank page. Make sure that everything is on the correct port (something i smoetimes forget). I know it sounds basic, but i really would get a very simple Flash application up and running that can echo back a sentence or a word.

Out of interest, do you have openamf running as a web service on Tomcat, or do you put the relavent files in each inidividual webapp?

I hope this is of some help.

Regards, snapple
snapple is offline   Reply With Quote
Old 04-04-2005, 09:22 PM   #8
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

What remoting components are you using? Version 1 or 2?
snapple is offline   Reply With Quote
Old 04-04-2005, 11:10 PM   #9
ramfitme
Registered User
 
Join Date: Apr 2005
Posts: 24
Default

To clarify:

build-webservice.xml and openamf-config.xml files are in their original directory under openamf application location under Tomcat. They are not under Axis.

As per your advice I did the following.
First, I changed the servlet section and servlet mapping section to the top of their individual sections in web.xml of my Axis application. It was the last.

Second, I wrote a simple hello world echo application from Flash (where I use things like Netservices.as and Netdebug.as for debugging).

I confirmed again that I get a white page when I run

http://tomcat_location/axis/gateway

When I run the HelloWorld application I still get the following error (half of it pasted here):

ERROR http-8100-Processor25 org.openamf.DefaultGateway - Error in service
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(DataInpu tStream.java:310)
at org.openamf.io.AMFDeserializer.readHeaders(AMFDese rializer.java:98)
at org.openamf.io.AMFDeserializer.<init>(AMFDeseriali zer.java:80)
at org.openamf.DefaultGateway.deserializeAMFMessage(D efaultGateway.java:154)
at org.openamf.DefaultGateway.service(DefaultGateway. java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
ERROR http-8100-Processor24 org.openamf.DefaultGateway - Error in service, detail=[AMFBody: {serviceName=http://tomcat_location/axis/HelloWorldService.wsdl, serviceMethodName=HelloWorld, response=/1, type=ARRAY, value=[Happy Face]}], ServiceRequest=[AMFBody: {serviceName=http://tomcat_location/axis/HelloWorldService.wsdl, serviceMethodName=HelloWorld, response=/1, type=ARRAY, value=[Happy Face]}]
org.openamf.invoker.ServiceInvocationException: file:/xxx/tomcat5/webapps/axis/WEB-INF/build-webservice.xml:63: Java returned: 1
at org.openamf.invoker.WebServiceInvoker.invokeServic e(WebServiceInvoker.java:85)
at org.openamf.DefaultGateway.invokeBody(DefaultGatew ay.java:210)
at org.openamf.DefaultGateway.processMessage(DefaultG ateway.java:190)
ramfitme is offline   Reply With Quote
Old 04-05-2005, 09:12 AM   #10
snapple
member
 
snapple's Avatar
 
Join Date: Feb 2002
Location: London
Posts: 2,442
Default

In that case your answer to my original question of:

Quote:
Out of interest, do you have openamf running as a web service on Tomcat
...would be yes. So as i understand it, you just have openamf as servlet under wbeapps and you can see it (start and stop) the service on the Tomcat manager, right?

What you need to do (i think i mentioned this in my previous post) is move those 2 xml files build-webservice.xml and openamf-config.xml into your webapp's WEB-INF file (so it sits next to your web.xml file). You should also copy ALL of the .jar files from openamf > lib into Tomcat > common > lib.

The way i see it, is that openamf is meant to come with a .war file (with all the .jar files wrapped up in it). And all help says things like "deploy open.war on the server", but i (after much trial and error) realised that basically, you do not need to run openamf as a servlet on Tomcat (like you have set up, if i am correct).

1) make sure your servlet mapping in your web.xml file is correct for your setup.

2) make sure you have all of the .jar files copied into Tomcat > common > lib (because there is no .war file available).

3) Don't bother having openamf running as a servlet on Tomcat.

Remember you web.xml file should look something like this:

Code:
<?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>DefaultGateway</servlet-name>
		<display-name>DefaultGateway</display-name>
		<description>DefaultGateway</description>
		<servlet-class>org.openamf.DefaultGateway</servlet-class>
		<init-param>
			<param-name>OPENAMF_CONFIG</param-name>
			<param-value>/WEB-INF/openamf-config.xml</param-value>
			<description>Location of the OpenAMF config file.</description>
		</init-param>
	</servlet>

	<servlet>
		<servlet-name>foo</servlet-name> <!-- mapping name below -->
		<servlet-class>FlashLogin</servlet-class> <!-- name of class -->
	</servlet>

	<servlet-mapping>
		<servlet-name>DefaultGateway</servlet-name>
		<url-pattern>/gateway</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>foo</servlet-name> <!-- servlet name looked for when URL below is searched for -->
		<url-pattern>/FlashLogin</url-pattern> <!-- the url that can be typed in the browser -->
	</servlet-mapping>

</web-app>
...obviously the servlet mapping will be setup specific to your application names.

Regards, snapple
snapple is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:04 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.