Precompiling an entire application

294 views
Skip to first unread message

upfron...@gmail.com

unread,
May 3, 2015, 9:54:54 PM5/3/15
to lu...@googlegroups.com
I'm in a situation where I'm trying to integrate my application with another piece of software.  That software only works with java bytecode, so I'm trying to precompile everything.  

For a bit of background, I used the version 4.5 tomcat installer on windows.  I moved my application to c:\lucee\tomcat\webapps\ROOT\ and it runs quite nicely.  

Next I tried to create a mapping to "/" with "c:\lucee\tomcat\webapps\ROOT\" as the resource and then assigned the archive to mapping.  I then removed the resource mapping and set the primary to "archive", leaving only a path to the .ra file that was created under c:\lucee\tomcat\webapps\ROOT\WEB-INF\lucee\context\archives.  To test if the application is using the archive, I renamed a cfm file that is contained in the archive and tried to access it, but I get a 404.  I tried the same thing with a cfc file and any CreateObject calls to that cfc fails.

Then I tried basically the same thing as above, but instead of mapping to ROOT, I mapped to a subfolder of root that contains the majority of my application.  Using the same tests as before, cfc files are being found, however cfm files still return 404.

I'm starting to be convinced that archive mappings are not working as intended.

After fighting with all that, I would like to take a different approach that, in theory, would afford me more flexibility as the application evolves.  I would simply like to "touch" every file on deployment such that .class files are generated in the cfclasses folder.  

So my question is, what might be the best way to get make all cfm and cfc files in my application precompile into the cfclasses folder?  Is this even possible?  Do I need to write a batch script that will hit all possible URLs in my application?  I'm worried that if I take that approach, the security settings I have in my Application.cfc that prevents all except for a few cfm files to be directly web-accessible will cause problems.  That security makes it so most of my application files must be accessed through the a controller.  The controller will prevent any non-logged-in request from touching those files.  

Any advice would be greatly appreciated.  I've been banging my head against this wall for a week now.  Thanks!

Michael Offner

unread,
May 4, 2015, 2:29:10 AM5/4/15
to lu...@googlegroups.com
"I'm starting to be convinced that archive mappings are not working as intended."
Take the Lucee admin as an example (/lucee/admin.cfm) that is an archive you used to do all this... ;-)
We also have clients that use archives for the complete website, with not a single cfm file on the server!

You are writing about .ra files, but then also from lucee. Have in mind that .ra (Railo archive) are not compatible with Lucee, you need .lar files for Lucee.
The welcome files to not work with archives (depending on the servlet engine used), best test with  the file name (/index.cfm) when you call a file.
Components only work if you have part of the package as entry point in the virtual path of the mapping (for compatibility reasons to ACF)
It is best to do component map for your components anyway.  In the wiki you can find some details about this...

Micha


--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/b11e74b8-e166-4305-9ad6-46f0c7102799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

imad...@gmail.com

unread,
May 4, 2015, 8:33:32 AM5/4/15
to lu...@googlegroups.com, alexfr...@yahoo.com
hmm

Michael Offner

unread,
May 4, 2015, 8:48:46 AM5/4/15
to lucee
hmm what ;-)

Micha

hmm
--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

upfron...@gmail.com

unread,
May 4, 2015, 10:34:45 AM5/4/15
to lu...@googlegroups.com
Thanks, Micha.

If .ra files are incompatible, why does the lucee admin create .ra files when I go to download an archive from a mapping or assign an archive to a mapping.  I did find it odd that I was getting .ra files from this process even though the lucee admin is using a .lar file.

To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

upfron...@gmail.com

unread,
May 4, 2015, 2:56:22 PM5/4/15
to lu...@googlegroups.com
Also, how might I go about precompiling to the cfclasses folder instead of to an archive?  Is that even a supported option?  Or would I have to come up with some sort of hacky solution that calls each cfm and cfc as part of the app initialization?


Michael Offner

unread,
May 4, 2015, 3:38:13 PM5/4/15
to lu...@googlegroups.com
What version do you use, this was a bug in a early version on Lucee 4.5...

Micha

Am Montag, 4. Mai 2015 schrieb :
Thanks, Micha.

If .ra files are incompatible, why does the lucee admin create .ra files when I go to download an archive from a mapping or assign an archive to a mapping.  I did find it odd that I was getting .ra files from this process even though the lucee admin is using a .lar file.


On Monday, May 4, 2015 at 2:29:10 AM UTC-4, Micha wrote:
"I'm starting to be convinced that archive mappings are not working as intended."
Take the Lucee admin as an example (/lucee/admin.cfm) that is an archive you used to do all this... ;-)
We also have clients that use archives for the complete website, with not a single cfm file on the server!

You are writing about .ra files, but then also from lucee. Have in mind that .ra (Railo archive) are not compatible with Lucee, you need .lar files for Lucee.
The welcome files to not work with archives (depending on the servlet engine used), best test with  the file name (/index.cfm) when you call a file.
Components only work if you have part of the package as entry point in the virtual path of the mapping (for compatibility reasons to ACF)
It is best to do component map for your components anyway.  In the wiki you can find some details about this...

Micha



Am Montag, 4. Mai 2015 schrieb :
I'm in a situation where I'm trying to integrate my application with another piece of software.  That software only works with java bytecode, so I'm trying to precompile everything.  

For a bit of background, I used the version 4.5 tomcat installer on windows.  I moved my application to c:\lucee\tomcat\webapps\ROOT\ and it runs quite nicely.  

Next I tried to create a mapping to "/" with "c:\lucee\tomcat\webapps\ROOT\" as the resource and then assigned the archive to mapping.  I then removed the resource mapping and set the primary to "archive", leaving only a path to the .ra file that was created under c:\lucee\tomcat\webapps\ROOT\WEB-INF\lucee\context\archives.  To test if the application is using the archive, I renamed a cfm file that is contained in the archive and tried to access it, but I get a 404.  I tried the same thing with a cfc file and any CreateObject calls to that cfc fails.

Then I tried basically the same thing as above, but instead of mapping to ROOT, I mapped to a subfolder of root that contains the majority of my application.  Using the same tests as before, cfc files are being found, however cfm files still return 404.

I'm starting to be convinced that archive mappings are not working as intended.

After fighting with all that, I would like to take a different approach that, in theory, would afford me more flexibility as the application evolves.  I would simply like to "touch" every file on deployment such that .class files are generated in the cfclasses folder.  

So my question is, what might be the best way to get make all cfm and cfc files in my application precompile into the cfclasses folder?  Is this even possible?  Do I need to write a batch script that will hit all possible URLs in my application?  I'm worried that if I take that approach, the security settings I have in my Application.cfc that prevents all except for a few cfm files to be directly web-accessible will cause problems.  That security makes it so most of my application files must be accessed through the a controller.  The controller will prevent any non-logged-in request from touching those files.  

Any advice would be greatly appreciated.  I've been banging my head against this wall for a week now.  Thanks!

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/b11e74b8-e166-4305-9ad6-46f0c7102799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

upfron...@gmail.com

unread,
May 4, 2015, 4:31:01 PM5/4/15
to lu...@googlegroups.com
I installed this about 1-2 weeks ago from the Apache Tomcat windows installer found on lucee.org.  Here's a direct link to the file I downloaded to install from: http://railo.viviotech.net/downloader.cfm/id/134/file/lucee-4.5.1.000-pl0-windows-installer.exe

So it appears I'm on version 4.5.1.  What version should I be using?
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/b11e74b8-e166-4305-9ad6-46f0c7102799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

upfron...@gmail.com

unread,
May 5, 2015, 9:50:47 AM5/5/15
to lu...@googlegroups.com
I updated to 4.5.1.014 and the admin is now producing .lar files.  However, I am still running into the same issues that I originally explained.  

Is there a resource I can read up on?  

upfron...@gmail.com

unread,
May 7, 2015, 3:01:04 PM5/7/15
to lu...@googlegroups.com
For anyone interested and equally nooby as me....

As an update, I never managed to get archives working as I would expect.  To clarify, I expect once I define a mapping to an archive, then any requests made to templates/components compiled in the archive will be "pulled" from the archive.  Instead, I receive "not found" type errors when I try to access a template/component that resides in the mapped archive but has been removed from its original location.  Perhaps I have wrong expectations.

Anyhow, I found a different solution which would have been fine from the beginning had it not eluded me.  What I have done is create a mapping to "/" from my app's root folder.  I then simply Compile that mapping (either from the Lucee admin or from a cfadmin tag).  What eluded me was where the .class files were being created.  I figured they would go in to the cfclasses folder under WEB-INF of my application.  Instead they are being created in c:\lucee\lib\lucee-server\context\cfclasses\.  Then it just became a matter of copying those class files to the appropriate location under my app's WEB-INF.  Admittedly, I only do this copy because I don't know which .class files are executed at runtime, so as long as I have them in both places, I don't care.  My whole goal was to simply have the app precompiled so an external application can scan the application for all java binaries.

Michael Offner

unread,
May 8, 2015, 2:45:02 AM5/8/15
to lucee
Like I said we use that functionality in many places including your Lucee admin. If you give me your archive (off list) I can even test it if you like...

You can btw also take the code from the cfclasses directory and replace your source code with the classes files, so for example you have a app with one file named test.cfm, take the test class from the cfclasses directory, rename it to test.cfm and replace it with the source file. Lucee will recognize that the .cfm file contains a class binary and uses that directly.
There was even an extension for Railo to do this, this was a 3th party extension and I have no clue it is migrated to Lucee or not, but I can find out if you are interested.

Micha


To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/b11e74b8-e166-4305-9ad6-46f0c7102799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/f4f73f7f-e06e-439c-b13e-56b1a6eeab0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

upfron...@gmail.com

unread,
May 8, 2015, 1:35:01 PM5/8/15
to lu...@googlegroups.com
Thanks for offering to test out my archive, but I don't think that's necessary.  Using the archives was only a work-around to what I was originally trying to do (which is to precompile the application).  I'm not even really concerned about a sourceless distribution.  This is probably an uncommon edge case, but we intend to integrate with external software that will turn our application from single to multi-tenant.  Their product will scan our application for java binaries and map injection points which is why I needed all of the class files to be created ahead of time instead of JIT.  

So yeah, really I was just being boneheaded and couldn't find where the precompiled classes were being stored.  Had I know that from the beginning, I wouldn't have even bothered with the archive.

Perhaps you can clarify something for me, though.  It seems that despite precompiling the application, class files still build up under the app's WEB-INF folder.  So when it comes time to actually execute a class, which class files are being invoked?  Is it the class files in the app's WEB-INF?  Or is it the class files in /lucee/lib/lucee-server/context/cfclasses/?
Micha


To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/b11e74b8-e166-4305-9ad6-46f0c7102799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/f4f73f7f-e06e-439c-b13e-56b1a6eeab0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

Michael Offner

unread,
May 8, 2015, 6:20:08 PM5/8/15
to lu...@googlegroups.com
Always in the web context (web-inf)

Micha
Micha


To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/b11e74b8-e166-4305-9ad6-46f0c7102799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/f4f73f7f-e06e-439c-b13e-56b1a6eeab0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages