facebook

EJB3 Eval failing

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

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

    James_Hr
    Member

    In order to evaluate MyEclipseIDE 6 for EJB3 support I began by creating a test project TestEE5 w/new Web and EJB modules with the JPA enabled. I tested this deployment to JBoss 4.2.1 successfully to make sure the index.jsp would work fine and it did.

    Next, I created a com.test.persistence package and performed the Reverse EJB3 on a simple table (all options checked except “Use custom template”). As a simple test of this entity I added the following Add operatoin to index.jsp and deployed:

    TmpTrader tmpTrader = new TmpTrader(new Long(1), new Long(1), “AAA”, new Long(50));
    new TmpTraderFacade().save(tmpTrader);

    But, index.jsp now fails with the following JBoss trace:

    —–
    04:17:16,593 INFO [SessionFactoryObjectFactory] Factory name: persistence.units:ear=TestEE5.ear,jar=TestEE5EJB.jar,unitName=TestEE5EJBPU
    04:17:16,593 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
    04:17:16,609 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:ear=TestEE5.ear,jar=TestEE5EJB.jar,unitName=TestEE5EJBPU
    04:17:16,609 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
    04:17:16,609 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
    04:17:16,609 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
    04:17:16,609 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=TestEE5.ear,jar=TestEE5EJB.jar,name=TmpTraderFacade,service=EJB3 with dependencies:
    04:17:16,609 INFO [JmxKernelAbstraction] persistence.units:ear=TestEE5.ear,jar=TestEE5EJB.jar,unitName=TestEE5EJBPU
    04:17:16,765 INFO [EJBContainer] STARTED EJB: com.test.persistence.TmpTraderFacade ejbName: TmpTraderFacade
    04:17:16,890 INFO [EJB3Deployer] Deployed: file:/C:/dev/jboss-4.2.1.GA/server/default/deploy/TestEE5.ear/TestEE5EJB.jar/
    04:17:16,890 INFO [TomcatDeployer] deploy, ctxPath=/TestEE5Web, warUrl=…/deploy/TestEE5.ear/TestEE5Web.war/
    04:17:17,328 INFO [EARDeployer] Started J2EE application: file:/C:/dev/jboss-4.2.1.GA/server/default/deploy/TestEE5.ear/
    04:18:09,140 ERROR [STDERR] Sep 11, 2007 4:18:09 AM com.test.persistence.LogUtil log
    INFO: saving TmpTrader instance
    04:18:09,140 ERROR [STDERR] Sep 11, 2007 4:18:09 AM com.test.persistence.LogUtil log
    SEVERE: save failed
    java.lang.NullPointerException
    at com.test.persistence.TmpTraderFacade.save(TmpTraderFacade.java:29)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:61)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
    04:18:09,171 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException
    at com.test.persistence.TmpTraderFacade.save(TmpTraderFacade.java:29)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:61)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
    —–

    Apparently, the entityManager is null (see Line 29 in Bold) and the failure occurs on the invoke of entityManager.persist(). This is the code segment involved:

    —–
    package com.test.persistence;

    import java.util.List;
    import java.util.logging.Level;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;

    /**
    * Facade for entity TmpTrader.
    *
    * @see com.test.persistence.TmpTrader
    * @author MyEclipse Persistence Tools
    */
    @Stateless
    public class TmpTraderFacade implements TmpTraderFacadeLocal,
    TmpTraderFacadeRemote {
    // property constants
    public static final String TRADE_TYPE = “tradeType”;
    public static final String TRADE_SYMBOL = “tradeSymbol”;
    public static final String TRADE_SHARES = “tradeShares”;

    @PersistenceContext
    private EntityManager entityManager;

    public void save(TmpTrader transientInstance) {
    LogUtil.log(“saving TmpTrader instance”, Level.INFO, null);
    try {
    entityManager.persist(transientInstance);
    LogUtil.log(“save successful”, Level.INFO, null);
    } catch (RuntimeException re) {
    LogUtil.log(“save failed”, Level.SEVERE, re);
    throw re;
    }
    }
    —–

    The persistence definition is:

    —–
    <?xml version=”1.0″ encoding=”UTF-8″?>
    <persistence xmlns=”http://java.sun.com/xml/ns/persistence&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd&#8221; version=”1.0″>

    <persistence-unit name=”TestEE5EJBPU” transaction-type=”JTA”>
    <jta-data-source>java:patientpool</jta-data-source>
    </persistence-unit>

    </persistence>
    —–

    I really need a robust EJB 3 tool to demo to mgmt, so I need your help. I need to be able to Reverse Engineer tables on demand like above to keep up with on-going changes to the model and obviously it has to generate dependable code.

    Thanks,
    J

    #275413

    Loyal Water
    Member

    Can you export all 3 projects (EAR, Web, EJB) all to an archive and send it to me.

    #275423

    James_Hr
    Member

    Ok, I emailed the project export to support@genuitec.com with the same subject. Thanks, J

    #275482

    Loyal Water
    Member

    I got the project. Thanks.

    #275505

    James_Hr
    Member

    Per Riyad, I tried same on Glassfish v2 build 58 and it failed exactly the same way – below is the dump. In order to sell mgmt on my MyEclipseIDE proto type for their NEW development environment, I’m trying desparately to get a simple Web app up that utilizes an EJB3 service and entity with EE 5. The out-of-the-box Stateless fascade generated by MyEclipseIDE of the below entity would work nice for my prototype effort – just help me get this up and I’ll do the rest!

    Here is the simple table the test is mapping to.

    CREATE TABLE [TmpTrader] (
    [TradeKey] [numeric](18, 0) NOT NULL ,
    [TradeType] [numeric](18, 0) NULL ,
    [TradeSymbol] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [TradeShares] [numeric](18, 0) NULL ,
    CONSTRAINT [PK_TradeKey] PRIMARY KEY CLUSTERED
    (
    [TradeKey]
    ) WITH FILLFACTOR = 90 ON [PRIMARY]
    ) ON [PRIMARY]
    GO

    Glassfish dump:

    SEVERE: save failed
    java.lang.NullPointerException
    at com.eee.persistence.TmpTraderFacade.save(TmpTraderFacade.java:29)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java from :54)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
    at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:361)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
    at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Sep 12, 2007 3:03:01 PM org.apache.catalina.core.StandardWrapperValve log
    SEVERE: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception

    Thanks,
    J

    #275612

    James_Hr
    Member

    Thanks Riyad – It worked. Replacing:

    new TmpTraderFacade().save(tmpTrader);

    with this:

    InitialContext ctx = new InitialContext();
    TmpTraderFacadeRemote facade = (TmpTraderFacadeRemote) ctx.lookup(“com.test.TmpTraderFacadeRemote”);
    facade.save(tmpTrader);

    The lookup forced EntityManager to initialize properly so that injection of em allowed the save() to now work correct.

    J

    #279858

    Kevin
    Member

    MyEclipse folks, can you confirm whether you are addressing the null on EntityManager issue please?

    I am experincing the same issue. I reversed engineered the EJB persistence from the Myeclipse Derby DB Explorer and get the following trace:

    SEVERE: find failed
    java.lang.NullPointerException
    at uk.co.syntellect.svpm.states.SessionStateFacade.findById(SessionStateFacade.java:103)
    at uk.co.syntellect.svpm.client.SVPMClient.publish(SVPMClient.java:428)
    at uk.co.syntellect.svpm.client.SVPMClientCommandLine.start(SVPMClientCommandLine.java:70)
    at uk.co.syntellect.svpm.client.SVPMClientCommandLine.main(SVPMClientCommandLine.java:92)
    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:597)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:417)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
    at com.sun.enterprise.appclient.Main.main(Main.java:200)

    where the code is:

    package uk.co.syntellect.svpm.states;
    
    import java.util.List;
    import java.util.logging.Level;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    
    /**
     * Facade for entity SessionState.
     * 
     * @see uk.co.syntellect.svpm.states.SessionState
     * @author MyEclipse Persistence Tools
     */
    @Stateless
    public class SessionStateFacade implements SessionStateFacadeLocal,
            SessionStateFacadeRemote {
        // property constants
        public static final String SWITCHLINK_DN = "switchlinkDn";
        public static final String IS_LOGGED_IN = "isLoggedIn";
        public static final String ACD_STATE = "acdState";
        public static final String LAST_UPDATED_TIMESTAMP = "lastUpdatedTimestamp";
        public static final String LAST_CHANGE_IS_LOGGED_IN_TIMESTAMP = "lastChangeIsLoggedInTimestamp";
        public static final String LAST_CHANGE_ACD_STATE_TIMESTAMP = "lastChangeAcdStateTimestamp";
    
        @PersistenceContext
        private EntityManager entityManager;
    
        /**
         * Perform an initial save of a previously unsaved SessionState entity. All
         * subsequent persist actions of this entity should use the #update()
         * method.
         * 
         * @param entity
         *            SessionState entity to persist
         * @throws RuntimeException
         *             when the operation fails
         */
        public void save(SessionState entity) {
            LogUtil.log("saving SessionState instance", Level.INFO, null);
            try {
                entityManager.persist(entity);
                LogUtil.log("save successful", Level.INFO, null);
            } catch (RuntimeException re) {
                LogUtil.log("save failed", Level.SEVERE, re);
                throw re;
            }
        }
    
        /**
         * Delete a persistent SessionState entity.
         * 
         * @param entity
         *            SessionState entity to delete
         * @throws RuntimeException
         *             when the operation fails
         */
        public void delete(SessionState entity) {
            LogUtil.log("deleting SessionState instance", Level.INFO, null);
            try {
                entity = entityManager.getReference(SessionState.class, entity
                        .getId());
                entityManager.remove(entity);
                LogUtil.log("delete successful", Level.INFO, null);
            } catch (RuntimeException re) {
                LogUtil.log("delete failed", Level.SEVERE, re);
                throw re;
            }
        }
    
        /**
         * Persist a previously saved SessionState entity and return it or a copy of
         * it to the sender. A copy of the SessionState entity parameter is returned
         * when the JPA persistence mechanism has not previously been tracking the
         * updated entity.
         * 
         * @param entity
         *            SessionState entity to update
         * @returns SessionState the persisted SessionState entity instance, may not
         *          be the same
         * @throws RuntimeException
         *             if the operation fails
         */
        public SessionState update(SessionState entity) {
            LogUtil.log("updating SessionState instance", Level.INFO, null);
            try {
                SessionState result = entityManager.merge(entity);
                LogUtil.log("update successful", Level.INFO, null);
                return result;
            } catch (RuntimeException re) {
                LogUtil.log("update failed", Level.SEVERE, re);
                throw re;
            }
        }
    
        public SessionState findById(SessionStateId id) {
            LogUtil.log("finding SessionState instance with id: " + id, Level.INFO,
                    null);
            try {
                LogUtil.log("entityManager["+entityManager+"]", Level.INFO,null);
                
                [b][u]SessionState instance = entityManager.find(SessionState.class, id);[/u][/b]
                return instance;
    

    I am going to try the work around the other posters mentioned

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: EJB3 Eval failing

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