Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-3996

Assert error - code completion

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 11.2
    • None
    • cnd - Code Completion
    • None

    Description

      The problem started to happen after the Static function was added to the class DeclarationsFacade (code attached below).

      The code completion is trying to add the method findByNDEAArc. The list of options is shown. You use the cursor to find and select the right one, and then the error occurs.

      I shut down the NetBeans environment, and restarted afresh, and the same error appears.

      NOTE: I have now discovered that Static methods are not allowed in Stateless EJBs Nevertheless the exception shouldn't happen. The issue priority has been changed to minor.

      To confirm, when that static function is moved to a separate object, the issue doesn't occur.

       

      java.lang.AssertionError
      at com.sun.tools.javac.util.Assert.error(Assert.java:155)
      at com.sun.tools.javac.util.Assert.check(Assert.java:46)
      at com.sun.tools.javac.code.Scope$ScopeImpl.dble(Scope.java:410)
      at com.sun.tools.javac.code.Scope$ScopeImpl.enter(Scope.java:433)
      at com.sun.tools.javac.comp.MemberEnter.visitVarDef(MemberEnter.java:480)
      at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:972)
      at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:172)
      at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1191)
      at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:972)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:674)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:754)
      at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:778)
      at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1357)
      at org.netbeans.lib.nbjavac.services.NBAttr.visitBlock(NBAttr.java:78)
      at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1036)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:674)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:754)
      at org.netbeans.api.java.source.TreeUtilities.attributeTree(TreeUtilities.java:892)
      at org.netbeans.api.java.source.TreeUtilities.attributeTree(TreeUtilities.java:822)
      at org.netbeans.modules.editor.java.JavaCodeTemplateProcessor.type(JavaCodeTemplateProcessor.java:718)
      at org.netbeans.modules.editor.java.JavaCodeTemplateProcessor.instanceOf(JavaCodeTemplateProcessor.java:550)
      at org.netbeans.modules.editor.java.JavaCodeTemplateProcessor.getProposedValue(JavaCodeTemplateProcessor.java:399)
      at org.netbeans.modules.editor.java.JavaCodeTemplateProcessor.updateDefaultValues(JavaCodeTemplateProcessor.java:145)
      at org.netbeans.lib.editor.codetemplates.CodeTemplateInsertHandler.processTemplate(CodeTemplateInsertHandler.java:225)
      at org.netbeans.lib.editor.codetemplates.CodeTemplateManagerOperation.insert(CodeTemplateManagerOperation.java:273)
      at org.netbeans.lib.editor.codetemplates.api.CodeTemplate.insert(CodeTemplate.java:82)
      at org.netbeans.modules.editor.java.JavaCompletionItem.process(JavaCompletionItem.java:566)
      at org.netbeans.modules.editor.java.JavaCompletionItem.defaultAction(JavaCompletionItem.java:286)
      at org.netbeans.modules.editor.completion.CompletionImpl.dispatchKeyEvent(CompletionImpl.java:785)
      at org.netbeans.modules.editor.completion.CompletionImpl.keyPressed(CompletionImpl.java:386)
      at java.desktop/java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:258)
      at java.desktop/java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:257)
      at java.desktop/java.awt.Component.processKeyEvent(Component.java:6594)
      at java.desktop/javax.swing.JComponent.processKeyEvent(JComponent.java:2849)
      at java.desktop/java.awt.Component.processEvent(Component.java:6413)
      at java.desktop/java.awt.Container.processEvent(Container.java:2263)
      at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012)
      at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
      at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
      at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1950)
      at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:870)
      at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1139)
      at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1009)
      at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:835)
      at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4893)
      at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
      at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2762)
      at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
      at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
      at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
      at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
      at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
      at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
      [catch] at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

       

       

      DeclarationsFacade (edited

      package com.xxx.emcs_customs.sessionbeans;

      import com.xxx.emcs_customs.entities.Declarations;
      import java.util.Date;
      import java.util.List;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javax.ejb.Stateless;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import javax.persistence.Query;

      /**
      *

      • @author sjbro
        */
        @Stateless
        public class DeclarationsFacade extends AbstractFacade<Declarations> {

      private static final Logger LOG = Logger.getLogger(DeclarationsFacade.class.getName());

      @PersistenceContext(unitName = "EMCS_CustomsPU")
      private EntityManager em;

      @Override
      protected EntityManager getEntityManager()

      { return em; }

      public DeclarationsFacade()

      { super(Declarations.class); }

      // ***** ADDED ***** ADDED ***** ADDED *****

      @Override
      public void create(Declarations entity)

      { entity.setCreated(new Date()); entity.setUpdated(entity.getCreated()); super.create(entity); }

      @Override
      public void edit(Declarations entity)

      { entity.setUpdated(new Date()); super.edit(entity); }

      /**

      • Static method to obtain a DeclarationsFacade - for use when injection isn't available
      • @return
        */
        public static DeclarationsFacade lookupDeclarationsFacade()
        Unknown macro: { try { Context c = new InitialContext(); return (DeclarationsFacade) c.lookup("java:module/DeclarationsFacade"); }

        catch (NamingException ne) { LOG.log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } }

      public Declarations findByNDEAArc(String ndea, String arc)

      { Query q = em.createNamedQuery("Declarations.findByNDEAArc"); q.setParameter("ndea", ndea); q.setParameter("arc", arc); List<Declarations> list = q.getResultList(); // list can only ever be 0 or 1 rows return ( list.size() == 1 ? list.get(0) : null); }

      public Declarations findByNDEAConsignorLRN(String ndea, String consignorId, String lrn)

      { Query q = em.createNamedQuery("Declarations.findByNDEAConsignoridLrn"); q.setParameter("ndea", ndea); q.setParameter("consignorid", consignorId); q.setParameter("lrn", lrn); List<Declarations> list = q.getResultList(); // list can only ever be 0 or 1 rows return ( list.size() == 1 ? list.get(0) : null); }

      }

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            Steve B Stephen Brooksbank

            Dates

              Created:
              Updated:

              Slack

                Issue deployment