JAR File structure to override 'share/components/...' direrectory
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2014 04:18 PM
Hi,
I'm not sure if I'm on the right subforum for this topic, but I don't find another one that fits more.
I'm developing a small dashlet that I want to provide as a JAR file for tomcat/shared/lib. It's based on the "get-latest-document" dashlet example: https://code.google.com/p/alfresco-get-latest-document
The example dashlet works well if I copy and paste it into tomcat/shared/lib, but my extension won't work in this way. If I compare the created folder structure of both (the example jar and my final jar), it's nearly the same (only the file/webscript names has changed). It seems to be that the JavaScript/CSS/Image won't be found. All is located in the META-INF folder.
Here is my structure of the generated JAR file that does not work:
The strange is:
If I just copy the my_javascript.js + my_stylesheet.css to the exploded folder: "tomcat\webapps\share\components\dashlets" and the my_image.png to exploded folder "tomcat\webapps\share\images" it works, meaning the rest of the files in the JAR seems to be considered even the repo stuff in "templates". I don't see my mistake!?? What I'm doing wrong? Has anybody a clue why the files in the META-INF folder doesn't work?
Thanks guys!
I'm not sure if I'm on the right subforum for this topic, but I don't find another one that fits more.
I'm developing a small dashlet that I want to provide as a JAR file for tomcat/shared/lib. It's based on the "get-latest-document" dashlet example: https://code.google.com/p/alfresco-get-latest-document
The example dashlet works well if I copy and paste it into tomcat/shared/lib, but my extension won't work in this way. If I compare the created folder structure of both (the example jar and my final jar), it's nearly the same (only the file/webscript names has changed). It seems to be that the JavaScript/CSS/Image won't be found. All is located in the META-INF folder.
Here is my structure of the generated JAR file that does not work:
my_jar.jar|+-alfresco| || +-site-webscripts| | || | +-com| | || | +-myModule| | || | +-components| | | || | | +-dashlets| | | || | | + … webscripts …| | || | +-modules| | || | +-getMyModule| | || | +-config| | || | +- …config webscripts …| || +-templates| || + … repo stuff …|+-META-INF | +-extension | | | +-components | | | +-dashlets | | | | | +-my_stylesheet.css | | +-my_javascript.js | | | +-images | | | +-my_image.png | +-MANIFEST.MF
The strange is:
If I just copy the my_javascript.js + my_stylesheet.css to the exploded folder: "tomcat\webapps\share\components\dashlets" and the my_image.png to exploded folder "tomcat\webapps\share\images" it works, meaning the rest of the files in the JAR seems to be considered even the repo stuff in "templates". I don't see my mistake!?? What I'm doing wrong? Has anybody a clue why the files in the META-INF folder doesn't work?
Thanks guys!
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2014 05:41 AM
Hello,
first of all, please don't package Repository stuff in the same JAR as Share stuff. This may not be considered bad practice by most developers, but you should separate Repository from Share stuff to avoid any potential, crazy side-effects. Most (proper) people use separate Tomcat instances for Repository and Share too.
Your problem in this case seems to be the added "extension" folder in your JAR. You say it works fine if you put your resources in the exploded directory path, which does not contain "extension" anywhere. The path below META-INF is the same path you would expect in the exploded directory structure for client-side resources.
Regards
Axel
first of all, please don't package Repository stuff in the same JAR as Share stuff. This may not be considered bad practice by most developers, but you should separate Repository from Share stuff to avoid any potential, crazy side-effects. Most (proper) people use separate Tomcat instances for Repository and Share too.
Your problem in this case seems to be the added "extension" folder in your JAR. You say it works fine if you put your resources in the exploded directory path, which does not contain "extension" anywhere. The path below META-INF is the same path you would expect in the exploded directory structure for client-side resources.
Regards
Axel
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 03:55 AM
Hi Axel,
thank you for explaining in detail. My initial intention was to create my addon based on the mentioned example to get it first working at all. Later on, I'll split the repo from the share. With your help I've removed the "extension" folder and now it is working well. Unfortunatley I do not understand why… because in the get-latest-doc exsample above, the JavaScript in the extension folder will be found (both are in tomcat/shared/lib on the same Alfresco server).
My next strange issue is, that I've tested it against Alfresco Enterprise 4.2.3 - it is working (my addon and the example). Now, I've also installed (the exact same file from 4.2.3) in the latest version Alfresco Enterprise 4.2.3.3 and it doesnt work (neither my addon nor the example). What has significantly changed in this minor version? And the best: If I test the same file that works for 4.2.3 against Alfresco 5, it doesnt work too, but with a different behavior than in 4.2.3.3! In conclusion: I install the same addon against 3 different Alfresco versions and I got 3 different behaviors.
It's a bit frustrating because I don't find any documentation on how such an addon has to be created to work with all Alfresco versions (at least within the minor versions should be the goal… I would understand if it doesnt work with ALF 5.0).
If I check the examples, all have different structures (3 examples, 4 different folder structures but at the end all will do the same). I've found the following wiki page: https://wiki.alfresco.com/wiki/3.0_Component_Standards but last modified date was 23 June 2009. Is there any current documentation for that?
Thanks!
thank you for explaining in detail. My initial intention was to create my addon based on the mentioned example to get it first working at all. Later on, I'll split the repo from the share. With your help I've removed the "extension" folder and now it is working well. Unfortunatley I do not understand why… because in the get-latest-doc exsample above, the JavaScript in the extension folder will be found (both are in tomcat/shared/lib on the same Alfresco server).
My next strange issue is, that I've tested it against Alfresco Enterprise 4.2.3 - it is working (my addon and the example). Now, I've also installed (the exact same file from 4.2.3) in the latest version Alfresco Enterprise 4.2.3.3 and it doesnt work (neither my addon nor the example). What has significantly changed in this minor version? And the best: If I test the same file that works for 4.2.3 against Alfresco 5, it doesnt work too, but with a different behavior than in 4.2.3.3! In conclusion: I install the same addon against 3 different Alfresco versions and I got 3 different behaviors.
It's a bit frustrating because I don't find any documentation on how such an addon has to be created to work with all Alfresco versions (at least within the minor versions should be the goal… I would understand if it doesnt work with ALF 5.0).
If I check the examples, all have different structures (3 examples, 4 different folder structures but at the end all will do the same). I've found the following wiki page: https://wiki.alfresco.com/wiki/3.0_Component_Standards but last modified date was 23 June 2009. Is there any current documentation for that?
Thanks!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 06:59 AM
What I get based on logging for Alfresco 4.2.3.3 is, that is seems to be the ParseArgs.getParsedArgs() does not work anymore as expected.
Here the snippet of my repo get.js file (it will be executed and therefore it is found)
<javascript>
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js">
function getDoclist()
{
// Use helper function to get the arguments
var parsedArgs = ParseArgs.getParsedArgs();
if (parsedArgs === null)
{
logger.log("parsedArgs===null => RETURN…");
return;
}
var filter = args.filter,
…
}
</javascript>
The output in the log is:
Meaning, the parsedArgs are not available. But the "parse-args.lib.js" is still in the folder and contain the function.
What is going wrong here?
Here the snippet of my repo get.js file (it will be executed and therefore it is found)
<javascript>
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js">
function getDoclist()
{
// Use helper function to get the arguments
var parsedArgs = ParseArgs.getParsedArgs();
if (parsedArgs === null)
{
logger.log("parsedArgs===null => RETURN…");
return;
}
var filter = args.filter,
…
}
</javascript>
The output in the log is:
parsedArgs===null => RETURN…
Meaning, the parsedArgs are not available. But the "parse-args.lib.js" is still in the folder and contain the function.
What is going wrong here?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2014 03:59 AM
Hello,
one thing you have to keep in mind is that every Alfresco web script which has a lifecycle of "internal" set in its .desc.xml is a script that can (arbitrarily) change between versions. The script parse-args.lib.js belongs to such a web script (that imports it). Null is typically returned by the function if the URL or URL template parameters are not sufficient to sucessfully resolve a "rootNode" / "pathNode" for a document list data web script. Potentially, Alfresco 4.2.3.3 has added a (missing) check for an error condition - since this is a hot fix release, I haven't checked the details of the code changes.
The example from the Google Code site work because the import on the client side resources actually specify the location as being in the "extension" directory. Could it be that you forgot to include this in your <@script> / <@link> tags?
The documentation for 3.0 component standards is outdated because it applies to Alfresco version 3.0. Apart from the wiki, please also check <a href="http://docs.alfresco.com">docs.alfresco.com</a> which allows you to easily filter search results by Alfresco versions. E.g. <a href="http://docs.alfresco.com/4.2/concepts/dev-extensions-share.html">Share extensions</a> and <a href="http://docs.alfresco.com/4.2/concepts/surf-fwork-intro.html">Working with Surf</a> could be of interest to you.
Regards
Axel
one thing you have to keep in mind is that every Alfresco web script which has a lifecycle of "internal" set in its .desc.xml is a script that can (arbitrarily) change between versions. The script parse-args.lib.js belongs to such a web script (that imports it). Null is typically returned by the function if the URL or URL template parameters are not sufficient to sucessfully resolve a "rootNode" / "pathNode" for a document list data web script. Potentially, Alfresco 4.2.3.3 has added a (missing) check for an error condition - since this is a hot fix release, I haven't checked the details of the code changes.
The example from the Google Code site work because the import on the client side resources actually specify the location as being in the "extension" directory. Could it be that you forgot to include this in your <@script> / <@link> tags?
The documentation for 3.0 component standards is outdated because it applies to Alfresco version 3.0. Apart from the wiki, please also check <a href="http://docs.alfresco.com">docs.alfresco.com</a> which allows you to easily filter search results by Alfresco versions. E.g. <a href="http://docs.alfresco.com/4.2/concepts/dev-extensions-share.html">Share extensions</a> and <a href="http://docs.alfresco.com/4.2/concepts/surf-fwork-intro.html">Working with Surf</a> could be of interest to you.
Regards
Axel
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2014 10:18 AM
Hi Axel,
thank you very much for your answer. Indeed I found still an issue related to the extension directory and I've imported some scripts (JS, CSS) from a wrong direction. This means that they could not be loaded, but it was working fine as long as another dashlet (My Documents) was present because of its imports… This was the reason why I was confused between versions 4.2 and 4.2.3.3 because in 4.2.3.3 the "My Documents" dashlet was not enabled.
Anyway, now it works as expected (even with 5.0) and I can go on with some improvements (like split it into Repo and Share JAR). Thank you again for your great help!
Best regards,
Itzamna
thank you very much for your answer. Indeed I found still an issue related to the extension directory and I've imported some scripts (JS, CSS) from a wrong direction. This means that they could not be loaded, but it was working fine as long as another dashlet (My Documents) was present because of its imports… This was the reason why I was confused between versions 4.2 and 4.2.3.3 because in 4.2.3.3 the "My Documents" dashlet was not enabled.
Anyway, now it works as expected (even with 5.0) and I can go on with some improvements (like split it into Repo and Share JAR). Thank you again for your great help!
Best regards,
Itzamna