• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

Problem with CFOBJECT (or java class) in CF 9.0

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
Tpaul_10
Asked:
Tpaul_10
  • 14
  • 12
2 Solutions
 
_agx_Commented:
>> 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
 
Tpaul_10Author Commented:
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
 
_agx_Commented:
>> 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Tpaul_10Author Commented:
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
 
_agx_Commented:
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
 
_agx_Commented:
>>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
 
Tpaul_10Author Commented:
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
 
_agx_Commented:
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
 
Tpaul_10Author Commented:
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
 
_agx_Commented:
>> 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
 
Tpaul_10Author Commented:
I am still waiting on the information and will get the details
0
 
_agx_Commented:
No worries. I can see you're busy with other upgrading issues.
0
 
_agx_Commented:
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
 
Tpaul_10Author Commented:
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
 
_agx_Commented:
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
 
Tpaul_10Author Commented:
>>> 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
 
Tpaul_10Author Commented:
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
 
_agx_Commented:
>>> 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
 
Tpaul_10Author Commented:
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
 
_agx_Commented:
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
 
_agx_Commented:
I'm not familiar with cognos, but does it have an option to enable verbose logging? Most libraries do.
0
 
Tpaul_10Author Commented:
0
 
_agx_Commented:
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
 
Tpaul_10Author Commented:
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
 
_agx_Commented:
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 14
  • 12
Tackle projects and never again get stuck behind a technical roadblock.
Join Now