M
M
mechanicnikodimich2016-06-21 19:04:00
Java
mechanicnikodimich, 2016-06-21 19:04:00

Error in jboss.logging?

Good afternoon.
I'm trying to run a class.
POM.xml

<dependencies>

    <!--hibernate -->

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-c3p0</artifactId>
      <version>5.1.0.Final</version>
      <exclusions>
        <exclusion>
          <groupId>org.jboss.logging</groupId>
          <artifactId>jboss-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.hibernate.common</groupId>
      <artifactId>hibernate-commons-annotations</artifactId>
      <version>5.0.1.Final</version>
      <exclusions>
        <exclusion>
          <groupId>org.jboss.logging</groupId>
          <artifactId>jboss-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>5.1.0.Final</version>
      <exclusions>
        <exclusion>
          <groupId>org.jboss.logging</groupId>
          <artifactId>jboss-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>5.1.0.Final</version>
      <exclusions>
        <exclusion>
          <groupId>org.jboss.logging</groupId>
          <artifactId>jboss-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Spring -->

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>4.2.5.RELEASE</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>4.2.5.RELEASE</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>4.2.5.RELEASE</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- thymeleaf -->


    <dependency>
      <groupId>org.thymeleaf</groupId>
      <artifactId>thymeleaf-spring4</artifactId>
      <version>3.0.0.RELEASE</version>
    </dependency>

    <!-- hibernate additional -->
  
    <dependency>
      <groupId>org.jboss.logging</groupId>
      <artifactId>jboss-logging</artifactId>
      <version>3.3.0.Final</version>
    </dependency>
    
    <dependency>
    <groupId>jboss</groupId>
    <artifactId>jboss-common</artifactId>
    <version>4.2.2.GA</version>
</dependency>
    
    <dependency>
      <groupId>antlr</groupId>
      <artifactId>antlr</artifactId>
      <version>2.7.7</version>
    </dependency>

    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.2</version>
    </dependency>

    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>
    </dependency>

    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm</artifactId>
      <version>3.3.1</version>
    </dependency>

    <dependency>
      <groupId>cglib</groupId>
      <artifactId>cglib</artifactId>
      <version>3.2.2</version>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.21</version>
    </dependency>

    <dependency>
      <groupId>com.sun.xml.messaging.saaj</groupId>
      <artifactId>saaj-impl</artifactId>
      <version>1.3.4</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
    
    <!-- ojdbc6 -->
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc6</artifactId>
      <version>11.2.0.3</version>
    </dependency>

    <!-- jackson -->

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.4.1</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.4.1.1</version>
    </dependency>

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
      <version>1.9.13</version>
    </dependency>

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.13</version>
    </dependency>

    <!-- junit -->

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>

    <!-- gson -->

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.6.2</version>
    </dependency>


    <!-- apache -->


    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>2.5</version>
    </dependency>
    
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>2.5</version>
    </dependency>


    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-dbcp2</artifactId>
      <version>2.0</version>
    </dependency>

  </dependencies>

OrganizationInfoTest.java

@WebAppConfiguration
@ContextConfiguration(classes=AppConfig.class)
public class OrganizationInfoTest extends AbstractTransactionalJUnit4SpringContextTests {
  
    @Autowired
    private OrganizationService organizationService;
  

      @Test
      @Rollback(false)
      
      public void organizationInfoTest() {
      	OrganizationInfo oivid = new OrganizationInfo();
        	List<Agentlist> org=organizationService.getAll();
      	for (int i =0; i<org.size(); i++) {
      		System.out.println(org.get(i).getName()+" id: "+org.get(i).getAgentlistId());
      			System.out.println("22");
      	}  
     	 
  } 
}

AppConfig
@Configuration
@EnableWebMvc
@ComponentScan({"org.pmo.sti", "org.pmo.web","org.pmo.tests"})
@EnableTransactionManagement
public class AppConfig extends WebMvcConfigurerAdapter {
  
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/app/css/**").addResourceLocations("/APM/app/css/").setCachePeriod(31556926);
        registry.addResourceHandler("/node_modules/**").addResourceLocations("/APM/node_modules/").setCachePeriod(31556926);
        registry.addResourceHandler("/config/**").addResourceLocations("/APM/config/").setCachePeriod(31556926); 
        
    }
  @Bean(name = "dataSource")
    public DataSource getDataSource() {
    	BasicDataSource dataSource = new BasicDataSource();
    	dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
    	dataSource.setUrl("jdbc:oracle:thin:@192.168.1.11:1521:******");
    	dataSource.setUsername("******");
    	dataSource.setPassword("******");
   
    	return dataSource;
    }
    
    
    private Properties getHibernateProperties() {
    	Properties properties = new Properties();
    	properties.put("hibernate.show_sql", "true");
    	properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
    	
    	return properties;
    }
    
    @Autowired
    @Bean(name = "sessionFactory")
    public SessionFactory getSessionFactory(DataSource dataSource) {
    	LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);

    	sessionBuilder.addProperties(getHibernateProperties());
    	sessionBuilder.addAnnotatedClasses(Agentlist.class,OrganizationInfo.class,ClassificationData.class,RegistrationData.class);
    	sessionBuilder.addAnnotatedClasses(AreasOfMedicalCare.class);
    	
    	return sessionBuilder.buildSessionFactory();
    }
    
  @Autowired
  @Bean(name = "transactionManager")
  public HibernateTransactionManager getTransactionManager(
      SessionFactory sessionFactory) {
    HibernateTransactionManager transactionManager = new HibernateTransactionManager(
        sessionFactory);
    return transactionManager;
  }
}

As a result, an error occurs when running the test class.
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
  at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)

At the same time, when the MainController class is launched, everything works fine.
@Controller
@ContextConfiguration(classes=AppConfig.class)
public class MainController {

  @Autowired
  private OrganizationService organizationService;
  
  @RequestMapping(value = "/org", method = RequestMethod.GET)
  public ModelAndView getOrganization() {
    
    List<Agentlist> orgs =  organizationService.getAll();
    System.out.println("Size: "+orgs.size());
    ModelAndView mav = new ModelAndView("index");
    mav.addObject("orgs", org);
    return mav;

  }
}

What could be the snag, help kind people!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kosarev, 2016-06-22
@jaxtr

This is because you have both jboss-common and jboss-logging in your dependencies. Both artifacts contain the org.jboss.logging.Logger class, but with different descriptions.
And I advise you to remove unnecessary dependencies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question