Re: Setup for shared enviroment

78 views
Skip to first unread message

Tom Chiverton

unread,
Aug 28, 2009, 7:16:42 AM8/28/09
to Railo
I came across this thread (http://groups.google.com/group/railo/msg/
ec5799adf4fad1fe) because it looks like Railo still doesn't set up
it's BlazeDS intergration so it works out of the box with multiple
webs.

With multiple <server> blocks in the main web.xml under Tomcat, the
first virtual host that POST's to /flex2gateway/ creates a
MessageBrokerServlet, and the 2nd virtual host that tries to gets an
error:
28-Aug-2009 12:06:12 org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet RailoMessageBrokerServlet as unavailable
28-Aug-2009 12:06:12 org.apache.catalina.core.StandardWrapperValve
invoke
SEVERE: Allocate exception for servlet RailoMessageBrokerServlet
javax.servlet.UnavailableException: MessageBroker already defined from
MessageBrokerServlet with init parameter messageBrokerId =
'__default__'
at flex.messaging.MessageBrokerServlet.init
(MessageBrokerServlet.java:163)

Should I open a bug, or is there some extra step I need (other than
those in Sean's continuously excellent 'multi web' blog post) ?

Todd Rafferty

unread,
Aug 28, 2009, 7:48:12 AM8/28/09
to ra...@googlegroups.com
I suggest opening a ticket.  Paul Kukiel seems to be having a similar issue setting up in IIS.

~Todd Rafferty * Railo Community Manager -- Volunteer * http://getRailo.org/

Roland Ringgenberg

unread,
Aug 28, 2009, 8:39:45 AM8/28/09
to Railo
Yep, I'm afraid the ticket makes sense. Michael and I already talked
about it but didn't found a quick solution yet. In any case no other
than to startup several messagebroker servlets with separate id's like
whostheJBoss already explained.

Michael would like to see that the messagebroker servlet is startet up
only once on the container level and would then be able to load the
config files based on it's context, but apparently this does not work
out of the box. The first web context that receives a call to the
servlet works, the other contexts then fail. I don't like the
separated 'id' either, but I had the problem that if I didn't do it
this way, on JBoss I had initialization errors when starting the
container.

thx for the reminder...
;)

On Aug 28, 1:48 pm, Todd Rafferty <t...@getrailo.org> wrote:
> I suggest opening a ticket.  Paul Kukiel seems to be having a similar issue
> setting up in IIS.
>
> ~Todd Rafferty * Railo Community Manager -- Volunteer *http://getRailo.org/
>
> On Fri, Aug 28, 2009 at 7:16 AM, Tom Chiverton <tom.chiver...@gmail.com>wrote:
>
>
>
> > I came across this thread (http://groups.google.com/group/railo/msg/
> > ec5799adf4fad1fe<http://groups.google.com/group/railo/msg/%0Aec5799adf4fad1fe>)

Todd Rafferty

unread,
Aug 28, 2009, 8:41:54 AM8/28/09
to ra...@googlegroups.com
And mark it high priority so we can keep Roland busy... ;)

~Todd Rafferty * Railo Community Manager -- Volunteer * http://getRailo.org/

Tom Chiverton

unread,
Aug 28, 2009, 8:56:52 AM8/28/09
to ra...@googlegroups.com
2009/8/28 Todd Rafferty <to...@getrailo.org>:

> I suggest opening a ticket.  Paul Kukiel seems to be having a similar issue
> setting up in IIS.

https://jira.jboss.org/jira/browse/RAILO-400

If I'm using a 'global' install of Railo into Tomcat (i.e. added the
Railo jar's to catalina.properties' class path, servlets to the global
web.xml etc. is there a way to then move the MB servlets to each
webroot's WEB-INF/ folder ? If you know what I mean. I've only got
half a head around this J2EE stuff :-)

--
Tom

Tom Chiverton

unread,
Aug 28, 2009, 9:22:02 AM8/28/09
to ra...@googlegroups.com
2009/8/28 Todd Rafferty <to...@getrailo.org>:

> And mark it high priority so we can keep Roland busy... ;)

More seriously, it probably precludes any serious use of Railo with
Flex over AMF3, if I can only have one Railo-using virtual host using
Flex Remoting :-(

Yeah, there are other options (i.e. WSDL web services) but their not
as performant.

--
Tom

Roland Ringgenberg

unread,
Aug 28, 2009, 10:21:43 AM8/28/09
to Railo
Hi Tom,

Yes, you should be able to just move your MB Servlet code (and the
mapping) into the web.xml files of your contexts. Don't forget to take
it out of the global xml then.

I tested this on JBoss a couple of month ago, but I had to add these
'undocumented' id's, so that the container was able to startup several
BlazeDS instances. I'm not sure if this way is the right way but it
seems to work. Then whostheJBoss started with his amazing run through
the setup process (see all the post from june/july), I guess he knows
the most of it by now!

Do you use Apache for your virtual host? I will try to setup Apache/
ModProxy/Railo global/Tomcat/Two context roots over the weekend and
play with it, if it works I will make a post on the Railo blog,
promised. Please don't go back to WSDL, I could never get over it to
have you forced doing so. ;)

I have to admit though that I can't find information on the BlazeDS
forums/community about the problem, actually there's not much to find
about BlazeDS at all. I know that you are very active in several Adobe
communities, do you know someone that leads the BlazeDS community?
Would be nice to establish some communication.

@Todd, I guess my summer holidays are over then... ;)

Success!,
Roland

On Aug 28, 3:22 pm, Tom Chiverton <tom.chiver...@gmail.com> wrote:
> 2009/8/28 Todd Rafferty <t...@getrailo.org>:

Tom Chiverton

unread,
Sep 1, 2009, 5:11:05 AM9/1/09
to ra...@googlegroups.com
2009/8/28 Roland Ringgenberg <rin...@gmail.com>:

>
> Hi Tom,
>
> Yes, you should be able to just move your MB Servlet code (and the
> mapping) into the web.xml files of your contexts. Don't forget to take
> it out of the global xml then.

Okaaaay......
I don't seem to have a per-context web.xml.... can I just go ahead and
create one inside ......./WEB-INF/ ?
# ls -lah ...../railo-test/webroot/WEB-INF
total 4.5K
drwxr-xr-x 4 chivertont users 128 2009-08-27 15:27 .
drwxr-xr-x 5 chivertont users 216 2009-08-28 11:57 ..
drwxr-xr-x 2 chivertont users 200 2009-08-27 15:27 flex
-rw-r--r-- 1 chivertont users 96 2009-08-27 15:27 .htaccess
drwxr-xr-x 18 chivertont users 608 2009-08-28 13:05 railo

In which case, can I just take the server-wide one and strip
everything else out, or is there some template I should follow ?

> Do you use Apache for your virtual host? I will try to setup Apache/

Yes, as per Sean's 'multi web' blog posting,
http://corfield.org/blog/index.cfm/do/blog.entry/entry/Railo_on_Tomcat__multiweb

> play with it, if it works I will make a post on the Railo blog,
> promised. Please don't go back to WSDL, I could never get over it to
> have you forced doing so. ;)

Cheers Roland. This is just about the last road block :-)

> I have to admit though that I can't find information on the BlazeDS
> forums/community about the problem, actually there's not much to find
> about BlazeDS at all. I know that you are very active in several Adobe
> communities, do you know someone that leads the BlazeDS community?

I am afraid not. I guess Adobe have some 'magic' that makes BlazeDS
work better with their ColdFusion engine.

> Would be nice to establish some communication.

I think they'd probably respond well to that- have you tried posting
to their web-based forum ?

--
Tom

whostheJBoss

unread,
Sep 1, 2009, 5:32:21 AM9/1/09
to Railo
'allo!

So, I have the two-context Tomcat, Apache mod_proxy (and mod_rewrite)
setup working just fine. Just created the definition for the MB in
web.xml inside WEB-INF for both hosts. I also have the Tuckey
URLRewrite filter in there too (for pretty URLs, foo.com/user/1 or
foo.com/home, no index.cfm).

My issue has been that if I have a global BlazeDS installation, then
the channels, adapters, destinations, etc are shared. Often I want my
apps to have their own set of configurations. On JBoss the separate
instances are great for me. I also wouldn't want one instance crashing
to bring down the others for other sites. With that said, a shared
instance that had separate contexts of some sort would be interesting,
although I'm not sure what kind of Frakenstein BlazeDS creature you'd
have to create to accomplish this.

What I can't get to work in BlazeDS right now on Railo (which works on
CF8 with BlazeDS using the same definitions, etc) is simple messaging.
I'm not talking about gateways, messages that have to talk to Railo,
but just messages back and forth to some defined destination using
producer / subscribe. A simple Flex chat client I have works on CF8
with BlazeDS just sends to Blaze, Blaze drops the message off to the
subscriber. No problem, no CF, no gateway. Railo doesn't work. I
doesn't seem to want to sent out a producer message or subscribe. I'll
be doing a little more testing soon on this to find out what the exact
behavior is for diagnosis.

On Sep 1, 2:11 am, Tom Chiverton <tom.chiver...@gmail.com> wrote:
> 2009/8/28 Roland Ringgenberg <rin...@gmail.com>:
>
>
>
> > Hi Tom,
>
> > Yes, you should be able to just move your MB Servlet code (and the
> > mapping) into the web.xml files of your contexts. Don't forget to take
> > it out of the global xml then.
>
> Okaaaay......
> I don't seem to have a per-context web.xml.... can I just go ahead and
> create one inside ......./WEB-INF/ ?
> # ls -lah ...../railo-test/webroot/WEB-INF
> total 4.5K
> drwxr-xr-x  4 chivertont users 128 2009-08-27 15:27 .
> drwxr-xr-x  5 chivertont users 216 2009-08-28 11:57 ..
> drwxr-xr-x  2 chivertont users 200 2009-08-27 15:27 flex
> -rw-r--r--  1 chivertont users  96 2009-08-27 15:27 .htaccess
> drwxr-xr-x 18 chivertont users 608 2009-08-28 13:05 railo
>
> In which case, can I just take the server-wide one and strip
> everything else out, or is there some template I should follow ?
>
> > Do you use Apache for your virtual host? I will try to setup Apache/
>
> Yes, as per Sean's 'multi web' blog posting,http://corfield.org/blog/index.cfm/do/blog.entry/entry/Railo_on_Tomca...

Tom Chiverton

unread,
Sep 1, 2009, 5:47:17 AM9/1/09
to ra...@googlegroups.com
2009/9/1 whostheJBoss <dotf...@changethings.org>:

> So, I have the two-context Tomcat, Apache mod_proxy (and mod_rewrite)
> setup working just fine. Just created the definition for the MB in
> web.xml inside WEB-INF for both hosts. I also have the Tuckey
> URLRewrite filter in there too (for pretty URLs, foo.com/user/1 or
> foo.com/home, no index.cfm).

Could you post the per-host web.xml files ?

--
Tom

Gert Franz

unread,
Sep 1, 2009, 5:50:11 AM9/1/09
to ra...@googlegroups.com
You shouldn't work on your birthday!

Happy birthday Tom!

Gert

-----Ursprüngliche Nachricht-----
Von: ra...@googlegroups.com [mailto:ra...@googlegroups.com] Im Auftrag von
Tom Chiverton
Gesendet: Dienstag, 1. September 2009 11:47
An: ra...@googlegroups.com
Betreff: [railo] Re: Setup for shared enviroment

Tom Chiverton

unread,
Sep 1, 2009, 6:07:31 AM9/1/09
to ra...@googlegroups.com
2009/9/1 Gert Franz <ge...@getrailo.com>:

> You shouldn't work on your birthday!
> Happy birthday Tom!

Aww, cheers Gert :-)

--
Tom

Roland Ringgenberg

unread,
Sep 2, 2009, 4:47:44 AM9/2/09
to Railo
Hi Tom and whostheJBoss,

It looks like I have a late birthday gift for you Tom!
:-)

This will take longer, even for my posts ;) ok, it looks like I found
a way to instantiate the MessageBroker Servlet only once while the
configurations are properly loaded for any 'instance'. Actually I
don't know yet how BlazeDS manages them internally (something around
server classes) and I also did not test it with clusters, but it seems
to work reliable. But let me first answer Toms questions.

About the web.xml files, yes you can just add a clean web.xml and the
settings you want for your local web will override what is setup in
the tomcat conf web.xml. This means that you can initialize an
instance of BlazeDS or LCDS in yourWeb.war and even copy the local
jars without even bothering what is loaded from tomcat directly. Ok,
also Java has is quirks, so if your unlucky it could be that you have
classloader troubles with jar in different versions, so the more you
mix the more you need to be careful here. I hope this makes sense. So
for example you could put the following code into the web.xml of your
specific web:

<display-name>Railo Web4</display-name>

<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-
class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-
value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/flex2gateway/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/flashservices/gateway/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.cfm</welcome-file>
</welcome-file-list>

Now the problem we had with BlazeDS was, that if you put the same code
into a second web, tomcat will throw an error when started that he
already started a message broker with the id of __default__. The
solution to this is to add also an Id for you second message broker
servlet:


<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-
class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-
value>
</init-param>
<init-param>
<param-name>messageBrokerId</param-name>
<param-value>web5MessageBroker</param-value>
</init-param>
</servlet>

This approach works, but you have now to add the servlet and mappings
to any web.xml of all of your webs. That's why Michael suggested to
add the message broker only to the tomcat/conf/web.xml. But
unfortunately as you discovered, this way, on the second web, the
servlet is not available. Interesting enough is, that it's there again
on the third, but this is not the solution we are looking for.

To investigate further, I have setup a tomcat based on the Sean's
post, just using the host settings on tomcat to point to my wwwroot
folders. Thx Sean, now I finally know how to put the railo jars into a
separate folder. That rocks! I setup 6 webs, called railoweb1.local to
railoweb6.local and access the MBs over railoweb1.local:8080/
flex2gateway or railoweb1.loca:8080/messagebroker/amf This way I could
perfectly test which MB's work etc.

I took a second lesson learned from Sean's post an called the MB
servlet for the main tomcat/conf/web.xml RailoMessageBrokerServlet and
put following xml into it:

<!-- MessageBroker Servlet -->
<servlet>
<servlet-name>RailoMessageBrokerServlet</servlet-name>
<display-name>RailoMessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-
class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-
value>
</init-param>
</servlet>


On Sep 1, 12:07 pm, Tom Chiverton <tom.chiver...@gmail.com> wrote:
> 2009/9/1 Gert Franz <g...@getrailo.com>:

Roland Ringgenberg

unread,
Sep 2, 2009, 4:56:04 AM9/2/09
to Railo
that was the wrong click, sorry

and the mappings:

<!-- MessageBroker mappings -->
<servlet-mapping>
<servlet-name>RailoMessageBrokerServlet</servlet-name>
<url-pattern>/flex2gateway/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoMessageBrokerServlet</servlet-name>
<url-pattern>/flashservices/gateway/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoMessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>

That means also that I changed the old one to:

<servlet-mapping>
<servlet-name>RailoAMFServlet</servlet-name>
<url-pattern>/openamf/gateway/*</url-pattern>
</servlet-mapping>


I hope you are still with my, as you see, this way it is possible to
run a railo wide RailoMessageBrokerServlet but still use a BlazeDS
instance separately in yourWeb.war/WEB-INF/web.xml. But to avoid the
id errors, you need to add the messageBrokerId inti param. That's
where we where, right?

But I wondered now if it was possible to feed these id to the message
broker in some other way. I will make a third post to explain
this...

Roland Ringgenberg

unread,
Sep 2, 2009, 5:28:42 AM9/2/09
to Railo

BlazeDS comes with a bootstrap service, by extending
AbstractBootstrapService we can override the message broker
initialize, start and stop methods. I used the initialize method to
get the local messageBroker and feed it the id I wanted. You can
download the java class and a jar containing it from
http://rolandringgenberg.com/railo/railo-messaging-bootstrap-fix.zip,
just put the railo-messaging-bootstrap.jar into the tomcat/lib, sorry
to the tomcat/railo directory (if you followed Sean's post ;-).

To setup the bootstrap, go to yourWeb.war/WEB-INF/flex/services-
config.xml and add the bootstrap to the services tag:

<services>
<service-include file-path="remoting-config.xml" />
<service-include file-path="proxy-config.xml" />
<service-include file-path="messaging-config.xml" />
<service id="railoBootstrap"
class="railo.runtime.net.amf.RailoMessageBrokerBootstrapService">
<properties>
<messageBrokerId>web1MessageBroker</messageBrokerId>
</properties>
</service>
</services>

that's it, now your global RailoMessageBrokerServlet gets a proper id
for this configuration.

I tested this by setting up three webs with the global message broker
railoweb1.local:8080, railoweb2.local:8080 and railoweb3.local:8080,
then I put two MB's in the web.xml of railoweb4.local:8080 and
railoweb5.local:8080 and then also put a lcds3 into the web.xml of
railoweb6.local:8080. In all these remoting setups I have the
ColdFusion destination and tried a simple java destination using the
BlazeDS JavaAdapter and it worked as expected.

The railoweb1.local/WEB-INF/flex/remoting-config.xml looks like this:

<adapters>
<adapter-definition id="cf-object"
class="railo.runtime.net.flex.RailoAdapter" default="true"/>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"/>
</adapters>

<default-channels>
<channel ref="my-cfamf"/>
<channel ref="classic-cfamf"/>
</default-channels>

<destination id="ColdFusion">
<properties>
<source>*</source>
</properties>
</destination>

<destination id="web1Destination">
<adapter ref="java-object"/>
<channels>
<channel ref="my-amf"/>
</channels>
<properties>
<source>net.ringgi.tests.facade.JavaBackendWeb1Service</source>
</properties>
</destination>

Though, I found out that our RailoAdapter does not yet work with the
new architecture of lcds3, but that is another question (does this
never stops? ;-)

@whostheJBoss could try this approach in your JBoss environment too?
Do you have any unwanted side effects?

I added this only here because I have not yet discussed this with
Michael, so the naming could change and maybe he wants to put this
bootstrap class into the railo.jar but I guess this should be the
answer to the multi web remoting questions.

@whostheJBoss, I guess the next thing is the bug you found with the
messaging, I guess it's time to take a closer look into this now...

Cheers,
Roland

Tom Chiverton

unread,
Sep 2, 2009, 10:02:41 AM9/2/09
to ra...@googlegroups.com
> To setup the bootstrap, go to yourWeb.war/WEB-INF/flex/services-
> config.xml and add the bootstrap to the services tag:

If I understand right, I only have to change Tomcat's global
conf/web.xml, right ? And then add the boot strap lines to each web's
services-config.xml ? Looks easy...

I don't see that buying much, as I still have to go and add some stuff
to some file.
In fact, it's even less intuitive because although the server is
creating the services-config.xml it's creating it without a needed
setting.
If the boot strap code could be rolled into Railo, then could Railo
correct the services-config.xml (the first time it is created) for us
? That would really rock.

Having said that, this is an improvement, another great example of
listening to your community.

--
Tom

Roland Ringgenberg

unread,
Sep 2, 2009, 12:10:16 PM9/2/09
to Railo
Yep, you got it, these are exactly my thought too.

When I get my next chance to discuss this with Michael I will
definitively bring the generation of the service-config.xml on the
table. There was not much I could doe about generating something in
the web.xml but maybe with these files it could work. We need anyway
some flexiblity here.

Thx, for kind words!
:-)

Success,
Roland

Tom Chiverton

unread,
Sep 3, 2009, 5:47:13 AM9/3/09
to ra...@googlegroups.com
2009/9/2 Roland Ringgenberg <rin...@gmail.com>:

> table. There was not much I could doe about generating something in
> the web.xml but maybe with these files it could work. We need anyway
> some flexiblity here.

I dunno about Resin etc. but the Tomcat install I am using to play
with here doesn't create the per-context WEB-INF/web.xml file at all,
so as an alternative, could Railo generate one that included a
per-context MessageBroker (if the file doesn't exist) ?

--
Tom

Reply all
Reply to author
Forward
0 new messages