Error to export MPP


#1

Hi,

Error to export MPP using aspose tasks for Java:
project.save(file.getAbsolutePath(), SaveFileFormat.MPP);

java.lang.NoSuchMethodError: com.aspose.tasks.ExtendedAttributeDefinitionCollection.sort(Ljava/util/Comparator;)V
at com.aspose.tasks.atc.a(Unknown Source)
at com.aspose.tasks.azf.a(Unknown Source)
at com.aspose.tasks.avf.k(Unknown Source)
at com.aspose.tasks.azf.l(Unknown Source)
at com.aspose.tasks.azf.a(Unknown Source)
at com.aspose.tasks.cer.a(Unknown Source)
at com.aspose.tasks.cer.a(Unknown Source)
at com.aspose.tasks.Project.save(Unknown Source)


#2

@jexperts

It is requested to kindly share sample MPP file and please also mention which version of our API are you using so that we could investigate the issue in detail.

Moreover, You may share confidential file in a private message and the files shared in private message shall only be accessible to Aspose staff. For this purpose, please find “Message” button by clicking on my name.


#3

It happens in Java 7
Java version: 7
Aspose version: 18.11 - jdk17
MPP_TEMPLATE.mpp.zip (25.6 KB)

Code:

URL urlTemplate = TestResource.class.getResource("MPP_TEMPLATE.mpp");
Project project = new Project(urlTemplate.getPath());
project.set(Prj.DURATION_FORMAT, TimeUnitType.Hour);
project.setCalculationMode(CalculationMode.None);
Task parentTask = project.getRootTask();
Task taskA = parentTask.getChildren().add("A");
project.setCalculationMode(CalculationMode.None);
taskA.set(Tsk.ID, 1);
taskA.set(Tsk.UID, 1);
taskA.set(Tsk.START, DF.parse("21/12/2018 08:00"));
taskA.set(Tsk.FINISH, DF.parse("21/12/2018 17:00"));
taskA.set(Tsk.CONSTRAINT_TYPE, ConstraintType.StartNoEarlierThan);
taskA.set(Tsk.CONSTRAINT_DATE, DF.parse("21/12/2018 08:00"));
taskA.set(Tsk.DURATION, project.getDuration(8d));
taskA.set(Tsk.DURATION_FORMAT, TimeUnitType.Hour);
taskA.set(Tsk.TYPE, TaskType.FixedDuration);
taskA.set(Tsk.OUTLINE_LEVEL, 1);

ExtendedAttribute ea = new ExtendedAttribute();
ExtendedAttributeDefinition ead = 
ExtendedAttributeDefinition.createTaskDefinition(CustomFieldType.Text, 
ExtendedAttributeTask.Text10, "Test");
ea.setAttributeDefinition(ead);
ea.setFieldId(ead.getFieldId());
ea.setValue("1");
project.getExtendedAttributes().add(ead);
taskA.getExtendedAttributes().add(ea);


ExtendedAttributeDefinition eadR = ExtendedAttributeDefinition.createResourceDefinition(CustomFieldType.Text, ExtendedAttributeResource.Text10, "1");
ExtendedAttribute eaR = new ExtendedAttribute();
eaR.setAttributeDefinition(eadR);
eaR.setFieldId(eadR.getFieldId());
eaR.setValue("1");

Resource resource = project.getResources().add("Resource A");
resource.getExtendedAttributes().add(eaR);
ResourceAssignment ra = project.getResourceAssignments().add(taskA, resource);
ra.set(Asn.UNITS, 1d);
taskA.set(Tsk.WORK, project.getDuration(8d));
project.setCalculationMode(CalculationMode.Automatic);
try {
	project.recalculate();
} catch (Exception e) {
	e.printStackTrace();
}
project.save("mpp_test.mpp", SaveFileFormat.MPP);

#4

@jexperts

We have tested the code with Aspose.Tasks for Java 18.11 version and found the issue with resource assignment. We have made some modifications in the code, please have a look:

Project project = new Project(urlTemplate);
project.set(Prj.DURATION_FORMAT, TimeUnitType.Hour);
project.setCalculationMode(CalculationMode.None);
Task parentTask = project.getRootTask();
Task taskA = parentTask.getChildren().add("A");
project.setCalculationMode(CalculationMode.None);
taskA.set(Tsk.ID, 1);
taskA.set(Tsk.UID, 1);
        
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.set(2018,12,21,8,0,0);
        
java.util.Calendar calE = java.util.Calendar.getInstance();
cal.set(2018,12,21,17,0,0);
        
project.set(Prj.START_DATE, cal.getTime());
project.set(Prj.FINISH_DATE, calE.getTime());
project.set(Prj.DEFAULT_START_TIME, project.get(Prj.START_DATE));
project.set(Prj.DEFAULT_TASK_TYPE, TaskType.FixedDuration);
taskA.set(Tsk.CONSTRAINT_TYPE, ConstraintType.StartNoEarlierThan);
taskA.set(Tsk.CONSTRAINT_DATE, cal.getTime());
taskA.set(Tsk.DURATION, project.getDuration(8d));
taskA.set(Tsk.DURATION_FORMAT, TimeUnitType.Hour);
taskA.set(Tsk.TYPE, TaskType.FixedDuration);
taskA.set(Tsk.OUTLINE_LEVEL, 1);

Resource resource = project.getResources().add("Resource A");
ResourceAssignment ra = project.getResourceAssignments().add(taskA, resource);
ResourceAssignment assignment = project.getResourceAssignments().get(0);
        
ExtendedAttributeDefinition ead = ExtendedAttributeDefinition.createTaskDefinition(CustomFieldType.Text, 
ExtendedAttributeTask.Text10, "Test");
project.getExtendedAttributes().add(ead);

ExtendedAttribute value = ead.createExtendedAttribute();
value.setTextValue("1");

assignment.getExtendedAttributes().add(value);
ra.set(Asn.UNITS, 1d);
taskA.set(Tsk.WORK, project.getDuration(8d));
project.setCalculationMode(CalculationMode.Automatic);

Moreover, it is recommended to use the latest available version of our API and you may get more details regarding adding extended attributes to resource assignment at this link: https://docs.aspose.com/display/tasksjava/Adding+Extended+Attributes+to+Resource+Assignments

Please feel free to write back to us if you need additional information or if you have any further queries.


#5

It’s not working in Java version 7 on save:

project.save("test.mpp", SaveFileFormat.MPP);

Please, do tests in Java 7.


#6

@jexperts

Thank you for your feedback.

We test with latest available version of our API and it is recommended to use upgraded version of API.


#7

Hi @MuzammilKhan,

We are testing with latest available version of Aspose Tasks for Java: 18.11

Repeating, this error happens only using Java 7 (1.7) . Please, do tests of code using Java JDK 7 (1.7).


#8

@jexperts

We are sorry for inconvenience, this issue has been logged with ID “TASKSJAVA-818” for further investigation. You will automatically be informed here once we have more information to share with you.


#9

Any news?

This is of the utmost importance to our customers.


#10

@jexperts,

I have verified the issue status from our issue tracking system and regret to share that at present the issue is still unresolved. We request for your patience till the time the issue gets resolved and further feedback is shared.


#11

The issues you have found earlier (filed as TASKSJAVA-818) have been fixed in this update.