2017-10-11 70 views
0

最近,我将weblogic服务器从11g升级到12.2.1.3,并重新部署了Web应用程序。运行应用程序时,它会抛出异常。会话中出现错误。我试图在网络上谷歌,但不是运气,因为它是创建会话问题。我相信在根据谷歌搜索(例如https://stackoverflow.com/questions/12010056/org-hibernate-invalidmappingexceptioncould-not-parse-mapping-document-from-reso)尝试的hiberate配置或映射xml文件时没有问题,但仍然是同样的问题。org.hibernate.InvalidMappingException:无法从资源解析映射文档 - > parseSessionFactory

%%%% Error Creating SessionFactory %%%% 
org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/xxxx/hibernate/SSmsPromotion.hbm.xml 
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:588) 
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1606) 
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1574) 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1553) 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1527) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1447) 
    at com.xxxx.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69) 
    at com.xxxx.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53) 
    at com.xxxx.onlineapplications.manager.SBranchManager.getSBranchCatList(SBranchManager.java:19) 

public class SBranchManager{ 
    ........... 
    public ArrayList getSBranchCatList(String langId, String appType) throws Exception{ 
     ArrayList branchCatList = new ArrayList(); 
     Session session = HibernateSessionFactory.getSession(); <--- Line 19 
    ................ 

    } 
} 
public class HibernateSessionFactory { 

    private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml"; 
    private static final ThreadLocal threadLocal = new ThreadLocal(); 
    private static Configuration configuration = new Configuration();  
    private static org.hibernate.SessionFactory sessionFactory; 
    private static String configFile = CONFIG_FILE_LOCATION; 

    public static Session getSession() throws HibernateException { 
     Session session = (Session) threadLocal.get(); 

     if (session == null || !session.isOpen()) { 
      if (sessionFactory == null) { 
       rebuildSessionFactory(); <---- Line 53 
      } 
      session = (sessionFactory != null) ? sessionFactory.openSession() 
        : null; 
      threadLocal.set(session); 
     } 

     return session; 
    } 


    public static void rebuildSessionFactory() { 
     try { 
      configuration.configure(configFile); <--- Line 69 
      sessionFactory = configuration.buildSessionFactory(); 
     } catch (Exception e) { 
      System.err 
        .println("%%%% Error Creating SessionFactory %%%%"); 
      e.printStackTrace(); 
     } 
    } 
} 
+0

删除以下行解决我发现,在XML中的顺序,通过使这项事业。解决了 – AMMA

回答

0

它是通过在weblogic.xml

<!-- <container-descriptor> 
     <prefer-web-inf-classes>true</prefer-web-inf-classes> 
    </container-descriptor> -->