title: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
body: <p>I am building a <strong>Java Enterprise</strong> Application using Netbeans 8.0.1 on Linux Mint.
  I have to use an existing <strong>SQLite</strong> database so I followed the <a href="http://jakoch.de/2013/07/21/marry-netbeans-sqlite/" rel="nofollow">tutorial here</a> to connect Netbeans to it.
  Then I wrote a trial Entity class and Session Bean but <strong>when I deploy the application I get the following error</strong>:</p>
  
  <pre><code>Grave:   Exception while preparing the app : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
  Error Code: 0
  Local Exception Stack: 
  Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
  Error Code: 0
      at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:316)
      at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:135)
      at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
      at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:203)
      at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:734)
      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
      at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:681)
      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
      at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
      at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:358)
      at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
      at org.glassfish.persistence.jpa.PersistenceUnitLoader.&lt;init&gt;(PersistenceUnitLoader.java:107)
      at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
      at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
      at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
      at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:922)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:431)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.Subject.doAs(Subject.java:356)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
      at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
      at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
      at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:744)
  Caused by: java.sql.SQLException: Error in allocating a connection. Cause: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
      at com.sun.gjc.spi.base.AbstractDataSource.getConnection(AbstractDataSource.java:121)
      at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:123)
      ... 50 more
  Caused by: javax.resource.spi.ResourceAllocationException: Error in allocating a connection. Cause: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
      at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:319)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:196)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:171)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:166)
      at com.sun.gjc.spi.base.AbstractDataSource.getConnection(AbstractDataSource.java:114)
      ... 51 more
  Caused by: com.sun.appserv.connectors.internal.api.PoolingException: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
      at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:103)
      at com.sun.enterprise.resource.pool.ConnectionPool.addResource(ConnectionPool.java:282)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResourceAndAddToPool(ConnectionPool.java:1512)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResources(ConnectionPool.java:944)
      at com.sun.enterprise.resource.pool.ConnectionPool.initPool(ConnectionPool.java:230)
      at com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(ConnectionPool.java:511)
      at com.sun.enterprise.resource.pool.ConnectionPool.getResource(ConnectionPool.java:381)
      at com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:245)
      at com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:170)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:360)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:307)
      ... 55 more
  Caused by: com.sun.appserv.connectors.internal.api.PoolingException: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
      at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:924)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResource(ConnectionPool.java:1189)
      at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:98)
      ... 65 more
  Caused by: com.sun.appserv.connectors.internal.api.PoolingException: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
      at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:110)
      at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:907)
      ... 67 more
  Caused by: javax.resource.ResourceException: org.sqlite.JDBC cannot be cast to javax.sql.DataSource
      at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:166)
      at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:102)
      at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)
      ... 68 more
  </code></pre>
  
  <p>I search on internet for a solution but but I every time obtain the same exception.</p>
  
  <p>Can somebody help me???</p>