'JavaMember' object has no attribute

Hi guys,

i am attempting to get the allocated functions from a deployed physical component as shown below:

for dpc in selected_elem.get_deployed_physical_components():
all_pf = dpc.get_allocated_physical_functions()

I have added the above functions to the capella api(to both capella element and physical component) and ‘selected elem’ in this case is a physical component using the get first selected element method to run my script.

I am aware that for this physical component there is only one deployed component, but my error message appears as follows:

AttributeError: ‘JavaMember’ object has no attribute ‘get_allocated_physical_functions’

has anyone faced this or has any advice?

Thankyou

Yash.

There is an other thread with this exception.

But here the result of selected_elem.get_deployed_physical_components() should be a list of Python objects… so it should not be a JavaMember…

Can you try:

print(type(dpc))
print(str(dpc))
print(isinstance(dpc, PhysicalComponent))

To have a better idea of what is dpc.

dpc is deployed physical component.

I ran these print statements and this is what i got:

starting export of model Distributed Systems
<class ‘tuple’>
<class ‘py4j.java_gateway.JavaMember’>
<py4j.java_gateway.JavaMember object at 0x000001638524E048>
False
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “L/Python4Capella/sample_scripts/FFMEAExportPhysicalComponentScript.py”, line 348, in
if k.startswith(‘EASE’) or ((not k.startswith('’)) and (not k.startswith(‘pyease’)) and (not v.class.module.startswith(‘py4j.’)) and (not hasattr(v, ‘ease’)) and (not v.class.name == ‘module’))
File “L/Python4Capella/sample_scripts/FFMEAExportPhysicalComponentScript.py”, line 285, in main
File “L/Python4Capella/sample_scripts/FFMEAExportPhysicalComponentScript.py”, line 165, in PhysicalFunctionName
self.engine = engine
AttributeError: ‘JavaMember’ object has no attribute ‘get_allocated_physical_functions’

Can you provide your implementation of get_deployed_physical_components() ?

def get_deployed_physical_components(self):
“”"
“”"
return create_e_list(self.get_java_object().getDeployedPhysicalComponents, PhysicalComponent)
def get_allocated_physical_functions(self):
“”"
“”"
return create_e_list(self.get_java_object().getAllocatedPhysicalFunctions, PhysicalFunction)

I have been implementing it two ways, the above error was without the create elist part and now that i added the elist part i am getting the error as shown below:

<class ‘main.JavaList’>
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “L/Python4Capella/sample_scripts/FFMEAExportPhysicalComponentScript.py”, line 348, in
if k.startswith(‘EASE’) or ((not k.startswith('’)) and (not k.startswith(‘pyease’)) and (not v.class.module.startswith(‘py4j.’)) and (not hasattr(v, ‘ease’)) and (not v.class.name == ‘module’))
File “L/Python4Capella/sample_scripts/FFMEAExportPhysicalComponentScript.py”, line 285, in main
File “L/Python4Capella/sample_scripts/FFMEAExportPhysicalComponentScript.py”, line 161, in PhysicalFunctionName
‘’’
File “L/Python4Capella/java_api/Java_API.py”, line 40, in iter
_pyease_integer_types = (int, long)
AttributeError: ‘JavaMember’ object has no attribute ‘iterator’

You are missing “()” after the java call:

get_java_object().getDeployedPhysicalComponents().
get_java_object().getAllocatedPhysicalFunctions().

This should fix your issue.

is it friday yet? thankyou so much for your help. I’m so sorry for the trouble. I hope you have a good weekend

No problem, obviously something is missing in the API on our side. I opened a issue:

1 Like