使用ColdFusion访问Jar文件类和方法

时间:2015-09-01 12:52:06

标签: java xml jar coldfusion

我有一个jar文件,提取时有以下路径

 xmlcreator.jar

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

如果我像下面这样创建myObj1,我可以查看data1中的所有字段,而field1包含value1。

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

我想在填充data1类中的所有字段后创建xml。 xxxx.class有创建xml文件的createxml方法,但是如果我尝试以下操作,似乎createxml不知道data1。

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

ColdFusion错误只是返回错误顶部的data1而没有任何解释。因此,通过创建对象xmlpackage.xxxx,我似乎无法访问data1。

我是否将数据导入data1类并获取xxxx.createxml以创建xml文件?

更新

很抱歉这个混乱。我认为保持简单会变得容易。我按照我要尝试的顺序添加了代码,对象的转储以及错误的堆栈跟踪。

<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#">

转储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

转储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

堆栈跟踪

 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 ...

1 个答案:

答案 0 :(得分:0)

(来自评论)

  

java.lang.NoSuchFieldException: PATIENTROLE

查看转储中的字段,看起来您尝试设置的字段的名称为patientRoleObj,而不是patientRole。请尝试使用该字段名称:

<cfset yourOtherObject.patientRoleObj = yourPatientRoleObject />