2

Whole magic here what it crashes only on linux\server\laptop machine and perfectly working(autowiring) on mac. I have

@EnableWebSocketMessageBroker
@Configuration
public class WebSocketConfiguration extends AbstractWebSocketMessageBrokerConfigurer {

@Autowired
private A a;

@Autowired
private B b;

@Autowired
private C c;

@Autowired
private D d;

....

}

if one of these classes (for example C) have

@Autowired
private SimpMessagingTemplate simpMessagingTemplate;

then C becames null on WebSocketConfiguration and all following classes also becames as null (D class in current example also. So order important here)

Interesting what on Mac laptops it works perfectly but on server and my linux laptop I have troubles.

Also within A,B,C,D classes have references to each other (circular dependencies autowiring) but as I understand Spring have to resolve it very easy.

If I remove @Autowire from SimpMessagingTemplate all classes load perfectly and works.

What might be a problem here?

0dd_b1t
  • 568
  • 3
  • 15
  • 29
  • How are you starting things on the Mac and on your Linux machines? `mvn spring-boot:run`? `java -jar application.jar`? Or through the IDE? Are you using the same JVMs? Linux usually ships OpenJDK and not the Oracle one. Do a `java -version` on both and compare the output. – daniel.eichten Aug 27 '15 at 08:18
  • @hrrgttnchml i use only oracle JDK and on mac and linux we have similar versions. Starting application on Mac from IDE, on linux also from java -jar application.jar – 0dd_b1t Aug 27 '15 at 10:31
  • 1
    Hmm, do you have maybe a dependency which is marked as provided and missing in the jar but present on the classpath? – daniel.eichten Aug 27 '15 at 10:35
  • Or are you maybe injecting the beans with a conditional? – daniel.eichten Aug 27 '15 at 10:35
  • @hrrgttnchml good idea! Later I will look and check this. Thanks! – 0dd_b1t Aug 28 '15 at 17:41

1 Answers1

1

Found solution after 3 days of research.

Ive moved SimpMessagingTemplate to configuration class and use PostConstruct to set it to other beans.

Looks like here exist some order in beans initializations.

0dd_b1t
  • 568
  • 3
  • 15
  • 29