• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NoSuchField: logger from AnnotationConfigApplicationContext

 
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am running an example in ch 9 of Getting started with Springframework 4th edition:

pom.xml



NFO  org.springframework.context.annotation.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@3ecd23d9: startup date [Sat Jul 14 18:58:26 EDT 2018]; root of context hierarchy
Exception in thread "main" java.lang.NoSuchFieldError: logger
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:87)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at sample.spring.chapter09.bankapp.BankApp.main(BankApp.java:24)



The exception is thrown from the context.refresh. Please help.
fileStructure.JPG
[Thumbnail for fileStructure.JPG]
file structure
 
Himai Minh
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me answer my own question.
I first created the QBankAccountDetails.java and QFixedDepositDetails.java and their classes by adding the dependencies below and changed the plugins:
In pom.xml:


...
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId>
<version>3.6.6</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>3.7.4</version>
</dependency>
.....
<build>
<plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
                                                    <outputDirectory>target/generated-sources/java</outputDirectory>
  <processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>



Download Apache Maven. Set the path variables as instructed by MKyong (https://www.mkyong.com/maven/how-to-install-maven-in-windows/).
In a command prompt, navigate to the ch09-spring-mongo-data project folder. Type mvn compile. This can generate the Q-classes and java code in the target/generated-sources/java.
Copy the Q-classes , in this case, QBankAccountDetail.java  and QFixedDepositDetails.java to the corresponding package.

Close and delete the ch09-spring-mongo-data project from the Eclipse workspace. Open the original project with the original pom.xml file. Copy the Q classes to the corresponding package in the original project.
Now, the original project can compile with the Q classes.
Install MongoDB community instruction and follow their instruction to run it.
Run the BankApp.java from the original project. It should work.
 
reply
    Bookmark Topic Watch Topic
  • New Topic