Solved

Problem with CFOBJECT (or java class) in CF 9.0

Posted on 2011-09-12
26
511 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_
Comment Utility
>> 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
Comment Utility
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_
Comment Utility
>> 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
Comment Utility
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_
Comment Utility
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_
Comment Utility
>>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
Comment Utility
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_
Comment Utility
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
Comment Utility
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_
Comment Utility
>> 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
Comment Utility
I am still waiting on the information and will get the details
0
 
LVL 52

Expert Comment

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

Expert Comment

by:_agx_
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Tpaul_10
Comment Utility
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_
Comment Utility
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
Comment Utility
>>> 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
Comment Utility
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_
Comment Utility
>>> 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
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

10 Experts available now in Live!

Get 1:1 Help Now