mtedone / podam

PODAM - POjo DAta Mocker
https://mtedone.github.io/podam
MIT License
323 stars 750 forks source link

NullExternalFactory - Cannot instantiate class #257

Closed mubasherusman closed 6 years ago

mubasherusman commented 6 years ago

Hello, I have simple Pojo Graph.

PersonalInfo {
int ID,
String Name,
Set<Address> address = new HashSet<Address>(0);
City city ;
...
}

There is lot of custom objects.

So I am getting the following Excepions

2018-02-20 14:09:28.000 INFO 67284 --- [nio-9090-exec-2] o.s.c.s.ClassPathXmlApplicationContext : Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1f2bf318: startup date [Tue Feb 20 14:09:27 PKT 2018]; root of context hierarchy 2018-02-20 14:09:28.055 INFO 67284 --- [nio-9090-exec-2] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [META-INF/spring/podam.xml] 14:09:59.371 [http-nio-9090-exec-2] WARN uk.co.jemos.podam.api.PodamFactoryImpl - Loop in class com.vend.sb.commons.model.PersonalInformation production detected. Resorting to uk.co.jemos.podam.api.NullExternalFactory external factory

Here is my usage

PodamFactory factory = new PodamFactoryImpl(); PersonalInformation pInformation = factory.manufacturePojo(PersonalInformation.class);

What is wrong or What is missing?

I am using Latest Release Version.

daivanov commented 6 years ago

Hi,

These are log lines, there are no exceptions.

Thanks, Daniil

mubasherusman commented 6 years ago

But My code get into infinite loop.

daivanov commented 6 years ago

Your original post tells that you cannot instantiate class because of exceptions with providing log, which contains no exceptions. Now you say there is infinite loop in your code. There is not much I can do about it.

mubasherusman commented 6 years ago

When This line factory.manufacturePojo(PersonalInformation.class);

executes, It get into infinite loop and constantly logging following log. I waiting about 10 minutes and it still constantly logging again and again same line.

14:09:59.371 [http-nio-9090-exec-2] WARN uk.co.jemos.podam.api.PodamFactoryImpl - Loop in class com.vend.sb.commons.model.PersonalInformation production detected. Resorting to uk.co.jemos.podam.api.NullExternalFactory external factory

daivanov commented 6 years ago

Then I can only guess PersonalInfo contains reference(s) to a list or map of PersonalInfos. Anyhow the process is not infinite. You can reduce depth of filling by overriding DataProviderStrategy.getMaxDepth(), which is 3 by default.

mubasherusman commented 6 years ago

Personal Info do not have any such list which mapped back to itself, however inner objects do have a reference back to PersonalInfo. e.g.

PersonalInfo {
id,
name
ProductDetails  pd;
}

ProductDetails {
id 
name
List <PersonalInfo> list
}
daivanov commented 6 years ago

So you a have a loop PersonalInfo -> ProductDetails -> List. However, this should not result in execution time longer than 10 minutes, unless your hardware is really slow or there is something else in these POJOs taking time to be created.