Solved

Problem with CFOBJECT (or java class) in CF 9.0

Posted on 2011-09-12
26
512 Views
Last Modified: 2013-12-24
Experts,

Recently I have upgraded from CFMX 7.0 to CF 9.0 using the free developer edition.
Everything worked fine except accessing the java classes. Following is my code and CF Admin setting and have all the related .jar files in my folder.

Java Virtual Machine Path : C:/ColdFusion9/runtime/jre
ColdFusion Class Path  : E:\Website\Report_lib

Error Message from the code : , Variable myRpt is undefined.

Am I missing anything here or did anything change in CF 9.0 related to cfobject tag or registering the class?

Thanks in advance.
<cftry>
	<cfobject action=create type=java class="ReportList" name=MyReportView>
		<cfscript>
			myRpt = MyReportView.getBillingViewReport(sItemNumber);
		</cfscript>
	
		<cfoutput>#myRpt#</cfoutput>
		
	<cfcatch type = "any">
		<cfset pErrorDetail = CFCATCH.Detail>
		<cfset pErrorMessage = CFCATCH.Message>
		<cfoutput>#pErrorDetail# , #pErrorMessage#</cfoutput>
	</cfcatch>

</cftry>

Open in new window

0
Comment
Question by:Tpaul_10
  • 14
  • 12
26 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 36524173
>> have all the related .jar files in my folder.
>> ColdFusion Class Path  : E:\Website\Report_lib

You mean the jars are in "E:\Website\Report_lib" and that folder was added to your CF class path in the CF administrator?

>> Error Message from the code : , Variable myRpt is undefined.

If the jars weren't registered properly, you probably wouldn't even get that far.  CF would say it couldn't find the class when you called <cfobject>.  That error suggests MyReportView.getBillingViewReport() can't find the #sItemNumber# and is returning NULL.  Is that how your jar behaves?
0
 

Author Comment

by:Tpaul_10
ID: 36524366
Yes, the jars are in "E:\Website\Report_lib" and that folder was added to my CF class path in the CF administrator.

It is failing at <cfoutput>#myRpt#</cfoutput> and the error is , Variable myRpt is undefined.

sItemNumber variable is working fine and has a value and it is not null.

Please let me know if I don't make sense.

Thanks
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36524551
>> sItemNumber variable is working fine and has a value and it is not null.

No, I didn't mean  sItemNumber is null. I meant your object is returning a java null instead of whatever string or number you're expecting.  Since CF doesn't have nulls it says the variable is "undefined" instead.  Make sense?

ie  Null is the same as an undefined variable
     <cfset x = javacast("null", "")>
     <!--- should generate a "variable x is undefined" error --->
     <cfoutput>#x</cfoutput>
0
 

Author Comment

by:Tpaul_10
ID: 36524681
Perfect, THANKS for your patience and explanation. It does make sense. I will ask my Java folks to look at the class and it's methods.

Is there anything else I need to do or register from the CF point of view other than having Java Virtual Machine Path and ColdFusion Class Path ?

Thanks again.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36525243
Nope.  To use a java class you just add the jar to the CF class path and restart (which you've done).  

So far, it just seems like a usage issue. If you can dump the object created, then the jar is definitely registered ok

   <cfobject action=create type=java class="ReportList" name=MyReportView>
   <cfdump var="#MyReportView#">

0
 
LVL 52

Expert Comment

by:_agx_
ID: 36525461
>>I will ask my Java folks to look at the class and it's methods.

Ok. It's possible that returning NULL is valid.  For example, that might be how getBillingViewReport() indicates the id wasn't found.  If so, you'd just need to handle it in your code.

      <cfobject action=create type=java class="ReportList" name=MyReportView>
        <cfset myRpt = MyReportView.getBillingViewReport(sItemNumber)>
        <cfif structKeyExists(variables, "myRpt")>
              variable exists. do something here ...
        <cfelse>
              result is null. do something else
        </cfif>
0
 

Author Comment

by:Tpaul_10
ID: 36530698
While we are still looking into the .jar file, here is what I did

I have copied the .jar file which is giving me error (i.e. variable not found) and placed on my QA box where I have CFMX 7.0 and it works fine with no issues.

Is there anything changed in CF 9.0, the way it reads the .jar file or do we need to change anything in .jar file?

Just wanted to inform you what's going on and will update you once I get the details about the .jar file.

Thanks for your time and help.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36530844
Usually when there's a problem loading the class, you'd get a java exception.  But you say that's not happening. I'm wondering if maybe your cfcatch code isn't showing you the full error.  Try commenting it out and post the stack trace here.  Also check your CF logs. Any error messages there?

>> Is there anything changed in CF 9.0, the way it reads the .jar file

There's loads of changes. But the basic process is the same. Just add jar to path and restart.

- What is this jar you're using? Is it proprietary or something publically accessible?
- Does it have any dependencies ?  
- What does the method return? String, number, object .. ?

0
 

Author Comment

by:Tpaul_10
ID: 36533321
Nothing in CF Logs, I am not sure why. Here is what I have got after commenting CFCATCH and I will get you the answers about .jar file

Diagnostics:
Variable COGNOSRPT is undefined.
The error occurred on line 81.
--------------------------------------------------------------------------------
 Date: {ts '2011-09-13 16:14:41'}
--------------------------------------------------------------------------------
Browser Versioin: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)
------------------------------------------k--------------------------------------
Remote Address:
--------------------------------------------------------------------------------
Referer: http://mypath
--------------------------------------------------------------------------------
Template: my.cfm
--------------------------------------------------------------------------------
Querystring:
--------------------------------------------------------------------------------
Fuseaction: ReportView

Thanks
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36533532
>> Nothing in CF Logs, I am not sure why

Did you check after you removed the try/catch? Because try/catch prevents most errors from being written to the logs.

Assuming this is a dev box, are you able to access the stack trace? It should be at the bottom left corner of the error message ie "Stack Trace (click to expand) ".  I don't think it'll tell us anything new, but it wouldn't hurt to check.

>> I will get you the answers about .jar file

Sounds good.
0
 

Author Comment

by:Tpaul_10
ID: 36816731
I am still waiting on the information and will get the details
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36816842
No worries. I can see you're busy with other upgrading issues.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37034358
You know .. have you checked the permissions of the CF service account? Maybe there's a difference between the account CF7 and CF9 are running under.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Tpaul_10
ID: 37038967
Here is what I have checked

1. Under Services>> ColdFusion 9 Application Server >> Properties > Under Log on tab,
Local System Account radio button has been checked.
2. It is the same for CF 7.0

Am I looking at the right place?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37039045
Yeah, that's the right one.  The local system account has limited permissions, more so on win7. Verify it has access to any resources use by the jar.
0
 

Author Comment

by:Tpaul_10
ID: 37039108
>>> Verify it has access to any resources use by the jar.

Not quite sure about this and from the general tab I have Path to Executables as
"C:\ColdFusion9\runtime\bin\jrunsvc.exe""

Thanks
0
 

Author Comment

by:Tpaul_10
ID: 37039608
I mean how to "Verify it has access to any resources use by the jar."? Through the code or checking some properties etc?

Thanks
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37040113
>>> Verify it has access to any resources use by the jar.

That means whatever files, folders, databases, etc... your jar uses. Every jar is different.  Remember, I don't even know which library you're using. Only you know what your jar is doing.
0
 

Author Comment

by:Tpaul_10
ID: 37047376
It has the right access to all the files, folders, databases like I have in CF 7.0.

I was just checking CF9/runtime/logs/coldfusion-out.txt file and found this and not sure what to check based on this.
java.lang.NullPointerException
at com.cognos.org.apache.axis.serviceContext.ServiceContext.updateImplicitHeader(ServiceContext.java:270)
at com.cognos.developer.schemas.bibus._3.ContentManagerServiceStub.logon(ContentManagerServiceStub.java:5388)

>>> I don't even know which library you're using  === I didn't get this too about the library?

Thanks

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 37047809
Oh. Didn't know it was webservice related. Shot in the dark, but any chance it's version of axis is conflicting with CF's axis jar?

> I didn't get this too about the library?

I just meant I had no clue what product/jar you were using ;-)
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37047819
I'm not familiar with cognos, but does it have an option to enable verbose logging? Most libraries do.
0
 

Assisted Solution

by:Tpaul_10
Tpaul_10 earned 0 total points
ID: 37058711
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37059697
Good work! Thanks for posting the solution.  I've don't know how you got there from a NullPointerException ... but I'm VERY glad to hear you finally got things working :)  Don't forget to mark your comment as the solution so it's added to the archives.
0
 

Author Comment

by:Tpaul_10
ID: 37059909
I will do that, but I would like to give full credit and points to you for all your support, patience and the way you directed me to on many things recently.

Thanks for all your help.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37065265
You're very welcome.  IIRC, you can do a split ie Accept your comment as the solution and mark others as "assisted" solutions.  But don't worry about points unless the comments actually helped you find the problem ;-) I'm just glad you finally got things up and running under CF9.
0
 

Author Closing Comment

by:Tpaul_10
ID: 37089830
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now