25 February 2015

NetBeans hints (updated)

Your first NetBeans project
  1. On the start page click the Learn & Discover tab
  2. Under Demo's and Tutorials select Java SE applications
  3. Start the Java Quick Start Tutorial 
NetBeans 7.4 Developer Guide
If you're searching how to do someting in netbeans just type it in the ... search box, it will not only search in your project,  but also in the online help.
Keyboard shortcuts
  • view, search & change shortcuts: tools => options => keymap
    • You can set the keymap to a profile from another IDE (Eclipse, IntelliJ...) here as well.
  • help => keyboard shortcuts card. The pdf that is shown, lives in
    netbeansInstallDir
    /nb/shortcuts.pdf. 
  • Some additional useful shortcuts:
    • Go to
      • to definition: CTRL click
        • to implementation: CTRL ALT click
    • Edit
      • Code completion
        • autocomplete popup (+ javadoc): CTRL SPACE
        • javadoc inline popup: CTRL SHIFT SPACE
          • ALT F1 to see in browse
          • Netbeans bundles plenty of javadoc you can browse supplied javadoc for your project libraries from help>Javadoc references
        • complete to recently typed word: CTRL k
      • Add semicolon at end of line:  CTRL ;
      • Add new line below + go there: SHIFT ENTER
    • View
      • fold/unfold code: CTRL –/+
      • members/herarchy of current selection: CTRL/ALT SHIFT F12
Running code
  • After you ran a program, and corrected some errors Rerun using the >> buttons.

  • The lighter double arrows below allow you to rerun with different parameters. You can change the arguments you run with in the Ant properties window.
 
  • Similar options are available for (individual) tests.
    • You can also launch an individual test by  positioning the cursor in the method and selecting "Run focused test" from the right click menu. 


Samples
Netbeans comes with plenty of sample projects for you to explore

HTTP Monitor

In the properties of your Server you can enable  the HTTP monitor.
When the server receives an HTTP request, NetBeans will show a window with all request (but not all response) details. (You may have to undeploy/redeploy your webapp for the monitor to show up).
Additionally,  if you use the internal browser (or the NetBeans Chrome plugin) you can use Window > Web > Network Monitor (NetBeans >= 7.4). It is does not show all client side traffic but is targeted at in-page initiated traffic (REST, websockets) and failed requests.

26 January 2015

18 January 2015

Glassfish missing DataSource: Table/View XXX does not exist

I have a little old webapp connecting to a DB using a glassfish ConnectionPool.
This used to run fine but on a more recent glassfish (4.0) I do net get a good datasource from Glassfish, resulting in a Table/View <name> does not exist error message (the message is a general symptom for a failed DB connection, which can have many other reasons).
The problem exists if I configure the DataSource in web.xml and also if I inject it using @Resource.
The solution is to explicitly map the application reference to the JNDI name in WEB-INF/glassfish-web.xml:

<resource-ref>
    <res-ref-name>jdbc/theDB</res-ref-name>
    <jndi-name>jdbc/theDB</jndi-name>
</resource-ref>  

If you don't, Glassfish returns a ConnectionPoolDataSource. Some people corrected this by refering in their web.xml to the ConnectionPoolDataSource, but the solution above will work both for web.xml and Resource injection.

servlets / JSP links (updated)

9 January 2015

Java EE web technology version history (updated)


JSR numbers are included as links.
Servers are webcontainers.Take care, web containers do not include JSF. You have to add it yourself or use an enterprise application server. Enterprise application servers are included in the
complete Java EE version overview.

Java EEservletJSP     ELJSTLJSF    MVCServer       What’s new
2.1
1.0

iPlanet
jetty 1
ServletContext, RequestDispatcher
1.2
2.2
1.1
tomcat 3.3
jetty 3
war
1.3
53 2.3
53 1.2
tomcat 4.1
jetty 4
filters
1.4
154 2.4
152 2.0
1.0
52 1.1
tomcat 5.5
jetty 5
5
2.5
245 2.1
2.1
1.2
127 1.2
tomcat 6
jetty 6
annotations
6
315 3.0
2.2
2.2
1.2
314 2.0
tomcat 7
jetty 8
asynchronous servlets, EL method calls, more...
7
340 3.1
 341 3.0

344 2.2

tomcat 8
jetty 9.1
HTML 5, non blocking (Listener) servlet IO
8
369 4.0



371 1.0tomcat 9 (future)HTTP/2

Java EE component versions overview (edit)

The table below lists the components in latest versions of the Java Enterprise Edition.

  • I put the most important changes in red.
  • Components with a (version number) between brackets are  proposed for removal in a future release.
    • JAX-WS is intended to replace JAX-RPC
  • An x indicates a technology is removed from the specification
    • JSR's are shown as hyperlinked numbers.
    • SE indicates that an API was moved to the standard edition 
      • eventually followed with the version number
      • Java SE version history is in a separate post
    • Web technologies are in a separate post
    • EJB history is in a separate post
    • I added some application servers at the bottom of the table. 
    Technologies151
    J2EE 1.4

    2003
    244
    Java EE5

    2006
    316
    Java EE6

    2009
    342
    Java EE7

    4/2013
    366
    Java EE8
    Java SE59 1.4176 5270 6336 7337 8
    EJB153 2.1220 3.0318 3.1345 3.2
    Servlet/JSP2.42.53.03.14.0
    EE Management77 1.0


    373 2.0
    JMS 914 1.1


    343 2.0368 2.1
    JTA 9071.01.1
    1.2
    JavaMail 9191.31.4

    1.5
    Connector (JCA)112 1.51.5322 1.61.7
    Java Activation Framework
    (JAF)
    925
    1.01.1SE:1.1.1
    Web Services 1091.11.21.3
    Web Services Metadata 181
    2.0SE
    JAX-RPC 1011.1

    (1.1)x
    JAX-WS (SOAP) 2241.02.0SE (2.1)SE (2.2)
    JAX-RS (REST)

    311 1.1
    Jersey 1.1.5
    339 2.0370 2.1
    JAXB 222
    2.0SE:2.1
    JSON-P  353 1.0374 2.1
    JSON-B 367
     1.0
    JAXR (UDDI Registry)1.0
    (1.0)x
    SOAP with attachments
    (SAAJ)
    67
    1.21.3SE
    StAX 173
    1.0SE
    JMX1.2SESE
    container authorisation (JACC) 1151.01.11.41.5
    container authentication (JASPIC) 196

    1.01.1
    Security 375



    1.0
    Common annotations 250
    1.01.11.2
    Java Persistence (JPA)
    1.0317 2.0338 2.1
    Bean Validation

    303 1.0349 1.1
    Managed Beans

    1.0
    Interceptors
    1.01.11.2
    CDI for Java EE

    299 1.0346 1.1365 2.0
    DI for Java 330

    1.0
    Concurrency utilities 236


    1.0
    State management 350


    1.0
    Batch processing 352


    1.0
    JCache 107



    1.0
    Servers
    Sun JSAS89.1
    Glassfish23 (12/2009)4 (5/2013)
    JBoss / WildFly457 (7/2011)8 (2/2014)
    IBM Websphere678 (6/2011)-
    Oracle Weblogic91012.1.1
    (12/2011)
    12.1.4 (2015?)
    Apache Geronimo123 (7/2012)-
    • J2EE 1.3(2001) introduced
      • Message Driven  Beans
      • Local interfaces
    • Profiles are a subset of the spec.
      • Java EE Web profile (only profile currently defined)
        • contents
          • java SE
          • web technologies,
          •  JTA, common annotations, JPA, validation, managed beans, interceptors, CDI, DI
          • EJB Lite
            • Stateless, Stateful, and Singleton session beans
              • asynchronous session beans (EJB 3.2)
            • only local EJB interfaces or no interfaces
            • interceptors
            • security
            • transactions
            • non persistent timer only (EJB 3.2)
            • No Message Driven beans and remote invocation.
          • JAX-RS (Java EE7)
        • implemented by
          • Resin 4
          • Apache TomEE