File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes failed jndi datasource lookup for jdbc/__default on Glassfish Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "failed jndi datasource lookup for jdbc/__default on Glassfish " Watch "failed jndi datasource lookup for jdbc/__default on Glassfish " New topic
Author

failed jndi datasource lookup for jdbc/__default on Glassfish

das govender
Greenhorn

Joined: Mar 12, 2012
Posts: 16
Hi

I am using Glassfish 3.1.1 and the standard resource jdbc/__default using DerbyPool.

My code looks like this.
@Resource javax.sql.DataSource __default;
public ArrayList<FNDSProductDTO> getFNDSProductList() throws Exception {

Connection conn = __default.getConnection();
System.out.println("Connection Established to FNDS DB");

return new ArrayList<FNDSProductDTO>();
}

I get a jndi error for __default. See below

cd /Users/dgovender/Desktop/testsvncheckout/TestEJBProject; JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home "/Applications/NetBeans/NetBeans 7.0.1.app/Contents/Resources/NetBeans/java/maven/bin/mvn" -Dnetbeans.deploy=true package
Scanning for projects...

------------------------------------------------------------------------
Building TestEJBProject 1.0.0-SNAPSHOT
------------------------------------------------------------------------

[dependency:copy]

[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource

[compiler:compile]
Compiling 1 source file to /Users/dgovender/Desktop/testsvncheckout/TestEJBProject/target/classes

[resources:testResources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory /Users/dgovender/Desktop/testsvncheckout/TestEJBProject/src/test/resources

[compiler:testCompile]
Nothing to compile - all classes are up to date

[surefire:test]
Surefire report directory: /Users/dgovender/Desktop/testsvncheckout/TestEJBProject/target/surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running za.co.fnds.testejbproject.TestSessionBeanTest
Mar 22, 2012 10:58:40 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl getValidFile
SEVERE: ejb.embedded.location_not_exists
Mar 22, 2012 10:58:41 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish v3 (74.2) startup time : Embedded(409ms) startup services(315ms) total(724ms)
Mar 22, 2012 10:58:41 AM com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
Mar 22, 2012 10:58:41 AM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run
INFO: JMXStartupService: JMXConnector system is disabled, skipping.
Mar 22, 2012 10:58:42 AM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.SecurityLifecycle <init>
INFO: security.secmgroff
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.ssl.SSLUtils checkCertificateDates
SEVERE: java_security.expired_certificate
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: Security startup service called
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.PolicyLoader loadPolicy
INFO: policy.loading
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: Realm admin-realm of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: Realm file of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: Realm certificate of classtype com.sun.enterprise.security.auth.realm.certificate.CertificateRealm successfully created.
Mar 22, 2012 10:58:44 AM com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: Security service(s) started successfully....
Mar 22, 2012 10:58:44 AM com.sun.ejb.containers.BaseContainer initializeHome
INFO: Portable JNDI names for EJB TestSessionBean : [java:global/classes/TestSessionBean!za.co.fnds.testejbproject.beans.TestSessionBean, java:global/classes/TestSessionBean]
multiply
Mar 22, 2012 10:58:45 AM com.sun.ejb.containers.StatelessSessionContainer createStatelessEJB
SEVERE: ejb.stateless_ejbcreate_exception
Mar 22, 2012 10:58:45 AM com.sun.ejb.containers.BaseContainer postInvoke
WARNING: A system exception occurred during an invocation on EJB TestSessionBean method public int za.co.fnds.testejbproject.beans.TestSessionBean.multiply(int,int)
javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:448)
at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2418)
at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1811)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:188)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
at $Proxy80.multiply(Unknown Source)
at za.co.fnds.testejbproject.beans.__EJB31_Generated__TestSessionBean__Intf____Bean__.multiply(Unknown Source)
at za.co.fnds.testejbproject.TestSessionBeanTest.testMultiply(TestSessionBeanTest.java:67)
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.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
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:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
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.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at $Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:718)
at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:200)
at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:443)
... 40 more
Caused by: javax.ejb.CreateException: Could not create stateless EJB
at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:526)
at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:90)
at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:716)
... 42 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Res-Ref-Env-Property: za.co.fnds.testejbproject.beans.TestSessionBean/__default@javax.sql.DataSource@ resolved as: jndi: za.co.fnds.testejbproject.beans.TestSessionBean/__default@res principal: null@mail: null
No Runtime properties
Database Vendor : null
Create Tables at Deploy : false
Delete Tables at Undeploy : false into class za.co.fnds.testejbproject.beans.TestSessionBean
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:614)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:384)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:168)
at com.sun.ejb.containers.BaseContainer.injectEjbInstance(BaseContainer.java:1622)
at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:486)
... 44 more
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/za.co.fnds.testejbproject.beans.TestSessionBean/__default' in SerialContext [Root exception is javax.naming.NamingException: Lookup failed for 'za.co.fnds.testejbproject.beans.TestSessionBean/__default' in SerialContext [Root exception is javax.naming.NameNotFoundException: za.co.fnds.testejbproject.beans.TestSessionBean]]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:513)
... 48 more
Caused by: javax.naming.NamingException: Lookup failed for 'za.co.fnds.testejbproject.beans.TestSessionBean/__default' in SerialContext [Root exception is javax.naming.NameNotFoundException: za.co.fnds.testejbproject.beans.TestSessionBean]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:83)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:688)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:657)
at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:148)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:428)
... 50 more
Caused by: javax.naming.NameNotFoundException: za.co.fnds.testejbproject.beans.TestSessionBean
at com.sun.enterprise.naming.impl.TransientContext.resolveContext(TransientContext.java:252)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:171)
at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:58)
at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:101)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
... 56 more
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.265 sec <<< FAILURE!

Results :

Tests in error:
testMultiply(za.co.fnds.testejbproject.TestSessionBeanTest): javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 7.877s
Finished at: Thu Mar 22 10:58:45 SAST 2012
Final Memory: 15M/81M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project TestEJBProject: There are test failures.

Please refer to /Users/dgovender/Desktop/testsvncheckout/TestEJBProject/target/surefire-reports for the individual test results.
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: failed jndi datasource lookup for jdbc/__default on Glassfish
 
Similar Threads
Double insertion using entity lifecycle listener
Had an issue while accessing JMS remotely
Problem with jndi lookup for remote bean in EJB 3.x
EJB with Hibernate
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction