GithubHelp home page GithubHelp logo

Comments (19)

aklish avatar aklish commented on May 26, 2024

Spring 3.X only works with Elide 7 onwards.

from elide.

tzhao avatar tzhao commented on May 26, 2024

I tried Elide 7, but it still doesn't work. Is there any newer elide-spring-boot-starter which compatible with 3.x?

from elide.

tzhao avatar tzhao commented on May 26, 2024

11-03-2023 11:57:05.857 [restartedMain] ERROR SpringApplication.reportFailure - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.yahoo.elide.spring.controllers.JsonApiController' defined in BeanDefinition defined in null: Unexpected AOP exception
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293)
at gov.nih.gov.ncats.ifx.pounce.PounceApiApplication.main(PounceApiApplication.java:12)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception
at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:222)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:158)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.scope.ScopedProxyFactoryBean.setBeanFactory(ScopedProxyFactoryBean.java:115)
at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.setBeanFactory(GenericScope.java:448)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1783)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1750)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
... 20 common frames omitted
Caused by: java.lang.ClassCastException: class com.yahoo.elide.spring.controllers.JsonApiController$$SpringCGLIB$$0 cannot be cast to class org.springframework.cglib.proxy.Factory (com.yahoo.elide.spring.controllers.JsonApiController$$SpringCGLIB$$0 and org.springframework.cglib.proxy.Factory are in unnamed module of loader 'app')
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:91)
at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:213)
... 27 common frames omitted

from elide.

aklish avatar aklish commented on May 26, 2024

from elide.

tzhao avatar tzhao commented on May 26, 2024

I tried but got error: Could not find artifact com.yahoo.elide:elide-spring-boot-starter:jar:7.0.0-RC7-SNAPSHOT
(Could not find artifact com.yahoo.elide:elide-spring-boot-starter:jar:7.0.0-RC7-SNAPSHOT in com.yahoo.elide (https://github.com/yahoo/elide/tree/elide-7.x/elide-spring/elide-spring-boot-starter))
Any suggestions and pom.xml examples are highly appreciated!

from elide.

aklish avatar aklish commented on May 26, 2024

from elide.

tzhao avatar tzhao commented on May 26, 2024

@aklish I used latest version 7.0.0-pr2 in https://mvnrepository.com/artifact/com.yahoo.elide/elide-core, but still got error:

Caused by: java.lang.ClassCastException: class com.yahoo.elide.spring.controllers.JsonApiController$$SpringCGLIB$$0 cannot be cast to class org.springframework.cglib.proxy.Factory (com.yahoo.elide.spring.controllers.JsonApiController$$SpringCGLIB$$0 and org.springframework.cglib.proxy.Factory are in unnamed module of loader 'app')
	at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:91)
	at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:213)
	... 27 common frames omitted

from elide.

aklish avatar aklish commented on May 26, 2024

from elide.

tzhao avatar tzhao commented on May 26, 2024

We're unable to move forward until this problem is resolved, I really appreciate your help!

from elide.

aklish avatar aklish commented on May 26, 2024

from elide.

justin-tay avatar justin-tay commented on May 26, 2024

I didn't investigate this fully but this seems to be caused by Spring Boot Dev Tools and the fact that the controllers are annotated @Configuration which also creates a proxy by default. I don't think that the @Configuration annotations on the controllers are necessary and removing them seems to solve the issue.

If you need a quick fix removing Spring Boot Dev Tools also makes the problem go away.

from elide.

tzhao avatar tzhao commented on May 26, 2024

Thank you so much @justin-tay . After removing Spring Boot Dev Tools, I got another error:

required a bean of type 'com.yahoo.elide.graphql.QueryRunners' that could not be found.
Action:

Consider defining a bean of type 'com.yahoo.elide.graphql.QueryRunners' in your configuration.

We are eagerly awaiting your new release. I have developed a strong affinity for Elide, and would prefer not to part ways with it as we embark on our new project. Thank you again!

from elide.

justin-tay avatar justin-tay commented on May 26, 2024

Are you using the code at https://github.com/yahoo/elide-spring-boot-example/tree/elide-7.x to test?

You should have that bean in @RefreshScope if elide.graphql.enabled is set to true.

from elide.

aklish avatar aklish commented on May 26, 2024

So I tried 3.0.4 spring tonight with the elide-7.x branch of the elide-spring-boot-example repo. I wasn't able to reproduce this problem. The project launched and everything seems to check out fine. I bumped the elide-7.x branch to now use 3.0.4 spring.

I suspect there is something else going on with your pom that is different than the example project?

from elide.

tzhao avatar tzhao commented on May 26, 2024

@aklish and @justin-tay , thank you so much for your assistance! Could you please review the following code snippet (Springboot 3.0.4 and Elide 7.0.0-pr2, the GraphqlController used for intercepting the incoming requests), as well as the error message below? I would greatly appreciate any suggestions you may have.

Parameter 0 of constructor in a.b.c.GraphqlController required a bean of type 'com.yahoo.elide.graphql.QueryRunners' that could not be found.
Action: Consider defining a bean of type 'com.yahoo.elide.graphql.QueryRunners' in your configuration.
@Hidden
@RefreshScope
@Configuration
@RestController
@RequestMapping(value = "${elide.graphql.path}")
@ConditionalOnExpression("!${elide.graphql.enabled}")
@EnableConfigurationProperties(ElideConfigProperties.class)
public class GraphqlController {
	 
    private final QueryRunners runners;    
    private final ElideConfigProperties settings;    
    private final HeaderUtils.HeaderProcessor headerProcessor;       

    @Autowired
    public GraphqlController(QueryRunners runners, JsonApiMapper jsonApiMapper,
            HeaderUtils.HeaderProcessor headerProcessor, ElideConfigProperties settings) {
                this.runners = runners;
                this.settings = settings;
                this.headerProcessor = headerProcessor;
        }
    }

from elide.

justin-tay avatar justin-tay commented on May 26, 2024

I think it would be helpful to understand what you are trying to do as that snippet looks a little different from the one from the auto configuration. The auto configuration will already take care of creating the GraphqlController so are you attempting to define your own? If you aren't using the example at https://github.com/yahoo/elide-spring-boot-example/tree/elide-7.x then a small reproducer project would be easier to understand.

The message just says you are missing a com.yahoo.elide.graphql.QueryRunners in the application context.

If you were using the ElideAutoConfiguration this should have been automatically created for you

@Configuration
@ConditionalOnProperty(name = "elide.graphql.enabled", havingValue = "true")
public static class GraphQLConfiguration {
@Bean
@RefreshScope
@ConditionalOnMissingBean
public QueryRunners getQueryRunners(RefreshableElide refreshableElide) {
return new QueryRunners(refreshableElide);
}
}
.

from elide.

tzhao avatar tzhao commented on May 26, 2024

Our GraphqlController intercepts GraphQL queries for logging. monitoring, security etc. We discovered that on the Dev environment, the configuration file had mistakenly set 'elide.graphql.enabled' to false. After correcting this, the issue was resolved. Thank you very much for your assistance!
Go Elied!

from elide.

justin-tay avatar justin-tay commented on May 26, 2024

Looking at the @ConditionalOnExpression("!${elide.graphql.enabled}") annotation on your custom GraphqlController setting elide.graphql.enabled to true enabled the default auto configuration GraphqlController but disabled your custom GraphqlController.

You might want to consider leaving it as false and just setting your own configuration for QueryRunners.

@Configuration
public class GraphqlConfiguration {
     @Bean 
     @RefreshScope 
     public QueryRunners getQueryRunners(RefreshableElide refreshableElide) { 
         return new QueryRunners(refreshableElide); 
     } 
}

from elide.

tzhao avatar tzhao commented on May 26, 2024

Great idea! Thank you @justin-tay

from elide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.