Screencast #30: Java EE 6 & GlassFish 3 using NetBeans 6.9 - 5 screencasts

This 5-part screencast shows how NetBeans 6.9 provides comprehensive tooling for Java EE 6 & GlassFish 3. The video tutorial starts with building a simple Java EE 6 application and evolves to add features from several new technologies such as Java Persistence API 2, Java Server Faces 2, Contexts & Dependency Injection, and Java API for RESTful Web services from the platform. Specifically, the different parts show:

  1. How to create a simple Java EE 6 application using JSP, Servlets 3, and EJB 3.1
  2. Reading values from a database table using Java Persistence API 2 POJO entities
  3. Create a template-based website using Facelets with Java Server Faces 2
  4. Use Contexts & Dependency Injection with JSF 2
  5. Publish a RESTful Web service using JAX-RS

Enjoy!

Note, this is a playlist of all the videos so click on little arrows (shown as "<" or ">") to view the different videos.

Please give us feedback on GlassFish Forums.

Technorati: screencast javaee6 glassfish tutorial netbeans

Comments:

Super! Thank you for screen-casts!

Posted by Alexander Lipatov on July 20, 2010 at 05:49 AM PDT #

I am trying to convert a web app to a client server app. I am using JavaFx and Netbeans 6.9. I have put Oracle's JDBC driver in the projects classpath. I generate code through the JavaFx composer but I can't seem to get the DeviceDriver to reconisze the driver.

Posted by Ian Parkin on July 22, 2010 at 11:41 PM PDT #

Ian,

DeviceDriver is on the client or server-side ?

Posted by Arun Gupta on July 28, 2010 at 08:04 AM PDT #

The DeviceDriver is on the client side. I resolved the problem by downloading a more updated JDBC driver. I was using Java 6 and the driver I was pointing to was ojdbc14.jar I downloaded ojdbc6.jar and it worked. Thanks.

Posted by Ian Parkin on July 28, 2010 at 11:16 PM PDT #

I enjoyed your presentaion yesterday at Dallas Tech Fest. Thank you so much!

I am working your examples, but cannot get the jUnit tests to work. I see tons of stuff on google with the same type warnings but cann't seem to find a fix. Have you seen this before?

init:
deps-module-jar:
deps-ear-jar:
deps-jar:
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
Compiling 1 source file to C:\\guptaDemo\\HelloWorld\\build\\test\\classes
compile-test-single:
WARNING: multiple versions of ant detected in path for junit
jar:file:/C:/Program%20Files%20(x86)/NetBeans%206.9/java/ant/lib/ant.jar!/org/apache/tools/ant/Project.class
and jar:file:/C:/Program%20Files%20(x86)/glassfish-3.0.1/glassfish/modules/ant.jar!/org/apache/tools/ant/Project.class
Testsuite: server.HelloBeanTest
sayHello
Jul 31, 2010 3:35:40 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.0.1 (22) startup time : Embedded(2102ms) startup services(534ms) total(2636ms)
Jul 31, 2010 3:35:40 PM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run
INFO: JMXStartupService: JMXConnector system is disabled, skipping.
Jul 31, 2010 3:35:40 PM com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
Jul 31, 2010 3:35:41 PM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
Jul 31, 2010 3:35:43 PM com.sun.enterprise.deployment.archivist.Archivist readAnnotations
WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: build/web/WEB-INF/classes/server/HelloServlet (wrong name: server/HelloServlet)
Jul 31, 2010 3:35:43 PM org.glassfish.api.ActionReport failure
SEVERE: Exception while deploying the app
java.lang.IllegalArgumentException: Invalid ejb jar [HelloWorld.jar]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:72)
at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:124)
at com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:722)
at com.sun.enterprise.deployment.Application.visit(Application.java:1744)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.validate(ApplicationArchivist.java:774)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:253)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:222)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:152)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:79)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:612)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:554)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:262)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:214)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:144)
at org.glassfish.ejb.embedded.EJBContainerImpl.deploy(EJBContainerImpl.java:128)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:120)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:102)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:78)
at server.HelloBeanTest.testSayHello(HelloBeanTest.java:49)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
Jul 31, 2010 3:35:43 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl createEJBContainer
INFO: [EJBContainerProviderImpl] Cleaning up on failure ...
Jul 31, 2010 3:35:43 PM org.glassfish.admin.mbeanserver.JMXStartupService shutdown
INFO: JMXStartupService and JMXConnectors have been shut down.
Jul 31, 2010 3:35:43 PM com.sun.enterprise.v3.server.AppServerStartup stop
INFO: Shutdown procedure finished
Jul 31, 2010 3:35:43 PM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] exiting
Jul 31, 2010 3:35:43 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl createEJBContainer
SEVERE: ejb.embedded.exception_instantiating
javax.ejb.EJBException: Failed to deploy EJB modules - see log for details
at org.glassfish.ejb.embedded.EJBContainerImpl.deploy(EJBContainerImpl.java:135)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:120)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:102)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:78)
at server.HelloBeanTest.testSayHello(HelloBeanTest.java:49)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 6.282 sec

------------- Standard Output ---------------
sayHello
------------- ---------------- ---------------
------------- Standard Error -----------------
Jul 31, 2010 3:35:40 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.0.1 (22) startup time : Embedded(2102ms) startup services(534ms) total(2636ms)
Jul 31, 2010 3:35:40 PM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run
INFO: JMXStartupService: JMXConnector system is disabled, skipping.
Jul 31, 2010 3:35:40 PM com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
Jul 31, 2010 3:35:41 PM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
Jul 31, 2010 3:35:43 PM com.sun.enterprise.deployment.archivist.Archivist readAnnotations
WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: build/web/WEB-INF/classes/server/HelloServlet (wrong name: server/HelloServlet)
Jul 31, 2010 3:35:43 PM org.glassfish.api.ActionReport failure
SEVERE: Exception while deploying the app
java.lang.IllegalArgumentException: Invalid ejb jar [HelloWorld.jar]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:72)
at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:124)
at com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:722)
at com.sun.enterprise.deployment.Application.visit(Application.java:1744)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.validate(ApplicationArchivist.java:774)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:253)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:222)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:152)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:79)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:612)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:554)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:262)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:214)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:144)
at org.glassfish.ejb.embedded.EJBContainerImpl.deploy(EJBContainerImpl.java:128)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:120)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:102)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:78)
at server.HelloBeanTest.testSayHello(HelloBeanTest.java:49)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
Jul 31, 2010 3:35:43 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl createEJBContainer
INFO: [EJBContainerProviderImpl] Cleaning up on failure ...
Jul 31, 2010 3:35:43 PM org.glassfish.admin.mbeanserver.JMXStartupService shutdown
INFO: JMXStartupService and JMXConnectors have been shut down.
Jul 31, 2010 3:35:43 PM com.sun.enterprise.v3.server.AppServerStartup stop
INFO: Shutdown procedure finished
Jul 31, 2010 3:35:43 PM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] exiting
Jul 31, 2010 3:35:43 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl createEJBContainer
SEVERE: ejb.embedded.exception_instantiating
javax.ejb.EJBException: Failed to deploy EJB modules - see log for details
at org.glassfish.ejb.embedded.EJBContainerImpl.deploy(EJBContainerImpl.java:135)
at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:120)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:102)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:78)
at server.HelloBeanTest.testSayHello(HelloBeanTest.java:49)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
------------- ---------------- ---------------
Testcase: testSayHello(server.HelloBeanTest): Caused an ERROR
No EJBContainer provider available
The following providers:
org.glassfish.ejb.embedded.EJBContainerProviderImpl
Returned null from createEJBContainer call.

javax.ejb.EJBException: No EJBContainer provider available
The following providers:
org.glassfish.ejb.embedded.EJBContainerProviderImpl
Returned null from createEJBContainer call.

at javax.ejb.embeddable.EJBContainer.reportError(EJBContainer.java:186)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:121)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:78)
at server.HelloBeanTest.testSayHello(HelloBeanTest.java:49)

Test server.HelloBeanTest FAILED
C:\\guptaDemo\\HelloWorld\\nbproject\\build-impl.xml:902: Some tests failed; see details above.
BUILD FAILED (total time: 10 seconds)

Posted by Michael Dudley on July 31, 2010 at 06:40 AM PDT #

Michael,

Strangely I've not seen this error before. Any help to reproduce this would be useful.

Here are my environment settings:

~ >echo $JAVA_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
~ >uname -a
Darwin Macintosh-187.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 i386
~ >java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-9M3165)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)

I also see the following warning message in your log:

WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: build/web/WEB-INF/classes/server/HelloServlet (wrong name: server/HelloServlet)

Does this project also have a Servlet ?

Have you tried creating a simple Web project, added only an EJB there, created the unit tests, and run them ?

-Arun

Posted by Arun Gupta on July 31, 2010 at 08:19 AM PDT #

Here is my system information.

Product Version: NetBeans IDE 6.9 (Build 201006101454)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)

Yes, there is a Servlet in the project as well. I was following along with your web cast. I will try your suggestion about creating a new project with only the EJB and see what happens.

Thank you, Michael

Posted by Michael Dudley on July 31, 2010 at 08:51 AM PDT #

As you suggested I created a project with only the EJB. When testing I still have the same errors.

Next I updated my jdk to the following but still had the same errors.

Product Version: NetBeans IDE 6.9 (Build 201006101454)
Java: 1.6.0_21; Java HotSpot(TM) 64-Bit Server VM 17.0-b17
System: Windows Vista version 6.0 running on amd64; Cp1252; en_US (nb)

I was able to right click and choose "debug test file." When I did this everything runs and the test passes. But when I right click "run file" and right click "test file" both fail.

I am not sure where to go from here. I will keep googling.

Posted by Michael Dudley on July 31, 2010 at 11:23 AM PDT #

I broke up the jndi call in my test to get a better idea of where the issue is ...

@Test
public void testSayHello() throws Exception {
System.out.println("sayHello");
String name = "Duke";

EJBContainer ejbc = EJBContainer.createEJBContainer();
Context ctx = ejbc.getContext();
HelloBean instance = (HelloBean) ctx.lookup("java:global/classes/HelloBean");
//HelloBean instance = (HelloBean)javax.ejb.embeddable.EJBContainer.createEJBContainer().getContext().lookup("java:global/classes/HelloBean");

String expResult = "Hello Duke";
String result = instance.sayHello(name);
assertEquals(expResult, result);

It is erroring out on this line:
EJBContainer ejbc = EJBContainer.createEJBContainer();

Posted by Michael Dudley on July 31, 2010 at 12:50 PM PDT #

Michael,

Sorry for the issues you are facing. Here is a command-line version of embeddable EJB, see if this works ?

http://blogs.sun.com/arungupta/entry/totd_128_ejbcontainer_createejbcontainer_embedded

-Arun

Posted by Arun Gupta on August 03, 2010 at 04:34 AM PDT #

Something is probably wrong as screencast 3 to 5 are based on Eclipse and not NetBeans.

Posted by Koenraad Van Acker on August 05, 2010 at 05:11 AM PDT #

Koenraad,

I changed the source of videos and that's why the order got messed up, now fixed.

Thanks for the catch!

Posted by Arun Gupta on August 05, 2010 at 05:22 AM PDT #

Your tutorials are VERY helpful and thanks for providing them.

I was able to follow first 2 and when I started the 3rd set, I am having problem with my NetBeans IDE, when I need to add folder to WEB-INF. I am missing option to add a folder and it does not show the following options:
<Interceptor Bindinding Type, Facelets Template Client, Facelets Template, Folder, Java Interfaces>. I downloaded full version and installed sucessfully.
How do I enable the IDE to show the missing options with right click and New ?

Posted by baheti on August 10, 2010 at 01:59 AM PDT #

baheti,

Select "New", "Other ...", "Other", "Folder" to create the folder.

Posted by Arun Gupta on August 10, 2010 at 02:45 AM PDT #

try to turn off email67

Posted by Ian Parkin on August 10, 2010 at 02:53 AM PDT #

I posted earlier about how to have other options showup in the right click and I figured that out myself. It shows after we use it once from 'other'.

Thanks for your great tutorials.

Posted by baheti on August 10, 2010 at 03:09 AM PDT #

I tried to build RESTful Web services from Database and I ended with errors in in the generated code and I deleted those .java files and wanted to rebuild (I am not sure what is the best way to remove the services, once deployed) but how do I get back to be able to rebuild with database?
Any help is appreciated.

Thanks

Posted by baheti on August 10, 2010 at 08:36 AM PDT #

baheti,

Try creating a new project :-)

Posted by Arun Gupta on August 10, 2010 at 08:50 AM PDT #

I am not able to retrieve data from Oracle 10g from NetBeans with entity class. Getting SQL exception. Any ideas?

Thanks

Posted by baheti on August 20, 2010 at 12:18 AM PDT #

I am not able to retrieve data from Oracle 10g from NetBeans with entity class. Getting SQL exception. Any ideas?

Thanks

Posted by baheti on August 23, 2010 at 12:34 AM PDT #

Hi,
I found solution to my earlier 3 posts about connecting Oracle 10g from IDE and the SQL exceptions that were problem. I needed to add the driver to the project libraries.

Thanks.

Posted by baheti on August 23, 2010 at 06:00 AM PDT #

Thanks for the tutorial, you made complicated thing is easy to understand

Posted by ndra on September 08, 2010 at 03:13 AM PDT #

Hi Arun,

Good job with the screencasts... very straight and to the point! Very helpful with getting started with both Netbeans and JEE.

Henlo

Posted by Henlo on October 04, 2010 at 11:42 PM PDT #

Hi, very nice tutorials. I started following your lessons, I was able to finsih part 1, however when I started part 2 I got stuck because I was not able to find the script for the database tables (STATES) you use in your screencast. In fact, I checked my jdbc/sample, I have only "CUSTOMER, DISCOUNT_CODE, MANUFACTURER, MICR_MARKET, PRODUCT, PRODUCT_CODE, PURCHASE_ORDER).

Question, once the script available, how can we execute those scripts against the DB
In netbeans ?
Thanks for your help

Posted by eliassal on November 30, 2010 at 04:42 AM PST #

eliassal,

You can pick any of the available tables to proceed with the screencast.

Posted by Arun Gupta on November 30, 2010 at 07:41 PM PST #

Arun, regarding 3rd part,i followed our steps and wrote exactly same code in Welcome.java and input.xhtml, when i do a run i get the following error
/input.xhtml @18,56 value="#{welcome.name}": Target Unreachable, identifier 'welcome' resolved to null
By te way,is it possible to debug xhtml files in Netbeans?
Thanks for your help

Posted by eliassal on December 05, 2010 at 06:16 AM PST #

Arun - Very good tutorial. It all works for me except the JUnit test. I am also getting the same error Michael Dudley reported when running the JUNIT test.
Any suggestions of ideas how to fix?
Tks
Suresh Kumar

Posted by Suresh Kumar on December 10, 2010 at 10:38 AM PST #

Arun - I have this problem fixed now, this is what I did, I uninstalled my earlier version of NetBeans6.8 and GF3 server. Also I noticed that the EJB bean and servlet classes to be on the same package, if else it fails.
Suresh

Posted by Suresh Kumar on December 10, 2010 at 11:01 AM PST #

eliassal,

Have you added @Named annotation on Welcome class ?

Posted by Arun Gupta on December 14, 2010 at 09:20 AM PST #

Arun, excellent screencast, I've been using tomcat with eclipse for the majority of my projects so was interested to see how NetBeans and GlassFish compared.

Michael, I know you've probably long forgotton about the testing issue, but I had the same issue and found a solution (although not a very elegant one) which I thought I would post in case anyone else faced the same problem. I managed to fix the issue by adding/changing the following lines of code:

Map properties = new HashMap();
properties.put(EJBContainer.MODULES, new File("C:\\\\Development\\\\Java\\\\src\\\\HelloWorld\\\\build\\\\web\\\\WEB-INF\\\\classes"));
HelloBean instance = (HelloBean)EJBContainer.createEJBContainer(properties).getContext().lookup("java:global/classes/HelloBean");

Arun, any ideas why I would have to do this?

Many Thanks

Posted by Andrew on February 09, 2011 at 07:17 PM PST #

Andrew,

Not sure, I need to try it on a Windows environment and then will report back.

Can you file a bug on netbeans.org/community/issues.html if its reproducible ?

Posted by Arun Gupta on February 12, 2011 at 07:41 PM PST #

Hi Arun, Thank you for their tutorial are fantastic, I carry out the video 3 because I need user's login validated against a DataBase .... but when i did your exercising it doesn't work it leaves this error:

An Error Occurred:
/input.xhtml @15,115 value="#{welcome.name}": Target Unreachable, identifier 'welcome' resolved to null

(pd: sorry for my english)

Posted by Angie on February 15, 2011 at 06:27 AM PST #

Angie,

Have you added @Named or @Model annotation on Welcome.java ?

Posted by Arun Gupta on February 18, 2011 at 02:14 AM PST #

Hi Andrew,
thanks for your comments. I had the same problem as yours. When I've put "properties", the problems were finished!

Thank you!

Posted by Serpa on March 19, 2011 at 08:34 AM PDT #

Hi Arun

Can you make same video for maven project? It will be great if you do it.

regards, devalentino

Posted by guest on August 24, 2011 at 07:50 AM PDT #

Have you checked out the Maven-based screencast at http://www.youtube.com/watch?v=OusAoNKnYbw ?

Posted by Arun on September 05, 2011 at 06:39 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today