Dubbo: jdk11, No application config found or it's not a valid config!

Created on 25 Feb 2020  ·  8Comments  ·  Source: apache/dubbo


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

<dubbo:reference id="twoservice" interface="com.zzq.dubbo.service.MyDubboService" url="dubbo://localhost:20880"/>

Expection:
No application config found or it's not a valid config! Please add to your spring config.

debug中 org.apache.dubbo.config.ApplicationConfig#isValid()-----name是null

Most helpful comment

@chickenlj I investigate the issue in jdk11 , It's becase of @PostConstruct (javax.annotation.PostConstruct)

in I can't use @PostConstruct and @PostDestroy with Java 11

Note that both @PostConstruct and @PreDestroy annotations are part of Java EE. And since Java EE has been deprecated in Java 9 and removed in Java 11 we have to add an additional dependency to use these annotations:

however , application name inject by

@Parameter(key = APPLICATION_KEY, required = true, useKeyAsProperty = false)
    public String getName() {
        return name;
    }

and in AbstractConfig.java

    @PostConstruct
    public void addIntoConfigManager() {
        ApplicationModel.getConfigManager().addConfig(this);
    }

this method won't be invoked , so It's will throw

No application config found or it's not a valid config! Please add to your spring config.

ConfigValidationUtils .java

  if (!config.isValid()) {
            throw new IllegalStateException("No application config found or it's not a valid config! " +
                    "Please add <dubbo:application name=\"...\" /> to your spring config.");
        }

I try to add dependency to my project

<dependency>
         <groupId>javax.annotation</groupId>
         <artifactId>javax.annotation-api</artifactId>
         <version>1.3.2</version>
</dependency>

it works .

So... do you have some advice to resolve it ?

All 8 comments

@zzqsy I could not reproduce this problem in a local test.

This’s configure of my project name=”spring-dubbo-consumer.xml”


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

<dubbo:reference id="twoservice" interface="com.zzq.dubbo.service.MyDubboService" url="dubbo://localhost:20880"/>

Function main

package com.zzq.spring.dubbo.consumer;

import com.zzq.dubbo.service.MyDubboService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ConsumerMain {
public static void main(String[] args) {

    ApplicationContext context=new ClassPathXmlApplicationContext("spring-dubbo-consumer.xml");
    MyDubboService oneservice = (MyDubboService) context.getBean("twoservice");
    String zzq = oneservice.getString("zzq");
    System.out.println(zzq);
}

}

Exception:
Exception in thread "main" java.lang.IllegalStateException: No application config found or it's not a valid config! Please add to your spring config.
at org.apache.dubbo.config.utils.ConfigValidationUtils.validateApplicationConfig(ConfigValidationUtils.java:371)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.checkGlobalConfigs(DubboBootstrap.java:529)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.initialize(DubboBootstrap.java:514)
at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:698)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:52)
at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:45)
at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:85)
at com.zzq.spring.dubbo.consumer.ConsumerMain.main(ConsumerMain.java:15)

[cid:[email protected]]



org.apache.dubbo
dubbo
2.7.5

2.7.4.1 is normal, but change to 2.7.5 is abnormal

Is it my configuration problem?

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用

发件人: jiminnotifications@github.com
发送时间: 2020年3月2日 1:18
收件人: apache/dubbodubbo@noreply.github.com
抄送: zzqsyzhuzhenqiang@outlook.com; Mentionmention@noreply.github.com
主题: Re: [apache/dubbo] 2.7.5版本无法读取到xml文件中的dubbo:application名 (#5793)

@zzqsyhttps://github.com/zzqsy I could not reproduce this problem in a local test.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/apache/dubbo/issues/5793?email_source=notifications&email_token=AEPAY3EFBSICDUS7XJZZGQDRFKKETA5CNFSM4K25A4SKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENNE4RA#issuecomment-593120836, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEPAY3D3MB2MWZW7W27S7XTRFKKETANCNFSM4K25A4SA.

OK!!! change the jdk version form 11 to 8 it’s normal

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: jimin notifications@github.com
发送时间: Monday, March 2, 2020 1:18:01 AM
收件人: apache/dubbo dubbo@noreply.github.com
抄送: zzqsy zhuzhenqiang@outlook.com; Mention mention@noreply.github.com
主题: Re: [apache/dubbo] 2.7.5版本无法读取到xml文件中的dubbo:application名 (#5793)

@zzqsyhttps://github.com/zzqsy I could not reproduce this problem in a local test.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/apache/dubbo/issues/5793?email_source=notifications&email_token=AEPAY3EFBSICDUS7XJZZGQDRFKKETA5CNFSM4K25A4SKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENNE4RA#issuecomment-593120836, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEPAY3D3MB2MWZW7W27S7XTRFKKETANCNFSM4K25A4SA.

Thanks for the feedback. We'll look at the jdk11 issue.

Thanks for the feedback. We'll look at the jdk11 issue.

@chickenlj I investigate the issue in jdk11 , It's becase of @PostConstruct (javax.annotation.PostConstruct)

in I can't use @PostConstruct and @PostDestroy with Java 11

Note that both @PostConstruct and @PreDestroy annotations are part of Java EE. And since Java EE has been deprecated in Java 9 and removed in Java 11 we have to add an additional dependency to use these annotations:

however , application name inject by

@Parameter(key = APPLICATION_KEY, required = true, useKeyAsProperty = false)
    public String getName() {
        return name;
    }

and in AbstractConfig.java

    @PostConstruct
    public void addIntoConfigManager() {
        ApplicationModel.getConfigManager().addConfig(this);
    }

this method won't be invoked , so It's will throw

No application config found or it's not a valid config! Please add to your spring config.

ConfigValidationUtils .java

  if (!config.isValid()) {
            throw new IllegalStateException("No application config found or it's not a valid config! " +
                    "Please add <dubbo:application name=\"...\" /> to your spring config.");
        }

I try to add dependency to my project

<dependency>
         <groupId>javax.annotation</groupId>
         <artifactId>javax.annotation-api</artifactId>
         <version>1.3.2</version>
</dependency>

it works .

So... do you have some advice to resolve it ?

I have a workaround , above jdk9 , It introduces "JEP 238: Multi-Release JAR Files"

A multi-release JAR ("MRJAR") will contain additional directories for classes and resources specific to >particular Java platform releases. A JAR for a typical library might look like this:

jar root

  • A.class
  • B.class
  • C.class
  • D.class
    Suppose there are alternate versions of A and B that can take advantage of Java 9 features. We can bundle them into a single JAR as follows:

jar root

  • A.class
  • B.class
  • C.class
  • D.class
  • META-INF

    • versions



      • 9





        • A.class



        • B.class






When I use jdk8,it worked.Thanks.

Was this page helpful?
0 / 5 - 0 ratings