facebook

[Closed] EJB3 entity bean problem

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #271885 Reply

    Mehdi.b
    Member

    Hello !
    I’m french so excuse my possible langage faults 🙂

    I get the last myeclipse :
    Version: 5.5.1 GA
    Build id: 20070521-5.5.1-GA

    I try to generate EJB3 entity bean with your reverse engineering plugin. The generation looks working great !

    I work with an AS/400 server and DB2 database. I’m trying to genenrate a simple Table with a simple primary key and no foreign keys.

    The application server is JBoss 4.0.5.GA with EJB3 support.

    Here is my persistence.xml file

    
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
        version="1.0">
    
        <persistence-unit name="CRUD" transaction-type="JTA">
    
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/DB2400DS</jta-data-source>
    
            <properties>
    
                <property name="hibernate.dialect"
                    value="org.hibernate.dialect.DB2400Dialect" />
                <!--     <property name="hibernate.hbm2ddl.auto" value="update" /> -->
    
            </properties>
        </persistence-unit>
    </persistence>
    

    Here is the JBoss log deployement

    
    14:49:10,500 INFO  [Ejb3Deployment] EJB3 deployment time took: 47
    14:49:10,500 INFO  [JmxKernelAbstraction] installing MBean: persistence.units:jar=CRUD2.jar,unitName=CRUD with dependencies:
    14:49:10,500 INFO  [JmxKernelAbstraction]     jboss.jca:name=DB2400DS,service=DataSourceBinding
    14:49:10,500 INFO  [Ejb3Configuration] found EJB3 Entity bean: com.clemessy.cdam.crud.app.App
    14:49:10,515 WARN  [Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
    14:49:10,531 INFO  [Configuration] Reading mappings from resource: META-INF/orm.xml
    14:49:10,531 INFO  [Ejb3Configuration] [PersistenceUnit: CRUD] no META-INF/orm.xml found
    14:49:10,531 INFO  [AnnotationBinder] Binding entity from annotated class: com.clemessy.cdam.crud.app.App
    14:49:10,531 INFO  [EntityBinder] Bind entity com.clemessy.cdam.crud.app.App on table APP
    14:49:10,546 INFO  [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    14:49:10,546 INFO  [InjectedDataSourceConnectionProvider] Using provided datasource
    14:49:10,546 INFO  [SettingsFactory] RDBMS: DB2 UDB for AS/400, version: 05.03.0000 V5R3m0
    14:49:10,546 INFO  [SettingsFactory] JDBC driver: AS/400 Toolbox for Java JDBC Driver, version: 5.0
    14:49:10,546 INFO  [Dialect] Using dialect: org.hibernate.dialect.DB2400Dialect
    14:49:10,546 INFO  [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
    14:49:10,546 INFO  [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
    14:49:10,562 INFO  [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
    14:49:10,562 INFO  [SettingsFactory] Automatic flush during beforeCompletion(): disabled
    14:49:10,562 INFO  [SettingsFactory] Automatic session close at end of transaction: disabled
    14:49:10,562 INFO  [SettingsFactory] Scrollable result sets: enabled
    14:49:10,562 INFO  [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
    14:49:10,578 INFO  [SettingsFactory] Connection release mode: auto
    14:49:10,578 INFO  [SettingsFactory] Default batch fetch size: 1
    14:49:10,578 INFO  [SettingsFactory] Generate SQL with comments: disabled
    14:49:10,578 INFO  [SettingsFactory] Order SQL updates by primary key: disabled
    14:49:10,578 INFO  [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    14:49:10,578 INFO  [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
    14:49:10,578 INFO  [SettingsFactory] Query language substitutions: {}
    14:49:10,578 INFO  [SettingsFactory] JPA-QL strict compliance: enabled
    14:49:10,578 INFO  [SettingsFactory] Second-level cache: enabled
    14:49:10,578 INFO  [SettingsFactory] Query cache: disabled
    14:49:10,578 INFO  [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
    14:49:10,578 INFO  [SettingsFactory] Optimize cache for minimal puts: disabled
    14:49:10,578 INFO  [SettingsFactory] Structured second-level cache entries: disabled
    14:49:10,578 INFO  [SettingsFactory] Statistics: disabled
    14:49:10,578 INFO  [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
    14:49:10,578 INFO  [SettingsFactory] Default entity-mode: pojo
    14:49:10,578 INFO  [SessionFactoryImpl] building session factory
    14:49:10,578 INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
    14:49:10,578 INFO  [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
    14:49:10,578 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=CRUD2.jar,name=AppFacade,service=EJB3 with dependencies:
    14:49:10,578 INFO  [JmxKernelAbstraction]     persistence.units:jar=CRUD2.jar,unitName=CRUD
    14:49:10,609 INFO  [EJBContainer] STARTED EJB: com.clemessy.cdam.crud.app.AppFacade ejbName: AppFacade
    14:49:10,625 INFO  [EJB3Deployer] Deployed: file:/C:/Program Files/jboss-4.0.5.GA/server/default/deploy/CRUD2.jar/
    

    As you can see i have 2 problems

    WARN  [Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.

    and

    
    INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
    

    How do i fix them ?

    I added a simple printHello to test the session bean.

    here is the client side

    
    AppFacadeRemote appRemote;
            
            try {
                
                Context ctx = new InitialContext();
                
                appRemote = (AppFacadeRemote) ctx.lookup("AppFacade/remote");
                
    
                System.out.println(appRemote.printHello());
                
                App a = appRemote.findById("EBO");
                System.out.println(a.getLibelle());
                
                
                
            } catch (NamingException e) {
                System.out.println("Erreur");
                e.printStackTrace();
            }
    
            System.out.println("End");
        }
    

    The printHello works without problems but findById don’t.

    The error message

    
    Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
        at $Proxy0.findById(Unknown Source)
        at com.clemessy.cdam.client.ClientCRUD2.main(ClientCRUD2.java:27)
    Caused by: java.lang.ClassNotFoundException: [Ljava.lang.StackTraceElement;
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:50)
        at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:139)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
        at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1624)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
        at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
        at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
        at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
        at org.jboss.remoting.Client.invoke(Client.java:525)
        at org.jboss.remoting.Client.invoke(Client.java:488)
        at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:77)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
        ... 2 more
    

    I added these libraries for the EJB3 project

    
    C:\Program Files\jboss-4.0.5.GA\server\default\lib\ejb3-persistence.jar
    C:\Program Files\jboss-4.0.5.GA\server\default\deploy\ejb3.deployer\jboss-ejb3x.jar
    C:\Program Files\jboss-4.0.5.GA\server\default\deploy\ejb3.deployer\jboss-ejb3.jar

    …and this for the client side

    C:\Program Files\jboss-4.0.5.GA\client\jboss-aspect-jdk50-client.jar
    C:\Program Files\jboss-4.0.5.GA\client\jbossall-client.jar
    C:\Program Files\jboss-4.0.5.GA\client\jboss-aop-jdk50-client.jar

    a hint…

    
    public App findById(String id) {
            EntityManagerHelper.log("finding App instance with id: " + id,
                    Level.INFO, null);
            try {
                App instance = entityManager.find(App.class, id);
                return instance;
            } catch (RuntimeException re) {
                EntityManagerHelper.log("find failed", Level.SEVERE, re);
                throw re;
            }
        }
    

    if i remove this line :

    EntityManagerHelper.log("finding App instance with id: " + id,
                    Level.INFO, null);

    this function will work without any problems !

    BUT this technique won’t work with save/update/delete functions…. 🙁

    Somebody can specify precisely which libraries i have to use ?

    If anybody can help me, i would be grateful !!!! 🙂

    Best regards !

    #271928

    Riyad Kalla
    Member

    Before you go too far down this path, try using Toplink as your EJB3/JPA persistence provider, it provides a much better implementation of the Java EE 5 persistence spec.

    Then retry your example again and see if it’s behaving better. Also I noticed that during the RMI call to narrow the object, you are getting a class-not-found exception for a core platform class… are you running MyEclipse and JBoss with different JDKs? You might try and force them to run with the same JDK and see if that resolves the issue.

    #272233

    Mehdi.b
    Member

    Thank you, this was a JDK versionning problem !

    #272250

    Riyad Kalla
    Member

    I’m glad it’s working now.

    #273326

    yulun74
    Member

    @Mehdi.b wrote:

    Thank you, this was a JDK versionning problem !

    I have the same problem with JBoss 4.0.5 with JDK 1.5.0_11.
    Could you please specify how you get that resolve?
    Thank you…

    #273511

    Mehdi.b
    Member

    Hello yulun74
    You have to be sure that you use the right jdk version with “java -version” command.
    Personally, i removed all jre/jdk of my computer and reinstall it after… I’ve got the jre 1.6 release ..
    Now, I use the new release of jboss (4.2.1) with jdk 1.5.0_12 and all works fine 🙂
    Hope i helped you..

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: [Closed] EJB3 entity bean problem

You must be logged in to post in the forum log in