5 Replies Latest reply on Sep 2, 2005 7:03 AM by achetan

    ejbs with jboss

    rakeshkamat

      Hi
      Do i need to have the "org.jboss.ejb.plugins" folders somewhere within my jboss dir structure to run ejbs? I keep on getting the "javax.ejb.EJBException: Could not instantiate bean" error everytime i try to call either the crete or findByPrimarykey() method on my remote interface.

      What could be the problem?? Kindly help me out.

      Thanks in advance.

        • 1. Re: ejbs with jboss
          wadewang75024

          Did u get it work? I am having the same problem.

          Thanks,
          Wade

          • 2. Re: ejbs with jboss
            darranl

            Could both of you please put together a post with useful information that is not a complete waste of everyones times.

            NEVER post a line like 'javax.ejb.EJBException: Could not instantiate bean', this tells us nothing. Post the exception, message and stack trace.

            Post some code examples to show what you are actually doing.

            everytime i try to call either the crete or findByPrimarykey() method on my remote interface


            These methods should be on the home interface not the remote interface.

            • 3. Re: ejbs with jboss
              wadewang75024

              Sorry, Darren and others. Ensuing are my classes and config files including the entity bean class and ejb-jar.xml, web.xml, jboss-web.xml
              jboss.xml. BTW, I am using Jboss4.0.2/Eclipse3.1/JBossIDE1.5M/Java5.

              Here is the place where the exception (at Create) gets thrown:
              ...
              WWSoftUserLocalHome userHome = WWSoftUserUtil.getLocalHome();
              WWSoftUserLocal user = userHome.create(userLoginName);

              ...

              Any helps would be greatly appreciated.

              1. The bean class

              /**
              * @ejb.bean name="WWSoftUser"
              * display-name="User Entity Bean"
              * description="It represents a user to the system."
              * type="CMP"
              * cmp-version="2.x"
              * view-type="local"
              * primkey-field="id"
              *
              * @ejb.finder signature="java.util.Collection findAll()"
              * query="SELECT OBJECT(u) FROM WWSoftUser AS u"
              *
              * @ejb.finder signature="java.util.Collection findUser(java.lang.String id)"
              * query="SELECT OBJECT(u) FROM WWSoftUser AS u WHERE u.id = ?1"
              *
              * @ejb.value-object name="WWSoftUser"
              */
              public abstract class WWSoftUserBean implements EntityBean {

              public WWSoftUserBean() {
              super();
              // TODO Auto-generated constructor stub
              }

              /** @ejb.create-method */
              public String ejbCreate(String userLoginName)
              throws CreateException
              {
              logger.debug("WWSoftUserBean:ejbCreate *****");
              setId(com.wwsoft.strutswithejb.interfaces.WWSoftUserUtil.generateGUID(this));
              setName(userLoginName);
              setCreatedDate(new Date());
              logger.debug("creating user identified by " +
              getId() + " and " + userLoginName);
              return null;
              }

              public void ejbPostCreate(String userLoginName)
              throws CreateException
              {

              }

              /**
              * @ejb.pk-field
              * @ejb.persistence
              * @ejb.interface-method
              */
              public abstract String getId();
              public abstract void setId(String id);

              /**
              * @ejb.persistence
              * @ejb.interface-method
              */
              public abstract String getName();
              /** @ejb.interface-method */
              public abstract void setName(String name);

              /**
              * @ejb.persistence
              * @ejb.interface-method
              */
              public abstract Date getCreatedDate();
              /** @ejb.interface-method */
              public abstract void setCreatedDate(Date date);

              /**
              * @ejb.interface-method
              *
              * @ejb.relation name="Parent-to-Child"
              * role-name="Parent-has-one-Child"
              * target-ejb="com.wwsoft.strutswithejb.ejb.AddressBean"
              * target-role-name="Child-has-one-parent"
              *
              */
              public abstract com.wwsoft.strutswithejb.interfaces.AddressLocal getAddress();

              /** @ejb.interface-method */
              public abstract void setAddress(com.wwsoft.strutswithejb.interfaces.AddressLocal address);

              private Logger logger = Logger.getLogger(WWSoftUserBean.class);
              }


              2. My ejb-jar.xml

              <?xml version="1.0" encoding="UTF-8"?>

              <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">

              <![CDATA[No Description.]]>
              <display-name>Generated by XDoclet</display-name>

              <enterprise-beans>

              <!-- Session Beans -->

              <![CDATA[Description for HotelManagerSession]]>
              <display-name>Name for HotelManagerSession</display-name>

              <ejb-name>HotelManagerSession</ejb-name>

              com.wwsoft.strutswithejb.interfaces.HotelManagerSessionHome
              com.wwsoft.strutswithejb.interfaces.HotelManagerSession
              <ejb-class>com.wwsoft.strutswithejb.ejb.HotelManagerSessionBean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Container</transaction-type>



              <!--
              To add session beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called session-beans.xml that contains
              the markup for those beans.
              -->

              <!-- Entity Beans -->

              <![CDATA[It represents a user to the system.]]>
              <display-name>User Entity Bean</display-name>

              <ejb-name>WWSoftUser</ejb-name>

              <local-home>com.wwsoft.strutswithejb.interfaces.WWSoftUserLocalHome</local-home>
              com.wwsoft.strutswithejb.interfaces.WWSoftUserLocal

              <ejb-class>com.wwsoft.strutswithejb.ejb.WWSoftUserBean</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>java.lang.String</prim-key-class>
              false
              <cmp-version>2.x</cmp-version>
              <abstract-schema-name>WWSoftUser</abstract-schema-name>
              <cmp-field >
              <![CDATA[]]>
              <field-name>id</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[]]>
              <field-name>name</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[]]>
              <field-name>createdDate</field-name>
              </cmp-field>
              <primkey-field>id</primkey-field>


              <query-method>
              <method-name>findAll</method-name>
              <method-params>
              </method-params>
              </query-method>
              <ejb-ql><![CDATA[SELECT OBJECT(u) FROM WWSoftUser AS u]]></ejb-ql>


              <query-method>
              <method-name>findUser</method-name>
              <method-params>
              <method-param>java.lang.String</method-param>
              </method-params>
              </query-method>
              <ejb-ql><![CDATA[SELECT OBJECT(u) FROM WWSoftUser AS u WHERE u.id = ?1]]></ejb-ql>

              <!-- Write a file named ejb-finders-WWSoftUserBean.xml if you want to define extra finders. -->




              <![CDATA[It represents a generic address.]]>
              <display-name>generic address</display-name>

              <ejb-name>Address</ejb-name>

              <local-home>com.wwsoft.strutswithejb.interfaces.AddressLocalHome</local-home>
              com.wwsoft.strutswithejb.interfaces.AddressLocal

              <ejb-class>com.wwsoft.strutswithejb.ejb.AddressBean</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>java.lang.String</prim-key-class>
              false
              <cmp-version>2.x</cmp-version>
              <abstract-schema-name>Address</abstract-schema-name>
              <cmp-field >
              <![CDATA[]]>
              <field-name>id</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[]]>
              <field-name>addressLine1</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[]]>
              <field-name>addressLine2</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[]]>
              <field-name>city</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[]]>
              <field-name>state</field-name>
              </cmp-field>
              <cmp-field >
              <![CDATA[]]>
              <field-name>zip</field-name>
              </cmp-field>
              <primkey-field>id</primkey-field>


              <query-method>
              <method-name>findAll</method-name>
              <method-params>
              </method-params>
              </query-method>
              <ejb-ql><![CDATA[SELECT OBJECT(a) FROM Address AS a]]></ejb-ql>

              <!-- Write a file named ejb-finders-AddressBean.xml if you want to define extra finders. -->



              <!--
              To add entity beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called entity-beans.xml that contains
              the markup for those beans.
              -->

              <!-- Message Driven Beans -->
              <!--
              To add message driven beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called message-driven-beans.xml that contains
              the <message-driven></message-driven> markup for those beans.
              -->

              </enterprise-beans>

              <!-- Relationships -->

              <ejb-relation >
              <ejb-relation-name>Parent-to-Child</ejb-relation-name>

              <ejb-relationship-role >
              <ejb-relationship-role-name>Parent-has-one-Child</ejb-relationship-role-name>
              One
              <relationship-role-source >
              <ejb-name>WWSoftUser</ejb-name>
              </relationship-role-source>
              <cmr-field >
              <cmr-field-name>address</cmr-field-name>
              </cmr-field>
              </ejb-relationship-role>

              <ejb-relationship-role >
              <ejb-relationship-role-name>Child-has-one-parent</ejb-relationship-role-name>
              One
              <relationship-role-source >
              <ejb-name>Address</ejb-name>
              </relationship-role-source>
              <cmr-field >
              <cmr-field-name>parent</cmr-field-name>
              </cmr-field>
              </ejb-relationship-role>

              </ejb-relation>
              <!--
              To add relationships for beans not managed by XDoclet, add
              a file to your XDoclet merge directory called relationships.xml that contains
              the <ejb-relation></ejb-relation> markups for those beans.
              -->


              <!-- Assembly Descriptor -->
              <!--
              To specify your own assembly descriptor info here, add a file to your
              XDoclet merge directory called assembly-descriptor.xml that contains
              the <assembly-descriptor></assembly-descriptor> markup.
              -->

              <assembly-descriptor >
              <!--
              To specify additional security-role elements, add a file in the merge
              directory called ejb-security-roles.xml that contains them.
              -->

              <!-- method permissions -->
              <!--
              To specify additional method-permission elements, add a file in the merge
              directory called ejb-method-permissions.ent that contains them.
              -->

              <!-- transactions -->
              <!--
              To specify additional container-transaction elements, add a file in the merge
              directory called ejb-container-transactions.ent that contains them.
              -->

              <!-- finder transactions -->

              <!-- message destinations -->
              <!--
              To specify additional message-destination elements, add a file in the merge
              directory called ejb-message-destinations.ent that contains them.
              -->

              <!-- exclude list -->
              <!--
              To specify an exclude-list element, add a file in the merge directory
              called ejb-exclude-list.xml that contains it.
              -->
              </assembly-descriptor>

              </ejb-jar>


              3. My web.xml
              <?xml version="1.0" encoding="UTF-8"?>

              <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">


              <!--
              To use non XDoclet filters, create a filters.xml file that
              contains the additional filters (eg Sitemesh) and place it in your
              project's merge dir. Don't include filter-mappings in this file,
              include them in a file called filter-mappings.xml and put that in
              the same directory.
              -->

              <!--
              To use non XDoclet filter-mappings, create a filter-mappings.xml file that
              contains the additional filter-mappings and place it in your
              project's merge dir.
              -->


              <servlet-name>StarterServlet</servlet-name>
              A servlet for setup component container and other initialization processes
              <servlet-class>com.wwsoft.strutswithejb.web.StarterServlet</servlet-class>
              <init-param>
              <param-name>log4jInitFile</param-name>
              <param-value>WEB-INF/conf/applog4j.xml</param-value>
              </init-param>
              <init-param>
              <param-name>appConfigFile</param-name>
              <param-value>WEB-INF/conf/appConfig.properties</param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>

              <!-- Standard Action Servlet Configuration (with debugging) -->

              <servlet-name>action</servlet-name>
              <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
              <init-param>
              <param-name>config</param-name>
              <param-value>/WEB-INF/struts-config.xml</param-value>
              </init-param>
              <init-param>
              <param-name>config/hotel</param-name>
              <param-value>/WEB-INF/conf/hotel/struts-config.xml</param-value>
              </init-param>
              <init-param>
              <param-name>debug</param-name>
              <param-value>2</param-value>
              </init-param>
              <init-param>
              <param-name>detail</param-name>
              <param-value>2</param-value>
              </init-param>
              <load-on-startup>2</load-on-startup>


              <!-- Standard Action Servlet Mapping -->
              <servlet-mapping>
              <servlet-name>action</servlet-name>
              <url-pattern>*.do</url-pattern>
              </servlet-mapping>
              <!-- Struts Tag Library Descriptors -->

              <taglib-uri>/tags/struts-bean</taglib-uri>
              <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>



              <taglib-uri>/tags/struts-html</taglib-uri>
              <taglib-location>/WEB-INF/struts-html.tld</taglib-location>



              <taglib-uri>/tags/struts-logic</taglib-uri>
              <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>



              <taglib-uri>/tags/struts-nested</taglib-uri>
              <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>


              <taglib-uri>/tags/struts-tiles.tld</taglib-uri>
              <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>


              <!--
              To specify mime mappings, create a file named mime-mappings.xml, put it in your project's mergedir.
              Organize mime-mappings.xml following this DTD slice:

              <!ELEMENT mime-mapping (extension, mime-type)>
              -->

              <!--
              To specify error pages, create a file named error-pages.xml, put it in your project's mergedir.
              Organize error-pages.xml following this DTD slice:

              <!ELEMENT error-page ((error-code | exception-type), location)>
              -->

              <!--
              To add taglibs by xml, create a file called taglibs.xml and place it
              in your merge dir.
              -->

              <ejb-ref >
              <ejb-ref-name>ejb/HotelManagerSession</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              com.wwsoft.strutswithejb.interfaces.HotelManagerSessionHome
              com.wwsoft.strutswithejb.interfaces.HotelManagerSession
              <ejb-link>HotelManagerSession</ejb-link>
              </ejb-ref>

              <ejb-local-ref >
              <ejb-ref-name>ejb/WWSoftUserLocal</ejb-ref-name>
              <ejb-ref-type>Entity</ejb-ref-type>
              <local-home>com.wwsoft.strutswithejb.interfaces.WWSoftUserLocalHome</local-home>
              com.wwsoft.strutswithejb.interfaces.WWSoftUserLocal
              <ejb-link>WWSoftUser</ejb-link>
              </ejb-local-ref>

              <ejb-local-ref >
              <ejb-ref-name>ejb/AddressLocal</ejb-ref-name>
              <ejb-ref-type>Entity</ejb-ref-type>
              <local-home>com.wwsoft.strutswithejb.interfaces.AddressLocalHome</local-home>
              com.wwsoft.strutswithejb.interfaces.AddressLocal
              <ejb-link>Address</ejb-link>
              </ejb-local-ref>

              </web-app>


              4. My jboss-web.xml

              <jboss-web>
              <ejb-ref>
              <ejb-ref-name>ejb/HotelManagerSession</ejb-ref-name>
              <jndi-name>ejb/HotelManagerSession</jndi-name>
              </ejb-ref>

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

              <ejb-local-ref >
              <ejb-ref-name>ejb/AddressLocal</ejb-ref-name>
              <jndi-name>AddressLocal</jndi-name>
              </ejb-local-ref>
              </jboss-web>


              5. My jboss.xml
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">



              <enterprise-beans>

              <!--
              To add beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called jboss-beans.xml that contains
              the , and <message-driven></message-driven>
              markup for those beans.
              -->


              <ejb-name>WWSoftUser</ejb-name>
              <local-jndi-name>WWSoftUserLocal</local-jndi-name>



              <ejb-name>Address</ejb-name>
              <local-jndi-name>AddressLocal</local-jndi-name>




              <ejb-name>HotelManagerSession</ejb-name>
              <jndi-name>ejb/HotelManagerSession</jndi-name>



              <!--
              write a merge file jboss-webservices.ent for webservice-description
              -->

              </enterprise-beans>

              <resource-managers>
              </resource-managers>

              <!--
              | for container settings, you can merge in jboss-container.xml
              | this can contain <invoker-proxy-bindings/> and <container-configurations/>
              -->



              6. Finally the exception stack trace:

              type Exception report

              message

              description The server encountered an internal error () that prevented it from fulfilling this request.

              exception

              javax.servlet.ServletException: Could not instantiate bean
              org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
              org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
              org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
              org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
              org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
              javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)


              root cause

              javax.ejb.EJBException: Could not instantiate bean
              org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:180)
              org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:96)
              org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
              org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
              org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41)
              org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109)
              org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
              org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:146)
              org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:116)
              org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
              org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
              org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:508)
              org.jboss.ejb.Container.invoke(Container.java:894)
              org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:342)
              org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
              $Proxy62.create(Unknown Source)
              com.wwsoft.strutswithejb.business.BusinessDelegate.createUser(BusinessDelegate.java:58)
              com.wwsoft.strutswithejb.web.UserCreationAction.execute(UserCreationAction.java:26)
              org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
              org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
              org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
              org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
              javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)


              note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

              • 4. Re: ejbs with jboss
                achetan

                Hi all,

                I am also getting the same problem each time i am calling home.create() method on my stateless session bean.

                Log suggests nothing.

                Please tell the solution if any of you have solved it.

                Thanks
                Chetan

                • 5. Re: ejbs with jboss
                  achetan

                   

                  "achetan" wrote:
                  Hi all,

                  I am also getting the same problem each time i am calling home.create() method on my stateless session bean.

                  Log suggests nothing.

                  Please tell the solution if any of you have solved it.

                  Thanks
                  Chetan