Note that there are some explanatory texts on larger screens.

plurals
  1. POGlassfish embedded with JUnit for EJB testing
    primarykey
    data
    text
    <p>I ran into a big issue, what I cannot solve.</p> <p>I trying write a small application with JavaEE6 and EJB. I would like set up testing environment with EJBContainer and Glassfish Embedded.</p> <p>This project is created via Maven but the EJBContainer is booted up by the test class itself because as I see it is easier and more common than booting up from maven.</p> <p>I created a GlassFish domain based on some articles in my src/test/glassfish-domain folder (in the right structure, see below).</p> <p>If my domains.xml does not contains my JDBC resource what I define to test my application, GF embedded boots up correctly. But when I define the required JDBC resource, I got a NullPointerException without explanation.</p> <p>Can anyone point me, what I do wrong?</p> <p>Domain Config snippet:</p> <pre><code> &lt;resources&gt; &lt;!-- [...] --&gt; &lt;jdbc-resource pool-name="bookshelf" jdni-name="jdbc/bookshelf" /&gt; &lt;jdbc-connection-pool driver-classname="" datasource-classname="org.apache.derby.jdbc.ClientDataSource" res-type="javax.sql.DataSource" description="" name="bookshelf"&gt; &lt;property name="User" value="APP"&gt;&lt;/property&gt; &lt;property name="DatabaseName" value="bookshelf-db"&gt;&lt;/property&gt; &lt;property name="RetrieveMessageText" value="true"&gt;&lt;/property&gt; &lt;property name="Password" value="APP"&gt;&lt;/property&gt; &lt;property name="ServerName" value="localhost"&gt;&lt;/property&gt; &lt;property name="Ssl" value="off"&gt;&lt;/property&gt; &lt;property name="SecurityMechanism" value="4"&gt;&lt;/property&gt; &lt;property name="ConnectionAttributes" value=";create=true"&gt;&lt;/property&gt; &lt;property name="TraceFileAppend" value="false"&gt;&lt;/property&gt; &lt;property name="TraceLevel" value="-1"&gt;&lt;/property&gt; &lt;property name="PortNumber" value="1527"&gt;&lt;/property&gt; &lt;property name="LoginTimeout" value="0"&gt;&lt;/property&gt; &lt;/jdbc-connection-pool&gt; &lt;/resources&gt; &lt;servers&gt; &lt;server name="server" config-ref="server-config"&gt; &lt;!-- [...] --&gt; &lt;resource-ref ref="jdbc/bookshelf" /&gt; &lt;/server&gt; </code></pre> <p>The log:</p> <pre><code>javax.ejb.EJBException: java.lang.NullPointerException at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createContainer(EJBContainerProviderImpl.java:233) at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:129) at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:127) at me.hron.bookshelf.test.ejb.CategoryFacadeTest.setupContainer(CategoryFacadeTest.java:52) 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:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) 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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68) Caused by: java.lang.NullPointerException at com.sun.enterprise.config.serverbeans.Resources$Duck.getResourceByName(Resources.java:172) 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.jvnet.hk2.config.Dom.invokeDuckMethod(Dom.java:946) at org.jvnet.hk2.config.Dom.invoke(Dom.java:899) at org.glassfish.config.support.TranslatedConfigView.invoke(TranslatedConfigView.java:119) at $Proxy58.getResourceByName(Unknown Source) at org.glassfish.javaee.services.ResourceManager.isBindableResourceEnabled(ResourceManager.java:188) at org.glassfish.javaee.services.ResourceManager.deployResources(ResourceManager.java:162) at org.glassfish.javaee.services.ResourceManager.postConstruct(ResourceManager.java:116) at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131) at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91) at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82) at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67) at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139) at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76) at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:336) at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145) at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136) at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79) at org.glassfish.ejb.embedded.EJBContainerProviderImpl.createContainer(EJBContainerProviderImpl.java:203) ... 25 more </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload