当前位置: 首页 > 知识库问答 >
问题:

Spring框架MVC-Hibernate例外是java。lang.NoSuchMethodError

端木令雪
2023-03-14

我在JavaSpring Framework MVC-Hibernate中发布了有关我的一个项目的问题。请看看我下面的代码和文件。我想问题是由1)一些缺失或错误的依赖关系以及2)Hibernate配置中的一些问题引起的。首先,我感谢您的时间和帮助。格雷格

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory name="">
  <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
  <property name="hibernate.connection.password">adminC</property>
  <property name="hibernate.connection.url">jdbc:jtds:sqlserver://127.0.0.1//SQLEXPRESS:1433;databaseName=perfDatabase;</property>
  <property name="hibernate.connection.username">adminC</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
  <property name="hibernate.validator.apply_to_ddl">false</property> 
<property name="hibernate.validator.autoregister_listeners">false</property>
  <mapping class="com.perfectino.factures.Article"/>
  <mapping class="com.perfectino.factures.Clients"/>
  <mapping class="com.perfectino.factures.Confirmation"/>
  <mapping class="com.perfectino.factures.Providers"/>
 </session-factory>
</hibernate-configuration>
 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.perfectino</groupId>
    <artifactId>factures</artifactId>
    <name>mprojo</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>

        <!-- Logging -->
        <!-- <dependency> -->
        <!-- <groupId>org.slf4j</groupId> -->
        <!-- <artifactId>slf4j-api</artifactId> -->
        <!-- <version>${org.slf4j-version}</version> -->
        <!-- </dependency> -->
        <!-- <dependency> -->
        <!-- <groupId>org.slf4j</groupId> -->
        <!-- <artifactId>jcl-over-slf4j</artifactId> -->
        <!-- <version>${org.slf4j-version}</version> -->
        <!-- <scope>runtime</scope> -->
        <!-- </dependency> -->
        <!-- <dependency> -->
        <!-- <groupId>org.slf4j</groupId> -->
        <!-- <artifactId>slf4j-log4j12</artifactId> -->
        <!-- <version>${org.slf4j-version}</version> -->
        <!-- <scope>runtime</scope> -->
        <!-- </dependency> -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.18.1.GA</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.3.0.Final</version>
        </dependency>
        <dependency>  
      <groupId>org.jboss</groupId>  
      <artifactId>jboss-common-core</artifactId>  
      <version>2.2.16.GA</version>  
      <scope>compile</scope>  
      <exclusions>  
        <exclusion>  
          <artifactId>jboss-logging-spi</artifactId>  
          <groupId>org.jboss.logging</groupId>  
        </exclusion>  
      </exclusions>  
    </dependency>  
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.perfectino</groupId>
    <artifactId>factures</artifactId>
    <name>mprojo</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>5.0.3.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.18.1.GA</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.3.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-common-core</artifactId>
            <version>2.2.16.GA</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>jboss-logging-spi</artifactId>
                    <groupId>org.jboss.logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

我没有找到这个问题的解决办法。

GRAVE: Sontroller.java:104()的servlet[appServlet]在上下文中与路径[/facture]抛出异常[处理程序处理失败;嵌套异常com.perfectino.factures.NoSuchMethod错误:ontroller.addLontroller.java:62MessageLogger(Ljava/lang/Class; Ljava/lang/String;)Ljava/lang/Object;]与根本原因sun.reflect.NoSuchMethod odError:mpl.invokeLsun.reflect.MessageLogger(Ljava/lang/Class; Ljava/lang/String;)Ljava/lang/Object;在mpl.invokeCoreLogging.message记录器(CoreLogging.java:28)在org.hibernate.internal.CoreLogging.message记录器(CoreLogging.java:24)在org.hibernate.cfg.配置。(Configuration.java:86)在com.perfectino.factures.DAOManager.add对象(DAOManager.java:22)在com.perfectino.factures.HelloWorldController.set文章(HelloWorldCervlet.service)在java.lang.HelloWorldCorg.jboss.logging.产品(HelloWorldCogger.get)java.lang.NativemetodAccessorIorg.jboss.logging.0(本机方法)在ogger.getNativemetodAccessorIorg.hibernate.internal.(未知来源)在ServletInvocableHandlerMethod. tnkeAndHandle(ServletInvocableHandlerMethod. java: 96)在org. springframework. web. servlet. mvc. method. annotation。在org. springframe. web. servlet. mvc. method.注释中请求映射处理程序适配器。在org. springframework. web. servlet. mvc.方法中请求映射处理程序适配器。在org. springframe. web. servlet. mvc.方法中的内部(Request estMappingHandlerAdap. java: 578)。在org. springframe. web. servlet中的AbstractHandlerMethod odAdapter. hand(AbstractHandlerMethod odAdapter. java: 80)。在org. springframe. web. servlet中的DispatcherServlet. doDispat(DispatServlet. java: 923)。调度服务器。AbstractHttp11Processor. Process(AbstractHttp11Processor. java: 1041)在org. apache. tomcat. util. net。JIoEndpoint$SocketProcessor. run(JIoEndpoint. java: 312)在java. util. converter。java. util. conflow的ThreadPoolExecitor. runWorker(未知来源)。java. lang的ThreadPoolExecitor$Worker. run(未知来源)。线程. run(未知来源)

GRAVE:Servlet。路径为[/factures]的上下文中的servlet[appServlet]的service()引发了异常[处理程序处理失败;嵌套异常为java.util.ServiceConfigurationError:org.hibernate.boot.registry.selector.StrategyRegistrationProvider:Provider org.hibernate.c3p0.internal.StrategyRegistrationProviderImpl not Founder],根本原因为java。util。ServiceConfigurationError:组织。冬眠靴子注册表。选择器。StrategyRegistrationProvider:提供商组织。冬眠c3p0.内部。在java中找不到StrategyRegistrationProviderImpl。util。ServiceLoader。java失败(未知源)。util。ServiceLoader。访问java的300美元(未知来源)。util。ServiceLoader$LazyIterator。java上的nextService(未知源)。util。ServiceLoader$LazyIterator。java的下一个(未知源)。util。ServiceLoader 1美元。组织的下一个(未知源)。冬眠靴子注册表。类加载。内部的ClassLoaderServiceImpl。位于org的loadJavaServices(ClassLoaderServiceImpl.java:324)。冬眠靴子注册表。选择器。内部的StrategySelectorBuilder。位于org的buildSelector(StrategySelectorBuilder.java:162)。冬眠靴子注册表。BootstrapServiceRegistryBuilder。在org上构建(BootstrapServiceRegistryBuilder.java:221)。冬眠cfg公司。配置(Configuration.java:119)位于com。perfectino。断裂。DAOManager。com上的addObject(DAOManager.java:22)。perfectino。断裂。HelloWorldController。com上的setArticle(HelloWorldController.java:104)。perfectino。断裂。HelloWorldController。sun上的addProduct(HelloWorldController.java:62)。反映NativeMethodAccessorImpl。在sun调用0(本机方法)。反映NativeMethodAccessorImpl。在sun调用(未知源)。反映DelegatingMethodAccessorImpl。在java上调用(未知源)。lang.reflect。方法在组织中调用(未知源)。springframework。网状物方法支持InvocableHandlerMethod。在org调用(InvocableHandlerMethod.java:213)。springframework。网状物方法支持InvocableHandlerMethod。org上的invokeForRequest(InvocableHandlerMethod.java:126)。springframework。网状物servlet。mvc。方法注释。ServletInvocableHandlerMethod。org上的invokeAndHandle(ServletInvocableHandlerMethod.java:96)。springframework。网状物servlet。mvc。方法注释。RequestMappingHandlerAdapter。org上的invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)。springframework。网状物servlet。mvc。方法注释。RequestMappingHandlerAdapter。位于org的handleInternal(RequestMappingHandlerAdapter.java:578)。springframework。网状物servlet。mvc。方法AbstractHandlerMethodAdapter。handle(AbstractHandlerMethodAdapter.java:80)位于org。springframework。网状物servlet。DispatcherServlet。doDispatch(DispatcherServlet.java:923)位于org。springframework。网状物servlet。DispatcherServlet。位于org的doService(DispatcherServlet.java:852)。springframework。网状物servlet。FrameworkServlet。org上的processRequest(FrameworkServlet.java:882)。springframework。网状物servlet。FrameworkServlet。javax上的doPost(FrameworkServlet.java:789)。servlet。http。HttpServlet。javax上的服务(HttpServlet.java:647)。servlet。http。HttpServlet。位于org的服务(HttpServlet.java:728)。阿帕奇。卡特琳娜。果心ApplicationFilterChain。位于org的internalDoFilter(ApplicationFilterChain.java:305)。阿帕奇。卡特琳娜。果心ApplicationFilterChain。doFilter(ApplicationFilterChain.java:210)位于org。阿帕奇。公猫websocket。服务器WsFilter。doFilter(WsFilter.java:51)位于org。阿帕奇。卡特琳娜。果心ApplicationFilterChain。位于org的internalDoFilter(ApplicationFilterChain.java:243)。阿帕奇。卡特琳娜。果心ApplicationFilterChain。doFilter(ApplicationFilterChain.java:210)位于org。阿帕奇。卡特琳娜。果心标准包装阀。在org上调用(StandardWrapperValve.java:222)。阿帕奇。卡特琳娜。果心标准上下文阀。在组织中调用(StandardContextValve.java:123)。阿帕奇。卡特琳娜。验证器。AuthenticatorBase。在org调用(AuthenticatorBase.java:502)。阿帕奇。卡特琳娜。果心标准主阀。在组织中调用(StandardHostValve.java:171)。阿帕奇。卡特琳娜。阀门。错误报告阀。在组织中调用(ErrorReportValve.java:100)。阿帕奇。卡特琳娜。阀门。检修阀。在org调用(AccessLogValve.java:953)。阿帕奇。卡特琳娜。果心标准发动机阀。在组织中调用(StandardEngineValve.java:118)。阿帕奇。卡特琳娜。连接器。郊狼适应者。org上的服务(CoyoteAdapter.java:408)。阿帕奇。郊狼。http11.AbstractHTTP11处理器。进程(AbstractHttp11Processor.java:1041),位于org。阿帕奇。郊狼。AbstractProtocol$AbstractConnectionHandler。进程(AbstractProtocol.java:603)位于org。阿帕奇。公猫util。网JIoEndpoint$SocketProcessor。在java上运行(JIoEndpoint.java:312)。util。同时发生的线程池执行器。java上的runWorker(未知源)。util。同时发生的ThreadPoolExecutor$工作者。在java上运行(未知源)。lang.Thread。运行(未知源)

共有1个答案

谭奕
2023-03-14

第二个问题与不同库中存在的重复JAR有关。因此,作为解决方案,我在能够运行项目之前删除了重复项。谢谢你的帮助。格雷戈里

 类似资料:
  • Spring的模型-视图-控制器(MVC)框架是围绕一个DispatcherServlet来设计的,这个Servlet会把请求分发给各个处理器,并支持可配置的处理器映射、视图渲染、本地化、时区与主题渲染等,甚至还能支持文件上传。处理器是你的应用中注解了@Controller和@RequestMapping的类和方法,Spring为处理器方法提供了极其多样灵活的配置。Spring 3.0以后提供了@

  • CodeIgniter基于Model-View-Controller (MVC) development pattern 。 MVC是一种将应用程序逻辑与表示分离的软件方法。 实际上,它允许您的网页包含最少的脚本,因为演示文稿与PHP脚本分开。 Model代表您的数据结构。 通常,模型类将包含帮助您检索,插入和更新数据库中信息的函数。 View是呈现给用户的信息。 视图通常是一个网页,但在Code

  • 22.1 Spring Web MVC框架介绍 Spring的Web模型-视图-控制器(MVC)框架是围绕将请求分发到不同处理程序的DispatcherServlet类设计的,辅以可配置的处理程序映射、视图解析、本地化、时区、主题解析(theme resolution)以及对文件上传的支持。默认的处理程序基于@Controller和@RequestMapping注解,提供了大量灵活的处理方法。自从

  • Mac's MVC Framework是一个开源的MVC开发框架。内置一个模板引擎和一个基于该框架开发,Ajax驱动的CMS系统。它的主要特性包括:纯MVC架构、高度可扩展、超轻量级、易于学习、支持多种数据库。

  • 本文向大家介绍Spring Web MVC框架学习之配置Spring Web MVC,包括了Spring Web MVC框架学习之配置Spring Web MVC的使用技巧和注意事项,需要的朋友参考一下 这一篇文章讲的是Spring Web MVC各部分的配置方法,包括Java代码配置和XML文件配置以及MVC命名空间的使用方法。 启用MVC Java配置和XML命名空间 默认配置 要启用MVC

  • 本文向大家介绍Java框架篇:Spring+SpringMVC+hibernate整合开发,包括了Java框架篇:Spring+SpringMVC+hibernate整合开发的使用技巧和注意事项,需要的朋友参考一下 前言: 最近没什么事做,搭个框架写成博客记录下来,拉通一下之前所学知识. 话不多说,我们直接步入正题。 准备工作:   1/安装并配置java运行环境   2/数据库的安装配置(Mys