Reputation: 964
Something goes wrong in my code at runtime. I implemented SOAP client using apache CXF. I created the endpoint via JaxWsProxyFactoryBean
. Here is my code:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(MYAPI.class);
factory.setAddress(service);
api = (MYAPI) factory.create();
First time when I implemented it, it worked well, so I decided to do some refactoring, (move stub classes in different package, API interface in another and, so on...) When I built it again and run it, something wrong happens. The application fail's with java.lang.StackOverflowError
at api = (MYAPI) factory.create();
Here is the stackTrace:
Thread [main] (Suspended (exception StackOverflowError))
ReflectionUtil.getDeclaredFields(Class<?>) line: 169
JAXBContextInitializer.walkReferences(Class<?>) line: 395
JAXBContextInitializer.addClass(Class<?>) line: 317
JAXBContextInitializer.addType(Type, boolean) line: 236
JAXBContextInitializer.addType(Type) line: 226
JAXBContextInitializer.walkReferences(Class<?>) line: 424
JAXBContextInitializer.addClass(Class<?>) line: 317
JAXBContextInitializer.addType(Type, boolean) line: 236
JAXBContextInitializer.addType(Type) line: 226
JAXBContextInitializer.walkReferences(Class<?>) line: 424
JAXBContextInitializer.addClass(Class<?>) line: 317
JAXBContextInitializer.addType(Type, boolean) line: 236
JAXBContextInitializer.addType(Type) line: 226
JAXBContextInitializer.walkReferences(Class<?>) line: 424
JAXBContextInitializer.addClass(Class<?>) line: 317
JAXBContextInitializer.addType(Type, boolean) line: 236
JAXBContextInitializer.addType(Type) line: 226
JAXBContextInitializer.walkReferences(Class<?>) line: 424
JAXBContextInitializer.addClass(Class<?>) line: 317
JAXBContextInitializer.addType(Type, boolean) line: 236
JAXBContextInitializer.addType(Type) line: 226
JAXBContextInitializer.walkReferences(Class<?>) line: 424
JAXBContextInitializer.addClass(Class<?>) line: 317
JAXBContextInitializer.addType(Type, boolean) line: 236
JAXBContextInitializer.addType(Type) line: 226
JAXBContextInitializer.walkReferences(Class<?>) line: 424
JAXBContextInitializer.addClass(Class<?>) line: 317
....
Can anyone help me to solve this issue? I don't know what is the problem. I founded that is may be a problem to use JAVA 8 to build CXF, but I am with version 3.1.7 and I also tried to build it with Java 7, (because I don't have Java 8 specific implementations), run it and the same issue happened again.
Upvotes: 2
Views: 1034
Reputation: 39301
(solved in comments) It seems a circular reference where a JAXB class is charging itself recursively producing a stack overflow.
Actions
Have you refactored? Go back and do it step by step. If you can't, then try to detect the service and classes that are causing the problem, for example removing service method until error is not raised.
Solution (as @AleydinKaraimin commented)
CXF generated 2 classes with the same name and the first has field that refer to the second, but after refactoring Move in another package, it became to refer to itself and because of the implementation logic it load it again and again.
Upvotes: 2