4 Replies Latest reply on Jan 28, 2007 12:04 PM by guy_davis

    help with embedded server - driving me nuts

    wiggy

      having problems seeting up the embedded server for EJB3 so that i can run outside an app server.

      imported a bootsrap main programme from hibernate chapter 2 into an Eclipse project

      where i have a structure as

      src
       NeilsApp2.java (default package)
       objectModel
       more java files ...
       ejb3-interceptors-aop.xml
       jndi.properties
       log4j.properties
       META-INF
       persistence.xml (for mysql)
       neilsapp-beans.xml (ds for the beans)
      



      
      import objectModel.TestHandler;
      
      import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
      import javax.naming.InitialContext;
      
      public class NeilsApp2
      {
      
       public static void main(String[] args) throws Exception {
      // Boot the JBoss Microcontainer with EJB3 settings, automatically
      // loads ejb3-interceptors-aop.xml and embedded-jboss-beans.xml
       EJB3StandaloneBootstrap.boot(null);
      // Deploy custom stateless beans (datasource, mostly)
       EJB3StandaloneBootstrap
       .deployXmlResource("META-INF/NeilsApp-beans.xml");
      // Deploy all EJBs found on classpath (slow, scans all)
      // EJB3StandaloneBootstrap.scanClasspath();
      // Deploy all EJBs found on classpath (fast, scans build directory)
      // This is a relative location, matching the substring end of one
      // of java.class.path locations. Print out the value of
      // System.getProperty("java.class.path") to see all paths.
       EJB3StandaloneBootstrap.scanClasspath("helloworld-ejb3/bin");
      // Create InitialContext from jndi.properties
       InitialContext initialContext = new InitialContext();
      // Look up the stateless MessageHandler EJB
       TestHandler tstHandler = (TestHandler) initialContext
       .lookup("TestHandlerBean/local");
      // Call the stateless EJB
       tstHandler.testMessage();
      // Shut down EJB container
       EJB3StandaloneBootstrap.shutdown();
       }
      }
      


      and unpacked the embedded server release 9 patch 1 into a jboss install dir.

      Now we get the problems. The book said I should have an embedded-jboss-beans.xml file. However there is not one of these to be found in the
      E:\jboss\jboss-EJB-3.0_RC9_Patch_1 directories at all.

      further, included the /lib jar files into my class path and Eclipse couldnt resolve org.jboss.ejb3.embedded an any of the jars.

      I have partially fixed that by donwloading the full jboss AS5 beta - and eventually found a version of E:\jboss\jboss-5.0.0.Beta1\server\all\deployers\ejb3.deployer\jboss-ejb3.jar which had the org.jboss.ejb3.embedded package defined within in.

      couldnt find on the the EJB3 download at all.

      so i finally the code and it fails looking for the embedded-jboss-beans.xml.

      couldnt find one of these anywhere so i copied a default from one of the html files as this

      
      <?xml version="1.0" encoding="UTF-8"?>
      <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
      xmlns="urn:jboss:bean-deployer:2.0">
      <!-- Enable a JCA datasource available through JNDI -->
       <bean name="DefaultDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
       <property name="driverClass"><value>org.hsqldb.jdbcDriver</value></property>
       <property name="connectionURL"><value>jdbc:hsqldb:.</value></property>
       <property name="userName"><value>sa</value></property>
       <property name="jndiName"><value>java:/DefaultDS</value></property>
       <property name="minSize"><value>0</value></property>
       <property name="maxSize"><value>10</value></property>
       <property name="blockingTimeout"><value>1000</value></property>
       <property name="idleTimeout"><value>50000</value></property>
       <property name="transactionManager"><inject bean="TransactionManager"/></property>
       <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
       <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
       </bean>
      
       <bean name="DefaultDS" class="java.lang.Object">
       <constructor factoryMethod="getDatasource">
       <factory bean="DefaultDSBootstrap"/>
       </constructor>
       </bean>
      
      
      </deployment>
      
      


      this now fails as it cant find a parser

      Exception in thread "main" java.lang.RuntimeException: org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/Documents%20and%20Settings/Will/Neils%20project/NeillsApp2/bin/embedded-jboss-beans.xml@4,37
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:386)
       at NeilsApp2.main(NeilsApp2.java:19)
      Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/Documents%20and%20Settings/Will/Neils%20project/NeillsApp2/bin/embedded-jboss-beans.xml@4,37
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:164)
       at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:133)
       at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:86)
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:373)
       ... 1 more
      Caused by: java.lang.IllegalStateException: Failed to create schema loader: org.apache.xerces.dom.DOMXSImplementationSourceImpl cannot be cast to org.w3c.dom.DOMImplementationSource
       at org.jboss.xb.binding.Util$5.run(Util.java:518)15:51:11,189 ERROR Util:517 - Failed to create schema loader.
      java.lang.ClassCastException: org.apache.xerces.dom.DOMXSImplementationSourceImpl cannot be cast to org.w3c.dom.DOMImplementationSource
       at org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance(Unknown Source)
       at org.jboss.xb.binding.Util$5.run(Util.java:512)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.jboss.xb.binding.Util.getXSImplementation(Util.java:488)
       at org.jboss.xb.binding.Util.loadSchema(Util.java:387)
       at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:168)
       at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:139)
       at org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver.resolve(DefaultSchemaResolver.java:247)
       at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:187)
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:323)
       at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:160)
       at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:133)
       at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:86)
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:373)
       at NeilsApp2.main(NeilsApp2.java:19)
      
       at java.security.AccessController.doPrivileged(Native Method)
       at org.jboss.xb.binding.Util.getXSImplementation(Util.java:488)
       at org.jboss.xb.binding.Util.loadSchema(Util.java:387)
       at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:168)
       at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:139)
       at org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver.resolve(DefaultSchemaResolver.java:247)
       at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:187)
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:323)
       at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:160)
       ... 4 more
      


      I have included just about every jar file in evey /lib and /client directores in the jboss as5 and other directories - no soap.

      just how are you supposed to get this blasted embedded server to run!! The documentation and tutorials dont help me - theres nothing to explain how to setup the ejb3 standlone properly strainght from the download .


      Can any help in simple terms for idiots (me), what we are supposed to do get the embedded server running outside of an AS as a standalone application.

      unhappy in ipswich !


        • 1. Re: what a job but at last !
          wiggy

          well goodness me thats been difficult. I think it would be as well to put a package together just for the embedded server in an accessible format.

          in the end i spotted something on one ofthe seam pages that discusses deploying on the ejb standalone. even better the seam distro ships with a /lib and an an embedded/conf directory with a working set of libraries and config files.

          relinked my app to the seam /lib and confdirectoroies and provided my own META-INF directory to load my own datasource mysql data source and persistence.xml.

          and by golly my simple hello world test stateless bean worked straight out of the box.


          Thats cost me the best part of 3 days trying to get that working

          It would be really useful to put a section on the Jboss site/wiki to help with poor little idiots such as myself who wnat to get started easily without all the pain

          only thing i could see in the log output was the first line - a Warn

          17:30:05,753 WARN [BeanSchemaBinding] You should use the 2.0 version of the Microcontainer xml. xmlns='urn:jboss:bean-deployer:2.0'
          ...
          


          which sounds possibly not ideal but doesnt stop it all working. Any one got idea what this is trying to tell me and which XML config needs changing?



          • 2. Re: help with embedded server - driving me nuts
            amit_dly

            Hi,

            I am also struggling with the same problem,and did not get thru with the error. I have tried all the combinations. If you have the notes how to configure and run Junit for EJB 3.0, please drop it here.

            Thanks in advance!!

            Amit Gupta

            • 3. Re: help with embedded server - driving me nuts
              guy_davis

              I would also very much like to know what this error pertains to and how to get around it. I see it as soon as I try to move the jboss-seam-booking war into our tomcat install which has the Jdom jar in the path.

              Wiggy, could you elaborate on what you did to fix this?

              Thanks.

              • 4. Re: help with embedded server - driving me nuts
                guy_davis

                In case someone else runs into this error, I narrowed the problem down to our using Xerces as the XML parser for Jdom. I removed xerces.jar and xml-apis.jar from our build process and the problem went away. In our JDom configuration code, I needed to use the org.jdom.adapters.JAXPDOMAdapter rather than the org.jdom.adapters.XercesDomAdapter.

                I'm not sure if JBoss doesn't like a particular version of Xerces or all versions, but switching to the JAXP parser (which is included in the JDK libraries) made this problem go away.

                I can now run the Seam examples using the embedded EJB3 library in an embedded version of Tomcat within our Java server application.

                Hope this helps,
                Guy