• 尝试EJB整合Mybatis部署时报错:获得带有类加载器MybatisUtil的ModuleClassLoader的反射信息出错,请问大神如何解决


    mybatis的配置

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE configuration
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
    	<environments default="development">
    		<environment id="development">
    			<transactionManager type="JDBC" />
    			<dataSource type="POOLED">
    				<property name="driver" value="com.mysql.jdbc.Driver" />
    				<property name="url" value="jdbc:mysql://localhost:3306/MessageSystem" />
    				<property name="username" value="root" />
    				<property name="password" value="toor" />
    			</dataSource>
    		</environment>
    	</environments>
    	<mappers>
    		<mapper resource="MS/mybatis/mapper/User.xml" />		
    	</mappers>
    </configuration>
    

    SqlSessionFactory的构造

    package MS.mybatis;
    
    import java.io.IOException;
    import java.io.Reader;
    
    import org.apache.ibatis.io.Resources;
    import org.apache.ibatis.session.SqlSession;
    import org.apache.ibatis.session.SqlSessionFactory;
    import org.apache.ibatis.session.SqlSessionFactoryBuilder;
    
    
    public abstract class MybatisUtil {
    	
    	private static SqlSessionFactory sqlSessionFactory=null;
    	
    	static
    	{
    		try {
    			String resource = "mybatis-config.xml";
    			Reader reader = Resources.getResourceAsReader(resource);
    			sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}		
    	}
    	
    	public static SqlSessionFactory getSqlSessionFactory()
    	{
    		return sqlSessionFactory;
    	}
    	
    	public static SqlSession getSqlSession()
    	{
    		return sqlSessionFactory.openSession();
    	}
    }
    

     报错信息如下:

    20:53:05,537 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC0000
    01: Failed to start service jboss.deployment.unit."MessageSystem.jar".POST_MODUL
    E: org.jboss.msc.service.StartException in service jboss.deployment.unit."Messag
    eSystem.jar".POST_MODULE: JBAS018733: 处理 POST_MODULE 的 deployment "MessageSys
    tem.jar" 阶段失败
            at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(Deplo
    ymentUnitPhaseService.java:127) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0
    .Final-redhat-14]
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(Se
    rviceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-
    1]
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceCont
    rollerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
    utor.java:886) [rt.jar:1.6.0_26]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
    .java:908) [rt.jar:1.6.0_26]
            at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]
    Caused by: java.lang.RuntimeException: JBAS018757: 获得带有类加载器 class MS.myb
    atis.MybatisUtil 的 ModuleClassLoader for Module "deployment.MessageSystem.jar:m
    ain" from Service Module Loader 的反射信息出错
            at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getC
    lassIndex(DeploymentReflectionIndex.java:72) [jboss-as-server-7.3.0.Final-redhat
    -14.jar:7.3.0.Final-redhat-14]
            at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotation
    Information(MethodAnnotationAggregator.java:58)
            at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.ha
    ndleAnnotations(InterceptorAnnotationProcessor.java:107)
            at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.pr
    ocessComponentConfig(InterceptorAnnotationProcessor.java:92)
            at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.de
    ploy(InterceptorAnnotationProcessor.java:77)
            at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(Deplo
    ymentUnitPhaseService.java:120) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0
    .Final-redhat-14]
            ... 5 more
    Caused by: java.lang.NoClassDefFoundError: Lorg/apache/ibatis/session/SqlSession
    Factory;
            at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.6.0_26]
            at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [rt.jar:1.6
    .0_26]
            at java.lang.Class.getDeclaredFields(Class.java:1743) [rt.jar:1.6.0_26]
            at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(Cl
    assReflectionIndex.java:57) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Fin
    al-redhat-14]
            at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getC
    lassIndex(DeploymentReflectionIndex.java:68) [jboss-as-server-7.3.0.Final-redhat
    -14.jar:7.3.0.Final-redhat-14]
            ... 10 more
    Caused by: java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSessio
    nFactory from [Module "deployment.MessageSystem.jar:main" from Service Module Lo
    ader]
            at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:
    197) [jboss-modules.jar:1.3.0.Final-redhat-2]
            at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(Con
    currentClassLoader.java:443) [jboss-modules.jar:1.3.0.Final-redhat-2]
            at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(Concu
    rrentClassLoader.java:431) [jboss-modules.jar:1.3.0.Final-redhat-2]
            at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(Concu
    rrentClassLoader.java:398) [jboss-modules.jar:1.3.0.Final-redhat-2]
            at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentCl
    assLoader.java:373) [jboss-modules.jar:1.3.0.Final-redhat-2]
            at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoad
    er.java:118) [jboss-modules.jar:1.3.0.Final-redhat-2]
            ... 15 more
    
  • 相关阅读:
    第一次编程作业
    第一次博客作业
    软工回顾与总结
    百度OCR技术博客
    BUAA2020软工个人博客作业2-软件
    2020软工结队项目作业
    2020软工个人项目作业
    2020软件工程第一次个人博客作业
    2020软件工程热身作业
    OO完结篇-第四单元小结
  • 原文地址:https://www.cnblogs.com/DKSL/p/3997427.html
Copyright © 2020-2023  润新知