0

I wish to share session data between some apps that reside on different subdomains (same server). In the past I would make sure each application had the same name in their respective application.cfc. That's been working fine for a while -- people log in at one app; session is shared with the others.

Now we wish to convert one of these apps to ColdBox. So I set up ColdBox 4 running on ACF 2016 on my dev machine. Changing the default Coldbox application name from

this.name = hash( getCurrentTemplatePath() ); 

to

this.name = 'mysite;'

works fine on the development machine, no issues. But just as soon as I upload the same code to production (also ACF 2016), I get the following error:

Element CBBOOTSTRAP is undefined in a Java object of type class [Ljava.lang.String;. 

The error occurred in application.cfc: line 50

48 :    public boolean function onRequestStart( string targetPage ){
49 :        // Process ColdBox Request
50 :        application.cbBootstrap.onRequestStart( arguments.targetPage );
51 : 
52 :        return true;

Just as soon as I change the application name back to

this.name = hash( getCurrentTemplatePath() ); 

the app runs fine with no error (but session is not shared). I think the message about line 50 may be a red herring. I've tried all sorts of modifications there, but nothing changes the original error message short of changing the application name back to what it was.

I've unchecked component caching in the CF admin and restarted (several times) to no avail. I do not know enough about ColdBox to hazard a guess at what might be going on, but I am totally stumped. I do not know why it would work on ACF 2016 on one machine, but not on another. If anybody has any clues, I would really appreciate it! Thanks very much!

daltec
  • 447
  • 1
  • 5
  • 15
  • 1
    Have you tried changing `this.name = 'mysite;'` to `this.name = 'mysite';` – James A Mohler May 08 '18 at 01:48
  • 2
    I am more surprised that this worked before than that it isn't working now. If I had to do this I would either use the server scope (still not great) or a cache accessible to both applications (i.e Redis). The error tells you that Coldbox is not bootstrapped in the Application scope where it's looking; this happens on ApplicationStart. – Aquitaine May 08 '18 at 12:48
  • Hi James, sorry, I had made a typo in my post. It is indeed 'mysite'; in application.cfc. Good catch though! Thanks! – daltec May 08 '18 at 17:15

1 Answers1

0

Element CBBOOTSTRAP is undefined.

The reason you're not seeing this problem in your local dev is that you're always starting your CB app first, therefore defining CBBOOTSTRAP in the application scope before you start the non-CB app. In your other environment, the non-CB app is starting first and that value is therefore not yet defined.

Stop That, Do This

I went through this same problem years ago trying to get a CB and non-CB app to play nice together. IIRC, we had to create an include of shared application variables between the two and include the CFM into both apps so that we only had to edit the one file when updating any of that set of variables.

Trying to share session might work once you take that approach. If not, we also had eventually created an SSO login between our CB and non-CB apps so we could log in between the two.

Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44
  • Thank you, Adrian. I have been reading about having the main ColdBox directory outside of the webroot. Since these apps are all on different subdomains (app1.domain.com, app2.domain.com and so on), if I move the ColdBox directory to C:\, define a "master" app name there, remove the app names from all the application.cfcs for the apps, and then extend the master to all of them, so that they inherit that one application name, does that approach have merit? I ask because I'd rather not try it on production if it is not likely to work. Thanks in advance! – daltec May 08 '18 at 17:52
  • 1
    What I wrote just now might not have made much sense! Sorry! What I meant was, finding a way to not have the individual applications name themselves in their respective application.cfcs, but rather inherit or otherwise "get" a master application name from some ruling application.cfc or other mechanism. Hope that helps clarify! – daltec May 08 '18 at 18:17
  • One thing I would worry about with this approach is conflicts between application scoped variables of the same name. Like in `appOne`, you have `applicaiton.foo = x` and in `appTwo`, you have `applicaiton.foo = y`. You would have to refactor these apps to refer to a distinct list of application scoped variables. `myNewApp` would now have `application.foo = x` and `applicaiton.bar = y`, where the code that was `appTwo` would be updated to use `application.bar`. – Adrian J. Moreno May 09 '18 at 22:10
  • That is a good point Adrian! I guess I will just have to come up with a totally different approach -- I am not understanding why assigning my own "custom" application name to a ColdBox app should be so difficult! I even tried editing the bootstrap file, to no avail -- no matter what I do, it errors out with the same error and on the same line. It appears that "this.name = hash( getCurrentTemplatePath() );" cannot be changed in any way. Doesn't make much sense! – daltec May 10 '18 at 00:17