cancel
Showing results for 
Search instead for 
Did you mean: 

Execute JAR file placed inside Alfresco repository

cile87
Champ on-the-rise
Champ on-the-rise
Say I have a JAR file in Company Home/myfolder/myJarFiles/someJar.jar and now I want to execute that JAR form inside Alfresco. Is that possible by the way?

What I'm trying to do, is create an URL out of that JAR file with this (when I enter given URL in browser, it starts downloading a file, so the URL is probably correct):
String url = "http://www.mywebsite.com:8080/alfresco" + Utils.generateURL(FacesContext.getCurrentInstance(), new Node(fileInfo.getNodeRef()), URLMode.HTTP_DOWNLOAD);‍
then use class loader to load jar and create an instance of class:
Class klass = Class.forName("my.package.MyClass", true, classLoader);Object myObject = klass.newInstance();‍‍
However, I keep getting a ClassNotFoundException in java.security.AccessController.doPrivileged method.
Is is possible that Alfresco doesn't let me load my own classes dynamically? Is there a cure? Or perhaps it is something totally diiferent…?

Thanks.
1 REPLY 1

cile87
Champ on-the-rise
Champ on-the-rise
I got the solution. You need to append ?ticket={YOUR_TICKET} to URL string:
String url = "http://www.mywebsite.com:8080/alfresco" + Utils.generateURL(FacesContext.getCurrentInstance(), new Node(fileInfo.getNodeRef()), URLMode.HTTP_DOWNLOAD) + "?ticket=" + ticket;‍
and then it successfully loads JAR file.