How to set Aspose.Cells license in ColdFusion

Hi,

I now get: 'The setLicense Method was not found’

With:

<cfset license=CreateObject(“java”, “com.aspose.cells.License”).init()>
<cfset setLicense = license.setLicense(“Aspose.Cells.lic”)>

Thanks,
Mike

Hi Mike,

Thank you for considering Aspose.

Please try the following code to set your license in cold fusion:

<cfobject action="create" type="java" class="java.io.FileInputStream" name="LicFile">
<cfset LicfileI = LicFile.init(JavaCast("string","Aspose.Cells.lic"))
<cfobject action="create" type="java" class="com.aspose.cells.License" name="license">

If you still face any problem, try using the complete license file path e.g. C:\ColdFusion9\Aspose.Cells.lic.

Thank You & Best Regards,

I don’t get an error with this:

<cfset LicfileI = LicFile.init(JavaCast(“string”,“D:\Inetpub\wwwroot\Intranet\Aspose.Cells.lic”))>



<cfset workbook=CreateObject(“java”, “com.aspose.cells.Workbook”).init()>

<cfset sheet= worksheets.getSheet(“Sheet1”)>


<cfset cell.setValue(“Hello World!”)>
<cfset workbook.save(“D:\Inetpub\wwwroot\Intranet\testtwg\sales_reports\engr\temp\out2.xls”)>

But -

The result xls file still has a tab talking about it being an evaluation copy. We purchased in Aug. 09 - I have the PO number if you need it.

Am I still missing something?

Thanks,
Mike

Hi Mike,

Thank you for considering Aspose.

Please update your code as below.

<cfobject action="create" type="java" class="java.io.FileInputStream" name="LicFile">
<cfset LicfileI = LicFile.init(JavaCast("string","D:\Inetpub\wwwroot\Intranet\Aspose.Cells.lic") )>
<cfobject action="create" type="java" class="com.aspose.cells.License" name="license"><cfset license.setLicense(LicfileI)>
<cfset workbook=CreateObject("java", "com.aspose.cells.Workbook").init()
<cfset worksheets = workbook.getWorksheets()>
<cfset sheet= worksheets.getSheet("Sheet1")>
<cfset cells= sheet.getCells()>
<cfset cell= cells.getCell(0,0)>
<cfset cell.setValue("Hello World!")
<cfset workbook.save("D:\Inetpub\wwwroot\Intranet\testtwg\sales_reports\engr\temp\out2.xls")>`

Thank You & Best Regards,

Hello,

I get an error reading:

Error when parse license stream line 8 which is

cfset license.setLicense(LicfileI)

Thanks,
Mike

Hi Mike,

Thank you for considering Aspose.

Well, I checked the code (shared in my previous post) and it works fine. Please send us your license file via email and we will check it soon. Please follow the steps mentioned in the below link to send us the license file (please don’t post your license file in the forum).

[How to Send License File to Support Team Please provide your license here]

Thank You & Best Regards,

Hi,

Thank you for considering Aspose.

We have received your file via email. I checked your issue with your license file and still I am not able to reproduce the issue you mentioned. Please share the complete sample code, your system environment like OS, Cold Fusion version, Aspose.Cells version etc. This will help us figure out the issue soon.

Thank You & Best Regards,

Here is the complete code:


Hello World!

This example shows how to create a simple MS Excel Workbook using Aspose.Cells


<cfset LicfileI = LicFile.init(JavaCast(“string”,“D:\Inetpub\wwwroot\Intranet\Aspose.Cells.lic”))>



<cfset license.setLicense(LicfileI)>



<cfset workbook=CreateObject(“java”, “com.aspose.cells.Workbook”).init()>



<cfset sheet= worksheets.getSheet(“Sheet1”)>





<cfset cell.setValue(“Hello World!”)>

<cfset workbook.save(“D:\Inetpub\wwwroot\Intranet\testtwg\sales_reports\engr\temp\out2.xls”)>

Download

<!— Tell the browser to expect an Excel file attachment.
<cfheader
name=“content-disposition”
value=“attachment; filename=out.xls”
/>

<!—
Tell browser the length of the byte array output stream.
This will help the browser provide download duration to
the user.
—>
<cfheader
name=“content-length”
value="#REQUEST.ExcelData.Size()#"
/>

<!— Stream the binary data to the user. —>
<cfcontent
type=“application/excel”
variable="#REQUEST.ExcelData.ToByteArray()#"
/>

—>





The OS is Windows Server 2003,
ColdFusion version 8.0
- ColdFusion is installed on the C drive, however, it loads InetPub on the D. Cells is working without the license (just getting the register notification).
Aspose.Cells (I believe I have installed JDK 1.4). Let me know if I need to install JDK 5.0 instead.

Hi,

Thank you for sharing the details.

We will look into your issue and get back to you soon.

Thank You & Best Regards,

Hello -

I typed in Java - version to terminal and I am apparently running 1.6.0_17-b04
Is this the issue?

Thanks,
Mike

Hi Mike,

I ran your exact code with your license file and it works absolutely fine. My system environment is Windows XP, ColdFusion 9, and JDK 5.0. Please make sure you are using the jar file in JDK 5.0 folder in your installation path. Also, share the complete exception stack trace (which may help us in finding the issue). We will also try to create same system environment as yours to try and figure out the issue.

Thank you for your constant support in figuring out the issue.

Hello,

I made sure I have the JDK 5.0 and restarted Coldfusion server. Here is the entire output error:








<tr>
    <td colspan="2">
        <table border="0" cellpadding="0" cellspacing="0">
    	<tbody><tr>
    	    <td><font style="color: black; font: 8pt/11pt verdana;">Browser  </font></td>
    		<td><font style="color: black; font: 8pt/11pt verdana;">Mozilla/5.0

(Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115
Firefox/3.6 (.NET CLR 3.5.30729)













The following information is meant for the
website developer for debugging purposes.



Error Occurred While Processing Request


<table border="0" cellpadding="0" cellspacing="0" width="500">
<tbody><tr>
    <td id="tableProps2" align="left" valign="middle" width="500">
        <h1 id="textSection1" style="color: black; font: 13pt/15pt verdana;">
        Error when parse license stream.
        </h1>
    </td>
</tr>
<tr>
    <td id="tablePropsWidth" colspan="2" width="400">
        <font style="color: black; font: 8pt/11pt verdana;">
        
        </font>
    <br></td>
</tr>
<tr>
    <td height=""> </td>
</tr>


    		<tr>
    			<td colspan="2" width="400">
    			<font style="color: black; font: 8pt/11pt verdana;">

    			The error occurred in <b>D:\InetPub\wwwroot\Intranet\testtwg\sales_reports\engr\test.cfm:

line 11

    			</font></td>
    		</tr>
		
			<tr>
			    <td colspan="2">

				
						<pre>9 : <cfobject action="create" type="java" class="com.aspose.cells.License" name="license"><br>10 : <br><b>11 : <cfset license.setLicense(LicfileI)></b><br>12 : <br>13 :  <br></pre>
					

			    </td>
			</tr>
			<tr>
				<td colspan="2">
					<hr color="#c0c0c0" noshade="noshade">
				</td>
			</tr>
		
<tr>
    <td colspan="2">
        <font style="color: black; font: 8pt/11pt verdana;">
        Resources:
        </font><ul><font style="color: black; font: 8pt/11pt verdana;">	    
<li>Check the <a href="http://www.macromedia.com/go/proddoc_getdoc" target="new">ColdFusion documentation</a> to verify that you are using 

the correct syntax.

  • Search the Knowledge Base to find a solution to your problem.
  •         </font></ul>
    


    Remote
    Address
    76.121.5.59
    Referrer
    Date/Time 28-Feb-10
    06:59 PM



        <table cellpadding="0" cellspacing="0" width="500">
        <tbody><tr>
            <td valign="top">
                <font style="font: 8pt/11pt verdana;">
                Stack Trace 
            </font></td>
        </tr>
        <tr>
            <td id="cf_stacktrace">
                <font style="color: black; font: 8pt/11pt verdana;">
                	at 
    

    cftest2ecfm1277860170.runPage(D:\InetPub\wwwroot\Intranet\testtwg\sales_reports\engr\test.cfm:11)

                <br>
                <br>
                </font><pre><font style="color: black; font: 8pt/11pt verdana;">com.aspose.cells.AsposeLicenseException: Error when parse license stream.<br>	at com.aspose.cells.License.setLicense(Unknown Source)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>	at java.lang.reflect.Method.invoke(Method.java:597)<br>	at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:87)<br>	at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2272)<br>	at cftest2ecfm1277860170.runPage(D:\InetPub\wwwroot\Intranet\testtwg\sales_reports\engr\test.cfm:11)<br>	at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)<br>	at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370)<br>	at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)<br>	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273)<br>	at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)<br>	at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)<br>	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)<br>	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)<br>	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)<br>	at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)<br>	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)<br>	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)<br>	at coldfusion.CfmServlet.service(CfmServlet.java:175)<br>	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)<br>	at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)<br>	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)<br>	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)<br>	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)<br>	at jrun.servlet.FilterChain.service(FilterChain.java:101)<br>	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)<br>	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)<br>	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)<br>	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)<br>	at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)<br>	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)<br>	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)<br>	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)<br>	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)<br></font></pre></td></tr></tbody></table></font></td></tr></tbody></table><br>
    

    Hi Mike,

    Thank you for sharing the complete exception stack trace.

    We will further look into your issue and will get back to you soon.

    Thank You & Best Regards,

    Hi,

    Please try the attached version.

    We have added some more exception messages for setting license. Please try this new fix and give us the output error messages. Or you can just transform the following java code to the script in ColdFusion and see whether it can work fine now:

    javax.xml.parsers.DocumentBuilderFactory builderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
    javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder();
    builder.parse(new FileInputStream("Aspose.Cells.lic"));

    Thank you.

    Amjad,

    Here is my revised trace - thanks :








    <tr>
        <td colspan="2">
            <table border="0" cellpadding="0" cellspacing="0">
        	<tbody><tr>
        	    <td><font style="color: black; font: 8pt/11pt verdana;">Browser  </font></td>
        		<td><font style="color: black; font: 8pt/11pt verdana;">Mozilla/5.0
    

    (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115
    Firefox/3.6 (.NET CLR 3.5.30729)













    The following information is meant for the
    website developer for debugging purposes.



    Error Occurred While Processing Request


    <table border="0" cellpadding="0" cellspacing="0" width="500">
    <tbody><tr>
        <td id="tableProps2" align="left" valign="middle" width="500">
            <h1 id="textSection1" style="color: black; font: 13pt/15pt verdana;">
            Error when parse license stream.
            </h1>
        </td>
    </tr>
    <tr>
        <td id="tablePropsWidth" colspan="2" width="400">
            <font style="color: black; font: 8pt/11pt verdana;">
            
            </font>
        <br></td>
    </tr>
    <tr>
        <td height=""> </td>
    </tr>
    
    
        		<tr>
        			<td colspan="2" width="400">
        			<font style="color: black; font: 8pt/11pt verdana;">
    
        			The error occurred in <b>D:\InetPub\wwwroot\Intranet\testtwg\sales_reports\engr\test.cfm:
    

    line 11

        			</font></td>
        		</tr>
    		
    			<tr>
    			    <td colspan="2">
    
    				
    						<pre>9 : <cfobject action="create" type="java" class="com.aspose.cells.License" name="license"><br>10 : <br><b>11 : <cfset license.setLicense(LicfileI)></b><br>12 : <br>13 :  <br></pre>
    					
    
    			    </td>
    			</tr>
    			<tr>
    				<td colspan="2">
    					<hr color="#c0c0c0" noshade="noshade">
    				</td>
    			</tr>
    		
    <tr>
        <td colspan="2">
            <font style="color: black; font: 8pt/11pt verdana;">
            Resources:
            </font><ul><font style="color: black; font: 8pt/11pt verdana;">	    
    <li>Check the <a href="http://www.macromedia.com/go/proddoc_getdoc" target="new">ColdFusion documentation</a> to verify that you are using 
    

    the correct syntax.

  • Search the Knowledge Base to find a solution to your problem.
  •         </font></ul>
    


    Remote
    Address
    76.121.5.59
    Referrer
    Date/Time 02-Mar-10
    06:29 PM



        <table cellpadding="0" cellspacing="0" width="500">
        <tbody><tr>
            <td valign="top">
                <font style="font: 8pt/11pt verdana;">
                Stack Trace 
            </font></td>
        </tr>
        <tr>
            <td id="cf_stacktrace">
                <font style="color: black; font: 8pt/11pt verdana;">
                	at 
    

    cftest2ecfm1277860170.runPage(D:\InetPub\wwwroot\Intranet\testtwg\sales_reports\engr\test.cfm:11)

                <br>
                <br>
                </font><pre><font style="color: black; font: 8pt/11pt verdana;">com.aspose.cells.AsposeLicenseException: Error when parse license stream.<br>	at com.aspose.cells.License.setLicense(Unknown Source)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>	at java.lang.reflect.Method.invoke(Method.java:597)<br>	at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:87)<br>	at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2272)<br>	at cftest2ecfm1277860170.runPage(D:\InetPub\wwwroot\Intranet\testtwg\sales_reports\engr\test.cfm:11)<br>	at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)<br>	at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370)<br>	at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)<br>	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273)<br>	at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)<br>	at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)<br>	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)<br>	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)<br>	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)<br>	at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)<br>	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)<br>	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)<br>	at coldfusion.CfmServlet.service(CfmServlet.java:175)<br>	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)<br>	at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)<br>	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)<br>	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)<br>	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)<br>	at jrun.servlet.FilterChain.service(FilterChain.java:101)<br>	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)<br>	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)<br>	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)<br>	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)<br>	at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)<br>	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)<br>	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)<br>	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)<br>	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)<br>Caused by: org.xml.sax.SAXParseException: Premature end of file.<br>	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)<br>	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)<br>	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)<br>	... 36 more<br></font></pre></td></tr></tbody></table></font></td></tr></tbody></table><br>
    

    Hi,

    It seems your license file is corrupted and cannot be recognized as a valid
    xml file. I think you can try the code shown in our previous post, the code does
    not use Aspose.Cells any more and only try to load the xml file by SAX. I
    think it should give an exception too. Did you modified the license file manually? To trace this issue, please transform following code to the script in
    ColdFusion and give us the output file(res.dat) and your original license
    file(both by mail please):
    FileInputStream fis = new FileInputStream("Aspose.Cells.lic");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    int c = fis.read();
    while(c > -1)
    {
    baos.write(c);
    c = fis.read();
    }
    FileOutputStream fos = new FileOutputStream("res.dat");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(baos.toByteArray());
    oos.close();
    fos.close();

    Thank you.

    Amjad,



    I have not open or manipulated the license file in any way. I don’t
    know how to transform the code to Coldfusion, either.



    What other tech support options are available here? This isn’t working.



    Mike

    Amjad,

    As an idea, if you think my license file is corrupt, then let’s issue a new license file. You could send me your code and the new file (tested and confirmed to work), and I’ll install. Then we can isolate the issue to the server (or hopefully resolve the problem altogether).

    I have the invoice and any other information you may need to confirm our license. You should have the original license I sent to you in a previous email.

    Let me know your thoughts.

    Hi,
    I have sent your license file to you via email. It works absolutely fine. Please try the attached code in your environment. Following are the details for how I run the code:

    I placed the license file in the ColdFusion9\runtime\bin folder.

    The location of my test page is ColdFusion9\wwwroot\CFIDE\aspose\aspose2.cfm.

    Please try your license file again and see if it works fine with the attached file.

    Thank You & Best Regards,

    That did it! Thanks!