Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot application with security filter startup fails with 5.0 beta agent #1361

Closed
1 of 4 tasks
gamefundas opened this issue Jun 16, 2018 · 9 comments
Closed
1 of 4 tasks
Assignees
Labels
agent Language agent related. bug Something isn't working and you are sure it's a bug!

Comments

@gamefundas
Copy link

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
  • Question or discussion
  • Bug
  • Requirement
  • Feature or performance improvement

Bug

  • Which version of SkyWalking, OS and JRE?
    Skywalking 5.0 Beta, Amazon Linux, JRE 1.8, Spring Boot 2.0

  • Which company or project?
    Personal research on APM tools

  • What happen?
    If possible, provide a way for reproducing the error. e.g. demo application, component version.
    When the Skywalking java agent is used in my Spring boot 2.0 application I am getting the following error

2018-06-16 17:07:12,956 ERROR ip-10-83-72-93 [main] org.springframework.boot.SpringApplication - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webAuthController': Unsatisfied dependency expressed through bean property 'skyWalkingDynamicField': Set this property value or disable dependency checking for this bean. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies(AbstractAutowireCapableBeanFactory.java:1548) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) at com.myapp.Application.main(Application.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58)


Requirement or improvement

  • Please describe about your requirements or improvement suggestions.
    I am trying to get Skywalking agent up and running for my spring boot application and currently the collector and ui is all set to receive data. However my application startup fails because of the agent library interfering with Spring DI
@wu-sheng wu-sheng added bug Something isn't working and you are sure it's a bug! agent Language agent related. labels Jun 16, 2018
@wu-sheng wu-sheng added this to the 5.0.0-beta2 milestone Jun 16, 2018
@wu-sheng
Copy link
Member

Could you provide a demo application to reproduce the DI failure.

@ascrutae maybe this is springboot 2.0 related?

@gamefundas
Copy link
Author

Not related to SB2 as I am having the same trouble with SB 1.5. The problem lies somewhere in our Spring Security initialization. The web auth module that does JWT auth is failing to initialize when I include the java agent.

Will have to see if I can reproduce this in an example as the application code and security is not shareable.

@gamefundas gamefundas changed the title Spring Boot application startup fails with 5.0 beta agent Spring Boot application with security filter startup fails with 5.0 beta agent Jun 17, 2018
@wu-sheng
Copy link
Member

I can provide this detail to help you guess what is really happening.

Each controller in your application will be added a new field for auto instrumentation, your log has mentioned it. So maybe your applucation security component will check the fields somehow. This is the potential cause.

Of source, skywalking wouldn't add any autoware annotation for that field, that should be normal harmness field. But in your case, it harms.

If you can pinpoint whats codes in your or spring in checking this, and how to check. We can provide more helps.

@wu-sheng wu-sheng removed this from the 5.0.0-beta2 milestone Jun 17, 2018
@gamefundas
Copy link
Author

The above information helps. Let me dig in a little bit on this and then get back on this thread.

In the meantime, would like to know if skywalking can be configured to ignore some of these troublesome classes. For instance in this case the security library is developed by a third party. The application simply includes it in our dependency and plugs the custom JWT authentication.

@gamefundas
Copy link
Author

In our spring security implementation one of the bean post processor does the following to register the auth controller. Now the auth controller is being created with dependencyCheck = true which causes spring to run a dependency check on all properties (objects and primitives). One of the property being "skyWalkingDynamicField" is found to be unset and gets caught.

@OverRide
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException
{
BeanDefinition beanDefinition =
new RootBeanDefinition(AuthorizationController.class,
Autowire.BY_TYPE.value(),
registry.registerBeanDefinition("authController", beanDefinition);
}

I don't see a way to change this common code. Any chance we can configure skywalking to ignore classes for injection.

@wu-sheng
Copy link
Member

I don't see a way to change this common code. Any chance we can configure skywalking to ignore classes for injection.

Do you use a pattern match in SpringMVC? Such as url=product/order/{orderId}? We provide SpringMVC plugin to support this scenario, otherwise, you can simply remove the SpringMVC plugin, Tomcat plugin will do the trace work.

If you are using, we have to change the source codes of SpringMVC, not too hard, but still to change and recompile at your local.

@ascrutae
Copy link
Member

@gamefundas I had been reproduce this issue. I will try to find the cause about this issue.

@ascrutae
Copy link
Member

@gamefundas I had fix this issue in PR #1375

@wu-sheng
Copy link
Member

@gamefundas I think at least #1375 is a conflict with Spring Framework. You could try this by compiling master branch. But be advised, don't try to use collector and UI, there are some incompatible issues for preparing the beta2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent Language agent related. bug Something isn't working and you are sure it's a bug!
Projects
None yet
Development

No branches or pull requests

3 participants