You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Neil Gray <na...@hotmail.com> on 2005/11/21 23:13:59 UTC

Problem with CMP-update code and Oracle

When I tried setting up a connection to Oracle 10g (10.1.0.x) for an entity 
bean I got
SQL errors from the update statements that were generated for the beans.
The SQL code generated is of the form:
update mytable set balance = case when ?  then ? else balance end where 
customername = ?

Oracle complains of an invalid relational operator; it doesn't seem to like 
"when ? then" where the "?" parameter just gets assigned a true/false value.

Is there any extra parameter that modifies the generated CMP code by 
database type?

_________________________________________________________________
Start something musical - 15 free ninemsn Music downloads! 
http://ninemsn.com.au/share/redir/adTrack.asp?mode=click&clientID=667&referral=HotmailTaglineNov&URL=http://www.ninemsn.com.au/startsomething


Re: GERONIMO-M5/deply/Unable to distribute ...: Unable to initialize, EJBContainer GBean: ejbName ...

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
I posted this to JIRA -- we need a better error message if nothing else.

Aaron

http://issues.apache.org/jira/browse/GERONIMO-1219

On 11/22/05, Triki <tr...@gmail.com> wrote:
> Hi,
> I can´t deploy:
>
>     Error: Unable to distribute helloworld.jar: Unable to initialize
>         EJBContainer GBean: ejbName
>         [helloworld.domain.avail.AvailabilityMovement] caused by -1
>
>
> All seems right:
>
> ejb-jar.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://java.sun.com/xml/ns/j2ee">
>     <enterprise-beans>
>         <entity>
>             <description>Movimiento de disponibilidad</description>
>
> <ejb-name>helloworld.domain.avail.AvailabilityMovement</ejb-name>
>             <home>helloworld.domain.avail.AvailabilityMovementHome</home>
>             <remote>helloworld.domain.avail.AvailabilityMovement</remote>
>
> <ejb-class>helloworld.domain.avail.AvailabilityMovementCMP</ejb-class>
>             <persistence-type>Container</persistence-type>
>             <prim-key-class>java.lang.String</prim-key-class>
>             <reentrant>false</reentrant>
>             <cmp-version>2.x</cmp-version>
>
> <abstract-schema-name>AvailabilityMovement</abstract-schema-name>
>             <cmp-field>
>                 <field-name>availabilityMovementId</field-name>
>             </cmp-field>
>             ...
>
> openejb-jar.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0"
> xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.0"
> xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
> xmlns:security="http://geronimo.apache.org/xml/ns/security-1.0"
> xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.openejb.org/xml/ns/openejb-jar-2.0"
> configId="helloworld" parentId="org/apache/geronimo/Server">
>     <naming:cmp-connection-factory>
>         <naming:resource-link>TrkSiTravel</naming:resource-link>
>     </naming:cmp-connection-factory>
>     <enterprise-beans>
>         <entity>
>
> <ejb-name>helloworld.domain.avail.AvailabilityMovement</ejb-name>
>
> <jndi-name>helloworld.domain.avail.AvailabilityMovementHome</jndi-name>
>             <table-name>availability_movement</table-name>
>             <cmp-field-mapping>
>                 <cmp-field-name>availabilityMovementId</cmp-field-name>
>                 <table-column>availabilitymovementid</table-column>
>             </cmp-field-mapping>
>             ....
>
>
> geronimo.log:
>
> 18:53:56,265 DEBUG [Deployer] Deployment failed: plan=null,
> module=/usr2/geronimo/geronimo51/grupoiris/helloworld.jar
> org.apache.geronimo.common.DeploymentException: Unable to initialize
> EJBContainer GBean: ejbName [helloworld.domain.avail.AvailabilityMovement]
>         at
> org.openejb.deployment.CMPEntityBuilder.createBean(CMPEntityBuilder.java:188)
>         at
> org.openejb.deployment.CMPEntityBuilder.buildBeans(CMPEntityBuilder.java:108)
>         at
> org.openejb.deployment.OpenEJBModuleBuilder.addGBeans(OpenEJBModuleBuilder.java:518)
>         at
> org.openejb.deployment.OpenEJBModuleBuilder$$FastClassByCGLIB$$11bd7b20.invoke(<generated>)
>         at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>         at
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
>         at
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
>         at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:760)
>         at
> org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
>         at
> org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:36)
>         at
> org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
>         at
> org.apache.geronimo.j2ee.deployment.ModuleBuilder$$EnhancerByCGLIB$$2e9d1ba5.addGBeans(<generated>)
>         at
> org.apache.geronimo.j2ee.deployment.EARConfigBuilder.buildConfiguration(EARConfigBuilder.java:384)
>         at
> org.apache.geronimo.j2ee.deployment.EARConfigBuilder$$FastClassByCGLIB$$38e56ec6.invoke(<generated>)
>         at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>         at
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
>         at
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
>         at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:760)
>         at
> org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
>         at
> org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:36)
>         at
> org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
>         at
> org.apache.geronimo.deployment.ConfigurationBuilder$$EnhancerByCGLIB$$3a8a2417.buildConfiguration(<generated>)
>         at org.apache.geronimo.deployment.Deployer.deploy(Deployer.java:190)
>         at org.apache.geronimo.deployment.Deployer.deploy(Deployer.java:87)
>         at
> org.apache.geronimo.deployment.Deployer$$FastClassByCGLIB$$734a235d.invoke(<generated>)
>         at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>         at
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
>         at
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
>         at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:795)
>         at
> org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:180)
>         at
> org.apache.geronimo.kernel.KernelGBean.invoke(KernelGBean.java:125)
>         at
> org.apache.geronimo.kernel.KernelGBean$$FastClassByCGLIB$$1cccefc9.invoke(<generated>)
>         at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>         at
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
>         at
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
>         at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:795)
>         at
> org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:180)
>         at
> org.apache.geronimo.kernel.jmx.MBeanServerDelegate.invoke(MBeanServerDelegate.java:117)
>         at
> javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
>         at
> javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
>         at
> javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
>         at
> javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
>         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
> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
>         at sun.rmi.transport.Transport$1.run(Transport.java:153)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
>         at
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
>         at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
>         at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
>         at
> org.openejb.entity.cmp.CMPInstanceContextFactory.<init>(CMPInstanceContextFactory.java:127)
>         at
> org.openejb.deployment.CMPContainerBuilder.buildIt(CMPContainerBuilder.java:311)
>         at
> org.openejb.deployment.AbstractContainerBuilder.createConfiguration(AbstractContainerBuilder.java:354)
>         at
> org.openejb.deployment.CMPEntityBuilder.createBean(CMPEntityBuilder.java:185)
>
> any idea?
>
> Thank's in advance.
>

GERONIMO-M5/deply/Unable to distribute ...: Unable to initialize, EJBContainer GBean: ejbName ...

Posted by Triki <tr...@gmail.com>.
Hi,
I can´t deploy:

    Error: Unable to distribute helloworld.jar: Unable to initialize
        EJBContainer GBean: ejbName
        [helloworld.domain.avail.AvailabilityMovement] caused by -1


All seems right:

ejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/j2ee">
    <enterprise-beans>
        <entity>
            <description>Movimiento de disponibilidad</description>
            
<ejb-name>helloworld.domain.avail.AvailabilityMovement</ejb-name>
            <home>helloworld.domain.avail.AvailabilityMovementHome</home>
            <remote>helloworld.domain.avail.AvailabilityMovement</remote>
            
<ejb-class>helloworld.domain.avail.AvailabilityMovementCMP</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.String</prim-key-class>
            <reentrant>false</reentrant>
            <cmp-version>2.x</cmp-version>
            
<abstract-schema-name>AvailabilityMovement</abstract-schema-name>
            <cmp-field>
                <field-name>availabilityMovementId</field-name>
            </cmp-field>
            ...

openejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0" 
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.0" 
xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0" 
xmlns:security="http://geronimo.apache.org/xml/ns/security-1.0" 
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.openejb.org/xml/ns/openejb-jar-2.0" 
configId="helloworld" parentId="org/apache/geronimo/Server">
    <naming:cmp-connection-factory>
        <naming:resource-link>TrkSiTravel</naming:resource-link>
    </naming:cmp-connection-factory>
    <enterprise-beans>
        <entity>
            
<ejb-name>helloworld.domain.avail.AvailabilityMovement</ejb-name>
            
<jndi-name>helloworld.domain.avail.AvailabilityMovementHome</jndi-name>
            <table-name>availability_movement</table-name>
            <cmp-field-mapping>
                <cmp-field-name>availabilityMovementId</cmp-field-name>
                <table-column>availabilitymovementid</table-column>
            </cmp-field-mapping>
            ....


geronimo.log:

18:53:56,265 DEBUG [Deployer] Deployment failed: plan=null, 
module=/usr2/geronimo/geronimo51/grupoiris/helloworld.jar
org.apache.geronimo.common.DeploymentException: Unable to initialize 
EJBContainer GBean: ejbName [helloworld.domain.avail.AvailabilityMovement]
        at 
org.openejb.deployment.CMPEntityBuilder.createBean(CMPEntityBuilder.java:188)
        at 
org.openejb.deployment.CMPEntityBuilder.buildBeans(CMPEntityBuilder.java:108)
        at 
org.openejb.deployment.OpenEJBModuleBuilder.addGBeans(OpenEJBModuleBuilder.java:518)
        at 
org.openejb.deployment.OpenEJBModuleBuilder$$FastClassByCGLIB$$11bd7b20.invoke(<generated>)
        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
        at 
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
        at 
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
        at 
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:760)
        at 
org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
        at 
org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:36)
        at 
org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
        at 
org.apache.geronimo.j2ee.deployment.ModuleBuilder$$EnhancerByCGLIB$$2e9d1ba5.addGBeans(<generated>)
        at 
org.apache.geronimo.j2ee.deployment.EARConfigBuilder.buildConfiguration(EARConfigBuilder.java:384)
        at 
org.apache.geronimo.j2ee.deployment.EARConfigBuilder$$FastClassByCGLIB$$38e56ec6.invoke(<generated>)
        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
        at 
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
        at 
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
        at 
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:760)
        at 
org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
        at 
org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:36)
        at 
org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
        at 
org.apache.geronimo.deployment.ConfigurationBuilder$$EnhancerByCGLIB$$3a8a2417.buildConfiguration(<generated>)
        at org.apache.geronimo.deployment.Deployer.deploy(Deployer.java:190)
        at org.apache.geronimo.deployment.Deployer.deploy(Deployer.java:87)
        at 
org.apache.geronimo.deployment.Deployer$$FastClassByCGLIB$$734a235d.invoke(<generated>)
        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
        at 
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
        at 
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
        at 
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:795)
        at 
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:180)
        at 
org.apache.geronimo.kernel.KernelGBean.invoke(KernelGBean.java:125)
        at 
org.apache.geronimo.kernel.KernelGBean$$FastClassByCGLIB$$1cccefc9.invoke(<generated>)
        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
        at 
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
        at 
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
        at 
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:795)
        at 
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:180)
        at 
org.apache.geronimo.kernel.jmx.MBeanServerDelegate.invoke(MBeanServerDelegate.java:117)
        at 
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
        at 
javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
        at 
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1348)
        at 
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
        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 
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
        at sun.rmi.transport.Transport$1.run(Transport.java:153)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
        at 
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
        at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
        at 
org.openejb.entity.cmp.CMPInstanceContextFactory.<init>(CMPInstanceContextFactory.java:127)
        at 
org.openejb.deployment.CMPContainerBuilder.buildIt(CMPContainerBuilder.java:311)
        at 
org.openejb.deployment.AbstractContainerBuilder.createConfiguration(AbstractContainerBuilder.java:354)
        at 
org.openejb.deployment.CMPEntityBuilder.createBean(CMPEntityBuilder.java:185)

any idea?

Thank's in advance.

Re: Problem with CMP-update code and Oracle

Posted by Matt Hogstrom <ma...@hogstrom.org>.
This is a problem in the code that is generated.  TranQL uses SQL-92 format by 
default and that is not workable for DB2 or Oracle (granted, we probably used 
the wrong default.  You need to add a syntax factory to the deployment plan to 
generate the correct code.  Have you tried the Oracle or DB2 syntax factories? 
Etierh one should work.  I would try the Oracle one first, if that is a problem 
try DB2.  Please post back your results so we can fix it.

The problem is that the SQL92 specification was poorly written and the CASE WHEN 
  statements could use either a syntax in the form of CASE WHEN ? (assuming a 
boolean) or CASE WHEN 1 = ? where one would require an lvalue in this case a 1 
to complete the boolean comparison.  Apparently both DB2 and Oracle assume that 
one will provide a complete syntax.  I believe the DB2 driver has this as well 
as the Oracle one.

Here is the syntax as snipped from the DayTrader deployment plan.

             <!--
             ##
             ##  C o n n e c t i o n  F a c t o r y  D e f i n i t i o n
             ##
             ##
             ##
             -->
             <cmp-connection-factory>
                 <resource-link>jdbc/TradeDataSource</resource-link>
             </cmp-connection-factory>

<!--  For DB2 database users uncomment the following line.
 
<ejb-ql-compiler-factory>org.tranql.ejbcompiler.DB2EJBQLCompilerFactory</ejb-ql-compiler-factory>
 
<db-syntax-factory>org.tranql.sql.db2.DB2DBSyntaxFactory</db-syntax-factory>
-->

<!--  For Oracle database users uncomment the following line.
 
<ejb-ql-compiler-factory>org.tranql.ejbcompiler.OracleQLCompilerFactory</ejb-ql-compiler-factory>
 
<db-syntax-factory>org.tranql.sql.oracle.OracleDBSyntaxFactory</db-syntax-factory>
-->


Neil Gray wrote:
> When I tried setting up a connection to Oracle 10g (10.1.0.x) for an 
> entity bean I got
> SQL errors from the update statements that were generated for the beans.
> The SQL code generated is of the form:
> update mytable set balance = case when ?  then ? else balance end where 
> customername = ?
> 
> Oracle complains of an invalid relational operator; it doesn't seem to 
> like "when ? then" where the "?" parameter just gets assigned a 
> true/false value.
> 
> Is there any extra parameter that modifies the generated CMP code by 
> database type?
> 
> _________________________________________________________________
> Start something musical - 15 free ninemsn Music downloads! 
> http://ninemsn.com.au/share/redir/adTrack.asp?mode=click&clientID=667&referral=HotmailTaglineNov&URL=http://www.ninemsn.com.au/startsomething 
> 
> 
> 
> 
>