简体   繁体   中英

Accessing Jar File Classes and Methods with ColdFusion

I have a jar file that when extracted has the following path

 xmlcreator.jar

 xmlcreator (folder)
     xmlpackage (folder)
         data1.class
         xxxx.class
             createxml (method)

If I create myObj1 like the following, I can view all the fields in data1 and field1 contains value1.

 <cfset myObj1 = createObject("java","xmlpackage.data1") />
 <cfset myObj1.field1 = "value1">
 <cfdump var="#myObj1#">

I would like to create the xml after populating all the fields in the data1 class. The xxxx.class has the method createxml that creates the xml file however if I try the following it seems that createxml does not know about data1.

 <cfset myObj2 = createObject("java","xmlpackage.xxxx”) />
 <cfset myObj2.data1 = myobj1 />
 <cfset return = myObj2.createxml()>

The ColdFusion error simply returns data1 at the top of the error with no explanation. So by creating the object xmlpackage.xxxx I can not seem to get to data1.

I do I get data into the data1 class and get xxxx.createxml to create the xml file?

Update:

Sorry for the confusion. I thought that keeping it simple was going to be easy. I have added the code, the dump of the object, and the stack trace of the error in order of what I am attempting to do.

<cfset myObj = createObject("java","CDAPackage.PatientRole") />
<cfset myObj.patientFamilyName = "Jones">
<cfdump var="#myObj#">

<cfset ccdaObj = createObject("java","CDAPackage.CCDA") />
<cfdump var="#ccdaObj#">
<cfset ccdaObj.PatientRole = myobj />
<cfset x = ccdaObj.GenerateCCDA()>
<cfdump var="#x#">

Dump of myObj

object of CDAPackage.PatientRole
Class Name  CDAPackage.PatientRole
Methods 
Method  Return Type
getRaceList()   java.util.List
setRaceList(java.util.List) void
Fields  
Field   Value
java.util.List RaceList [undefined value]
java.lang.String administrativeGenderCode   [undefined value]
java.lang.String administrativeGenderDisplayName    [undefined value]
CDAPackage.Address birthPlaceAddress    CDAPackage.Address
java.lang.String birthTime  [undefined value]
java.lang.String ethnicGroupCode    [undefined value]
java.lang.String ethnicGroupCodeDisplayName [undefined value]
java.lang.String insuranceProvider  [undefined value]
java.lang.String languageCommunication  [undefined value]
java.lang.String languageCommunicationDisplayname   [undefined value]
java.lang.String languageCommunicationModeCodeCode  [undefined value]
java.lang.String languageCommunicationModeCodeDisplayName   [undefined value]
java.lang.String languageCommunicationPreferenceInd [undefined value]
java.lang.String maritalStatusCode  [undefined value]
java.lang.String maritalStatusDisplayName   [undefined value]
java.lang.String mrn    [undefined value]
CDAPackage.Address patientAddress   CDAPackage.Address
java.lang.String patientFamilyName  Jones
... more fields

Dump of ccdaObj

object of CDAPackage.CCDA
Class Name  CDAPackage.CCDA
Methods 
Method  Return Type
GenerateCCDA()  java.lang.String
Fields  
Field   Value
java.lang.String CCDACode   [undefined value]
java.lang.String CCDADisplayName    [undefined value]
java.lang.String CCDAEffectiveTimeValue [undefined value]
java.lang.String Chiefcomplaint [undefined value]
java.lang.String DocumentID [undefined value]
java.lang.String EHRID  [undefined value]
java.lang.String EHRName    [undefined value]
CDAPackage.Address FacilityAddressObj   CDAPackage.Address
java.util.List FunctionalStatusListObj  java.util.List
CDAPackage.AssignedPerson PrimaryProviderObj    CDAPackage.AssignedPerson
java.util.List ReferralListObj  java.util.List
java.util.List allergyListObj   java.util.List
java.util.List carePlanListObj  java.util.List
java.util.List careTeamObj  java.util.List
java.lang.String dischargeinstructions  [undefined value]
java.util.List encounterDiagnosisListObj    java.util.List
java.util.List encounterListObj java.util.List
java.util.List immunizationListObj  java.util.List
java.util.List instructionListObj   [undefined value]
java.util.List medicationAdministedListObj  java.util.List
java.util.List medicationListObj    java.util.List
CDAPackage.PatientRole patientRoleObj   CDAPackage.PatientRole
... more fields

Stack Trace

 java.lang.NoSuchFieldException: PATIENTROLE
     at coldfusion.runtime.StructBean.bindName(StructBean.java:243)
     at coldfusion.runtime.Scope.put(Scope.java:74)
     at coldfusion.runtime.CfJspPage._arrayset(CfJspPage.java:1093)
     at     coldfusion.runtime.NeoPageContext.SymTab_setSplitNameInMap(NeoPageContext.java:1429)
at coldfusion.runtime.CfJspPage._structSetAt(CfJspPage.java:2356)
at cfdllcall2ecfm1400054296.runPage(/Applications/ColdFusion11/cfusion/wwwroot/test/dllcall.cfm:16)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246)
at ...

(From comments)

java.lang.NoSuchFieldException: PATIENTROLE

Looking at the fields in the dump, it looks like the field you are trying to set is named is patientRoleObj , rather than patientRole . Try using that field name instead:

<cfset yourOtherObject.patientRoleObj = yourPatientRoleObject />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM