8 Replies Latest reply on Mar 31, 2007 9:16 AM by prakash Dumbre

    Migration from Weblogic to JBoss 4.0.5

    prakash Dumbre Newbie

      I am migrating our application from Weblogic 7.0 to JBoss 4.0.5. I have succesefully Deployed our ear file after changing all xml files on JBoss. But now i am facing problem regarding to ejb JNDI lookup while accessing login page.

      "Failed to lookup EJB home interface javax.naming.NameNotFoundException:"
      what should I do? Is there any anather way to lookup jndi in jboss.


      please help me
      Thanks in advanced

        • 1. Re: Migration from Weblogic to JBoss 4.0.5
          David Ward Master

          Please show the relevant sections of ejb-jar.xml, jboss.xml and the code that is doing the JNDI lookup.

          • 2. Re: Migration from Weblogic to JBoss 4.0.5
            prakash Dumbre Newbie

            Thanks for replay

            When i deployed our ear file, the server takes following
            jndi name .

            15:18:22,793 INFO [ProxyFactory] Bound EJB Home SecurityService' to jndi 'SecurityService'


            but i have write the following jndi name in jboss.xml then how it takes "SecurityService" as jndi name

            <enterprise-bean>

            <ejb-name>SecurityService</ejb-name>
            <jndi-name>com.cedera.server.user.ejb.SecurityService</jndi-name>

            </enterprise-bean>


            and ejb-jar.xml



            <ejb-name>SecurityService</ejb-name>

            com.cedera.server.user.ejb.SecurityServiceHome
            com.cedera.server.user.ejb.SecurityService
            <ejb-class>com.cedera.server.user.ejb.SecurityServiceEJB</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>



            This is all for SecurityServiceEJB bean

            Now i have tested this jndi name in test jsp page the jsp code is following

            <% Connection conn;

            Context ctx = new InitialContext();
            EJBHome home = (EJBHome) ctx.lookup("SecurityService");
            out.println("Connected to JNDI : " + home );

            %>

            Then it gives following result.
            Connected to JNDI : SecurityServiceHome

            Is it mean its work fine. it return SecurityServiceHome object.


            my jndi lookup is

            private static EJBHome lookupHomeInterface(String jndiName)
            throws CederaException
            {
            Context ctx = null;
            EJBHome home = null;

            try
            {
            System.out.println("The JNDI Name is:" + jndiName );
            ctx = EJBUtil.getInitialContext();
            home = (EJBHome)PortableRemoteObject.narrow(ctx.lookup(jndiName), javax.ejb.EJBHome.class);
            System.out.println("The JNDI Name is:" + jndiName);
            }
            catch(NamingException ne)
            {

            }
            return home;
            }


            after getting home EJBHome object i have to pass it to following method

            javax.ejb.EJBHome home = EJBHomeFactory.getHomeInterface("com.cedera.server.user.ejb.SecurityService", false);
            SecurityServiceHome secHome = (SecurityServiceHome)PortableRemoteObject.narrow(home, com.cedera.server.user.ejb.SecurityServiceHome.class);
            SecurityService secService = (SecurityService)PortableRemoteObject.narrow(secHome.create(), com.cedera.server.user.ejb.SecurityService.class);

            Here i have facing following error when i am accesing login page.

            java.lang.ClassCastException
            at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
            at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
            at com.cedera.util.GetRemoteInterfaces.getSecurityService(GetRemoteInterfaces.java:360)


            Please help me to solve tis issue

            regards,
            Prakash

            • 3. Re: Migration from Weblogic to JBoss 4.0.5
              David Ward Master

              So your ClassCastException is different from your original NameNotFoundException.

              The NameNotFoundException was caused by looking up a jndi name that was not bound. It seems like a common thing for people who are used to weblogic to bind beans into jndi with the fully qualified package name of a class. You are also depending upon the global jndi namespace. I would suggest you:
              1) look into using local interfaces to your ejbs rather than remote interfaces wherever possible
              2) change your jndi names to path-like structures
              3) make use of ejb references (<ejb-ref> or <ejb-local-ref>) to bind your beans from the global jndi namespace into a local jndi namespace (so you could lookup "java:comp/env/ejb/UserService" - the standard way of doing it)
              How to do the above is in the standard ejb documentation and jboss documentation.

              You ClassCastException was caused by your second narrow. You only have to narrow the remote home interface. After that you can just call create() and use the remote interface you get back directly. (If you decide to move to local interfaces rather than remote remember that the narrow would then be unnecessary.)

              Last, I know you are just trying to migrate an existing application, but remember if you move to EJB3 and JEE 5, explicit jndi lookups can become a thing of the past as you can use annotations to instruct the container to inject resources into your managed componets.

              Hope this helps.

              • 4. Re: Migration from Weblogic to JBoss 4.0.5
                prakash Dumbre Newbie


                I have resolved ClassCastException problem.
                It is alll about classloader and webloader problem.
                I have to removed classes folder from WEB-INF folder from war file


                Thanks
                Prakash



                • 5. Re: Migration from Weblogic to JBoss 4.0.5
                  prakash Dumbre Newbie

                  Hi
                  Now i am facing prblem with Entity beans. When server is starting that the entity bean takes following jndi name

                  16:20:44,347 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'BusinessSKUEntity' to jndi 'local/BusinessSKUEntity@23128226'

                  How it takes that name? and each time '@23128226' value chenges.

                  when i am accessing other pages that time following error occures


                  com.xxxxx.exception.CederaException: MSG: javax.transaction.TransactionRolledbackException: MSG: javax.naming.NameNotFoundException: BusinessSKUEntity not boundBusinessSKUEntity not bound TIME: 0; nested exception is:
                  com.xxxxxx.exception.CederaEJBException: MSG: javax.naming.NameNotFoundException: BusinessSKUEntity not boundBusinessSKUEntity not bound TIME: 0MSG: javax.naming.NameNotFoundException: BusinessSKUEntity not boundBusinessSKUEntity not bound TIME: 0; nested exception is:
                  com.xxxxxx.exception.CederaEJBException: MSG: javax.naming.NameNotFoundException: BusinessSKUEntity not boundBusinessSKUEntity not bound TIME: 0 TIME: 0
                  at com.xxxxxx.client.bean.fulfill.PackBean.getOrders(PackBean.java:65)
                  at org.apache.jsp.fulfill.pack_jsp._jspService(pack_jsp.java:327)
                  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
                  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                  at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                  at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                  at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                  at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                  at java.lang.Thread.run(Thread.java:595)




                  What should I do to resolve?

                  If i am accessing the entity bean with above jndi name ,it gives proper result but each tome value has been changed. how could i do?

                  • 6. Re: Migration from Weblogic to JBoss 4.0.5
                    David Ward Master

                    First off, your ClassCastException was at your second narrow, according to the stack trace you provided, and indeed a second narrow should not be done. Good move cleaning up classes from your web tier, though. Classes that exist in the ejb tier should not be duplicated in your web tier. As long as both tiers are bundled in the same enterprise app (ear), the spec says the ejb tier classes will be visible by the web tier.

                    Anyway, per your more current problem, again, I need to see the relevant sections of your ejb-jar.xml, jboss.xml and the code that is doing the lookup. Also, are you making use of ejb-local-ref's? You should be. Also, are you using any code generation tools, like XDoclet? Just trying to understand how your app is glued together...

                    • 7. Re: Migration from Weblogic to JBoss 4.0.5
                      prakash Dumbre Newbie

                      Thanks for Replay.

                      16:20:44,347 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'BusinessSKUEntity' to jndi 'local/BusinessSKUEntity@23128226'

                      In this case application server takes 'local/BusinessSKUEntity@23128226' as JNDI name.

                      How it takes that name? and each time '@23128226' value has been chenged.

                      I am confused how should I lookup?

                      when I am accessing other pages that time above error occures

                      Following are the xml descriptor for BusinessSKUEntity entity bean

                      jboss.xml


                      <ejb-name>BusinessSKUEntity</ejb-name>
                      <ejb-ref-name>BusinessSKUEntity</ejb-ref-name>
                      <local-jndi-name>BusinessSKUEntity</local-jndi-name>

                      <entity-descriptor>



                      <entity-cache>
                      <max-beans-in-cache>4000</max-beans-in-cache>
                      <idle-timeout-seconds>600</idle-timeout-seconds>
                      <concurrency-strategy>Readonly</concurrency-strategy>
                      <cache-between-transactions>False</cache-between-transactions>
                      </entity-cache>


                      <is-modified-method-name>isModified</is-modified-method-name>
                      <delay-updates-until-end-of-tx>False</delay-updates-until-end-of-tx>
                      <persistence-use>
                      <type-identifier>JBoss_CMP_RDBMS</type-identifier>
                      <type-version>4.0.5</type-version>
                      <type-storage>META-INF/jbosscmp-jdbc.xml</type-storage>
                      </persistence-use>



                      <entity-clustering>
                      </entity-clustering>

                      </entity-descriptor>

                      <transaction-descriptor>
                      </transaction-descriptor>

                      <reference-descriptor>
                      </reference-descriptor>





                      ejb-jar.xml




                      <![CDATA[This bean represent one business specific product]]>

                      <ejb-name>BusinessSKUEntity</ejb-name>
                      <local-home>com.xxxx.server.product.ejb.BusinessSKUEntityHome</local-home>
                      com.xxxx.server.product.ejb.BusinessSKUEntity
                      <ejb-class>com.xxxxx.server.product.ejb.BusinessSKUEntityEJB</ejb-class>
                      <persistence-type>Container</persistence-type>
                      <prim-key-class>com.xxxxx.server.product.ejb.BusinessSKUEntityPK</prim-key-class>
                      False
                      <abstract-schema-name>BusinessSKUEntity</abstract-schema-name>
                      <cmp-field>
                      <field-name>businessskuid</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>owningbusinessid</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>ownersku</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>ownerskudescription</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>department</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>description</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>baseprice</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>marginpercentage</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>wholesalediscountpctg</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>minimumspreadpctg</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>weight</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>totalexcessinvforavail</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>skusetid</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>markdownlevel</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>createddate</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>createdby</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>modifieddate</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>modifiedby</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>preorder</field-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>instoredate</field-name>
                      </cmp-field>

                      <ejb-local-ref id="EJBLocalRef_1040043976657">
                      Local Ref for BusinessSKUEntity
                      <ejb-ref-name>BusinessSKUEntity</ejb-ref-name>
                      <ejb-ref-type>Entity</ejb-ref-type>
                      <local-home>com.xxxxx.server.product.ejb.BusinessSKUEntityHome</local-home>
                      com.xxxxx.server.product.ejb.BusinessSKUEntity
                      <ejb-link>BusinessSKUEntity</ejb-link>
                      </ejb-local-ref>




                      <query-method>
                      <method-name>findByBusinessAndBusinessSKUID</method-name>
                      <method-params>
                      <method-param>int</method-param>
                      <method-param>int</method-param>
                      </method-params>

                      </query-method>

                      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(o) FROM BusinessSKUEntity o WHERE ((o.owningbusinessid = ?1) AND (o.businessskuid = ?2))]]></ejb-ql>


                      <query-method>
                      <method-name>findByBusinessAndOwnerSKU</method-name>
                      <method-params>
                      <method-param>int</method-param>
                      <method-param>java.lang.String</method-param>
                      </method-params>

                      </query-method>

                      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(o) FROM BusinessSKUEntity o WHERE ((o.owningbusinessid = ?1) AND (o.ownersku = ?2))]]></ejb-ql>




                      <assembly-descriptor>
                      <method-permission>



                      <![CDATA[This entity bean represent a row in the database for the table CederaSKU]]>
                      <ejb-name>BusinessSKUEntity</ejb-name>
                      <method-name>*</method-name>


                      <ejb-name>BusinessSKUEntity</ejb-name>
                      <!-- method-intf>Local</method-intf -->
                      <method-name>*</method-name>


                      <ejb-name>BusinessSKUEntity</ejb-name>
                      <!-- method-intf>LocalHome</method-intf -->
                      <method-name>*</method-name>




                      <ejb-name>ProductService</ejb-name>
                      <method-intf>Remote</method-intf>
                      <method-name>*</method-name>


                      </method-permission>
                      <container-transaction>

                      <ejb-name>BusinessSKUEntity</ejb-name>
                      <!-- method-intf>LocalHome</method-intf -->
                      <method-name>*</method-name>


                      <ejb-name>BusinessSKUEntity</ejb-name>
                      <!-- method-intf>Local</method-intf -->
                      <method-name>*</method-name>

                      </container-transaction>
                      </assembly-descriptor>


                      jbosscmp.xml

                      <jbosscmp-jdbc>

                      <enterprise-beans>



                      <ejb-name>BusinessSKUEntity</ejb-name>


                      java:/orderPool
                      <datasource-mapping>Oracle9i</datasource-mapping>

                      <table-name>BusinessSKU</table-name>
                      <cmp-field>
                      <field-name>businessskuid</field-name>
                      <column-name>BUSINESSSKUID</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>owningbusinessid</field-name>
                      <column-name>OWNINGBUSINESSID</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>ownersku</field-name>
                      <column-name>OWNERSKU</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>department</field-name>
                      <column-name>DEPARTMENT</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>description</field-name>
                      <column-name>DESCRIPTION</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>ownerskudescription</field-name>
                      <column-name>OWNERSKUDESCRIPTION</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>baseprice</field-name>
                      <column-name>BASEPRICE</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>marginpercentage</field-name>
                      <column-name>MARGINPERCENTAGE</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>wholesalediscountpctg</field-name>
                      <column-name>WHOLESALEDISCOUNTPCTG</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>minimumspreadpctg</field-name>
                      <column-name>MINIMUMSPREADPCTG</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>weight</field-name>
                      <column-name>WEIGHT</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>totalexcessinvforavail</field-name>
                      <column-name>TOTALEXCESSINVFORAVAIL</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>skusetid</field-name>
                      <column-name>SKUSETID</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>markdownlevel</field-name>
                      <column-name>MARKDOWNLEVEL</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>createddate</field-name>
                      <column-name>CREATEDDATE</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>createdby</field-name>
                      <column-name>CREATEDBY</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>modifieddate</field-name>
                      <column-name>MODIFIEDDATE</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>modifiedby</field-name>
                      <column-name>MODIFIEDBY</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>preorder</field-name>
                      <column-name>PREORDER</column-name>
                      </cmp-field>
                      <cmp-field>
                      <field-name>instoredate</field-name>
                      <column-name>INSTOREDATE</column-name>
                      </cmp-field>


                      <!-- <optimistic-column>MODIFIEDDATE</optimistic-column> -->

                      </enterprise-beans>


                      </jbosscmp-jdbc>



                      • 8. Re: Migration from Weblogic to JBoss 4.0.5
                        prakash Dumbre Newbie


                        Please anybody help me for the above problem?
                        I am stuck here and could not go ahead.