Hello,

I'm trying to make simple stateless session bean to connect to PostgreSQL
database. I've read the instructions at this page: 
http://openejb.apache.org/databases.html
http://openejb.apache.org/databases.html 

When I add the <Resource> tag in the openejb.xml file, I can not start the
server anymore.

I get the following exceptions:

org.apache.openejb.OpenEJBException: Unable to read OpenEJB configuration
file at /opt/openejb-3.0-beta-1/conf/openejb.xml: unexpected element
(uri:"http://www.openejb.org/System/Configuration";, local:"Resourse").
Expected elements are
<{http://www.openejb.org/System/Configuration}Container>,<{http://www.openejb.org/System/Configuration}ConnectionManager>,<{http://www.openejb.org/System/Configuration}SecurityService>,<{http://www.openejb.org/System/Configuration}ProxyFactory>,<{http://www.openejb.org/System/Configuration}Resource>,<{http://www.openejb.org/System/Configuration}TransactionManager>,<{http://www.openejb.org/System/Configuration}JndiProvider>,<{http://www.openejb.org/System/Configuration}Connector>,<{http://www.openejb.org/System/Configuration}Deployments>
        at
org.apache.openejb.config.sys.JaxbOpenejb.readConfig(JaxbOpenejb.java:129)
        at
org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:207)
        at 
org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:206)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
        at org.apache.openejb.server.Server.init(Server.java:63)
        at org.apache.openejb.server.Main.initServer(Main.java:155)
        at org.apache.openejb.server.Main.main(Main.java:128)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.openejb.cli.MainImpl.main(MainImpl.java:151)
        at org.apache.openejb.cli.Bootstrap.main(Bootstrap.java:102)
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.openejb.org/System/Configuration";, local:"Resourse").
Expected elements are
<{http://www.openejb.org/System/Configuration}Container>,<{http://www.openejb.org/System/Configuration}ConnectionManager>,<{http://www.openejb.org/System/Configuration}SecurityService>,<{http://www.openejb.org/System/Configuration}ProxyFactory>,<{http://www.openejb.org/System/Configuration}Resource>,<{http://www.openejb.org/System/Configuration}TransactionManager>,<{http://www.openejb.org/System/Configuration}JndiProvider>,<{http://www.openejb.org/System/Configuration}Connector>,<{http://www.openejb.org/System/Configuration}Deployments>
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:523)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:199)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:194)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:71)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.childElement(Loader.java:65)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.childElement(StructureLoader.java:209)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:366)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:347)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:101)
        at 
org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
        at
org.apache.openejb.config.sys.JaxbOpenejb$NamespaceFilter.startElement(JaxbOpenejb.java:256)
        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
        at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
        at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
        at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:333)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:194)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:167)
        at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:120)
        at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:103)
        at
org.apache.openejb.config.sys.JaxbOpenejb.unmarshal(JaxbOpenejb.java:235)
        at
org.apache.openejb.config.sys.JaxbOpenejb.readConfig(JaxbOpenejb.java:124)
        ... 13 more


My openejb.xml looks like this, I have only added the <Resource> tag to the
end. I have not made any other modifications to the default configuration
file.

<openejb>

<Container id="Default CMP Container" ctype="CMP_ENTITY">
# This container can service CMP 1.1 and 2.x Entity Beans
#
# Persistence is achived by taking the entity beans deployed
# and internally readapting them to the new EJB 3.0 JPA (Java
# Persistence API) specification.  It is possible, though
# not well documented, to mix in newer JPA concepts with
# old style Entity beans allowing you to slowly transition
# your entities to JPA.  Aggressively inquiring on the
# users@openejb.apache.org about this feature will help
# us generate better documentation.
# ---------

# ConnectorName is he id of the Connector element which
# should provide connectivity for this CMP Container

    ConnectorName  Default JDBC Database

</Container>


<Container id="Default BMP Container" ctype="BMP_ENTITY">

# Specifies the size of the bean pools for this
# bmp entity container.

    PoolSize 10

</Container>

<Container id="Default Stateful Container" ctype="STATEFUL">
#  The passivator is responsible for writing beans to disk
#  at passivation time. Different passivators can be used
#  by setting this property to the fully qualified class name
#  of the PassivationStrategy implementation. The passivator
#  is not responsible for invoking any callbacks or other
#  processing, its only responsibly is to write the bean state
#  to disk.
#
#  Known implementations:
#     org.apache.openejb.core.stateful.RAFPassivater
#     org.apache.openejb.core.stateful.SimplePassivater

    Passivator   org.apache.openejb.core.stateful.SimplePassivater

#  Specifies the time to wait between invocations. This
#  value is measured in minutes.  A value of 5 would
#  result in a time-out of 5 minutes between invocations.

    TimeOut  20

#  Specifies the size of the bean pools for this
#  stateful SessionBean container.

    PoolSize  500

#  Property name that specifies the number of instances
#  to passivate at one time when doing bulk passivation.
#  Must be less than the PoolSize.

    BulkPassivate  50

</Container>



<Container id="Default Stateless Container" ctype="STATELESS">
#  Specifies the time to wait between invocations. This
#  value is measured in milliseconds.  A value of 5 would
#  result in a time-out of 5 milliseconds between invocations.
#  A value of zero would mean no timeout.

    TimeOut  0

#  Specifies the size of the bean pools for this
#  stateless SessionBean container.

    PoolSize  10

#  StrictPooling tells the container what to do when the pool
#  reaches it's maximum size and there are incoming requests
#  that need instances.
#
#  With strict pooling, requests will have to wait for instances
#  to become available.  The pool size will never grow beyond the
#  the set PoolSize value.
#
#  Without strict pooling, the container will create temporary
#  instances to meet demand.  The instances will last for just one
#  method invocation and then are removed.

    StrictPooling  true

</Container>

<Container id="Default MDB Container" ctype="MESSAGE">
# The resource adapter delivers messages to the container

    ResourceAdapter Default JMS Resource Adapter

# Specifies the activation spec class

    ActivationSpecClass org.apache.activemq.ra.ActiveMQActivationSpec

# Specifies the maximum number of bean instances that are
# allowed to exist for each MDB deployment.

    InstanceLimit 10
</Container>



<!--
# For more examples of database configuration see:
# http://openejb.apache.org/databases.html
-->

<Connector id="Default JDBC Database" >
    JdbcDriver org.hsqldb.jdbcDriver
    JdbcUrl jdbc:hsqldb:file:hsqldb
    UserName sa
    Password
</Connector>

<Connector id="Default Unmanaged JDBC Database">
    JdbcDriver org.hsqldb.jdbcDriver
    JdbcUrl jdbc:hsqldb:file:hsqldb
    UserName sa
    Password
</Connector>

<Resource id="Default JMS Resource Adapter">
    # Broker configuration
    BrokerXmlConfig broker:(tcp://localhost:61616)?useJmx=false

    # Broker address
    ServerUrl vm://localhost?async=true
</Resource>


<Resourse id="PostgreSQL Database" type="DataSource">
  JdbcDriver  org.postgreql.Driver
  JdbcUrl     jdbc:postgresql://localhost/test
  UserName    postgres
  Password    pass
</Resourse>


<Connector id="Default JMS Connection Factory">

    ResourceAdapter Default JMS Resource Adapter

</Connector>

<!--
#
#  The <Deployments> element can be used to configure file
#  paths where OpenEJB should look for ejb jars or ear files.
#
#  See http://openejb.apache.org/deployments.html
#
#  The below entry is simply a default and can be changed or deleted
-->
<Deployments dir="apps/" />

</openejb>

Thanks.

-- 
View this message in context: 
http://www.nabble.com/How-to-configure-a-datasource--tf4666327.html#a13329788
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to