从Weblogic迁移到tomcat问题

时间:2015-10-05 14:11:37

标签: java tomcat ejb weblogic openejb

我正在将应用程序从WebLogic迁移到Tomcat。

我知道Tomcat无法处理EJB代码,而这些代码是在WebLogic上部署项目时添加到项目中的。

因此,最终可以使用TomEE(1.7.2)服务器来帮助处理EJB代码。

但在TomEE Server错误下运行该项目同样出现,

java.lang.ClassCastException: org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource cannot be cast to org.omg.CORBA.Object

我的TomEE Server的Server.xml包含以下代码,

<Resource name="abc/myjndiName" auth="Container"
    type="javax.sql.DataSource" 
    driverClassName="oracle.jdbc.OracleDriver"
    factory="org.apache.openejb.core.LocalInitialContextFactory"
    url="jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST 
    =(ADDRESS = (PROTOCOL = TCP)(HOST = hostname.com)(PORT = 1111))
     (ADDRESS = (PROTOCOL = TCP)(HOST = hostname.com)(PORT = 1111))
     (LOAD_BALANCE = yes))(CONNECT_DATA =(SERVICE_NAME = hostname.com)))"
      user="XXX" password="XXX"
      maxActive="20" maxIdle="10" maxWait="10000" />

任何人都可以解决它吗?出了什么问题? 那将是一种欣赏。

感谢。

错误的全栈跟踪看起来同样如此,

Unexpected exception in EJBComponentFinder.getAnyHome: java.lang.ClassCastException.java.lang.ClassCastException
    at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    at development.component.util.ObjectFactory.getAnyHome(ObjectFactory.java:457)
    at development.component.util.ObjectFactory.createSiteConfigurationEJB(ObjectFactory.java:322)
    at development.component.ui.ComponentApplicationServlet.loadSiteConfigParameters(ComponentApplicationServlet.java:615)
    at development.component.ui.ComponentApplicationServlet.init(ComponentApplicationServlet.java:126)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5266)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5554)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource cannot be cast to org.omg.CORBA.Object
    ... 18 more

----------------- 代码方法:getAnyHome(...) ----------------

public EJBHome getAnyHome(Class homeClass)
    {
        ClientContext clientContext = ContextLocator.getClientContext();
        try
        {
            Map jndiEJBMap = null;
            synchronized (allClassMaps)
            {
                String compoundKey = clientContext.getSiteName() + "_ejb_jndi_mappings";
                jndiEJBMap = (Map) allClassMaps.get(compoundKey);
                if (jndiEJBMap == null)
                {
                    SiteConfig config;
                    // not cached, retrieve from configuration files and cache
                    if (clientContext.getConfigFilePath() != null &&
                            clientContext.getConfigFilePath().length() > 0)
                    {
                        config = SiteConfigFactory.getInstance().getConfig(clientContext.getSiteName(), clientContext.getConfigFilePath());
                    }
                    else
                        config = SiteConfigFactory.getInstance().getConfig(clientContext.getSiteName());

                    jndiEJBMap = config.getMap("ejb_jndi_mappings");
                    allClassMaps.put(compoundKey, jndiEJBMap);
                }
            }
            String jndiName = (String) jndiEJBMap.get(homeClass.getName());
            if (jndiName == null)
            {
                String msg = "ObjectFactory cannot find tag <mapentry name=\"" + homeClass.getName() + "\"> within tag <map name=\"ejb_jndi_mappings\"> for site (" + clientContext.getSiteName() + "), cannot create EJB.";
                Log.error(msg);
                throw new ConfigurationException(msg);
            }

            Object anyHome = namingContext.lookup(jndiName);
            // Then narrow the reference and return it

            return (EJBHome) PortableRemoteObject.narrow(anyHome, homeClass); // Here Error Comes
        }
        catch (Exception exc)
        {
            String msg = "Unexpected exception in EJBComponentFinder.getAnyHome: " + exc.toString() + ".";
            Log.error(msg, exc);
            throw new EJBException(msg);
        }
    }

----------------- 代码方法:createSiteConfigurationEJB() -----------------

public static SiteConfigurationEJB createSiteConfigurationEJB()
    {
        try
        {
            SiteConfigurationHome home =
                    (SiteConfigurationHome) getInstance().getAnyHome(SiteConfigurationHome.class);
            return home.create();
        }
        catch (Exception exc)
        {
            String msg = "Unexpected exception in ObjectFactory.createSiteConfigurationEJB: " + exc.toString() + ".";
            Log.error(msg, exc);
            throw new EJBException(msg);
        }
    }

-------------------------------------------- -------------------------------------------------- ------------------------------------

0 个答案:

没有答案