0

I'm facing the same problem as here. I can deploy my application without errors but when I try to view the index page I get the an error with the following root cause:

[#|2014-06-02T16:53:37.524+0100|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=18;_ThreadName=Thread-2;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.ClassNotFoundException: javax.persistence.Persistence
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at my.database.manager.PersistenceStoreManagerImpl.init(PersistenceStoreManagerImpl.java:57)
        at my.database.manager.PersistenceStoreManagerImpl.getInstance(PersistenceStoreManagerImpl.java:76)
        at my.database.manager.PersistenceCRUDManagerImpl.<init>(PersistenceCRUDManagerImpl.java:49)
        at my.database.model.Serviceprovider.<clinit>(Serviceprovider.java:40)
        at my.server.web.contoller.ServiceProviderController.findAll(ServiceProviderController.java:205)
        at my.server.web.contoller.ServiceProviderController.init(ServiceProviderController.java:62)
        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.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
        at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:174)
        at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:398)
        at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:174)
        at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:294)
        at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:107)
        at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:104)
        at my.server.web.contoller.ServiceProviderController$Proxy$_$$_WeldClientProxy.showViewDataTable(ServiceProviderController$Proxy$_$$_WeldClientProxy.java)
        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 javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:779)
        at javax.el.BeanELResolver.invoke(BeanELResolver.java:528)
        at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257)
        at com.sun.el.parser.AstValue.getValue(AstValue.java:134)
        at com.sun.el.parser.AstValue.getValue(AstValue.java:183)
        at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)
        at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
        at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
        at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
        at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
        at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
        at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.getValue(OutputLinkRenderer.java:182)
        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
        at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.renderAsActive(OutputLinkRenderer.java:191)
        at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.encodeBegin(OutputLinkRenderer.java:107)
        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1755)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:662)

my.database.* and my.server.* are my own classes that form the application I'm working on. See here for a full description although I don't think it's necessary for this issue.

In user1766169's question, the solution was to change the scope of the persistence library from provided to runtime since the library was not available in the execution environment.

However, this is not the case with me as the library is available in the Glassfish [as-install]/modules/ directory. This is the output of the asadmin list-modules command:

asadmin> list-modules
List Of Modules
.
.
.
Module : javax.persistence:2.0.4.v201112200901
.
.
.
Command list-modules executed successfully.

so I assume Glassfish is aware of the persistence module. I've inspected the javax.persistence.jar archive and the javax.persistence.Persistence class is in the library.

Do you need to do anything special to indicate to Glassfish to use the modules in its modules directory?

Update 1 03-06-2014 This issue appears intermittently and I receive the following error when this issue does not appear: java.lang.NoClassDefFoundError: Could not initialize class my.database.model.Serviceprovider.

Update 2 03-06-2014 I thought the java.lang.NoClassDefFoundError was related in a meaningful way but it appears to be a secondary error caused by the inability to locate java.lang.NoClassDefFoundError. Also, adding libraries in the [as-install]/modules/ directory to [as-install]/domains/MyDomain/lib/ext/ seems to make the Persistence library 'locateable' but leads to further errors trying to locate classes present in libraries in the [as-install]/modules/ directory. I have included my Glassfish config options at the bottom.

MyServer web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>my-server</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/balusc.taglib.xml</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
  </context-param>
  <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
  </filter-mapping>
  <context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

MyServer persistence.xml file

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="my_persistence_unit" transaction-type="JTA">
      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>my_persistence_unit</jta-data-source>
        <class>my.database.model.Table1</class>
        .
        .
        .
        <class>my.database.model.TableN</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>

         <properties>
           <property name="eclipselink.logging.level" value="FINE"/>
           <property name="validation-mode" value="NONE"/>
           <property name="eclipselink.cache.shared.default" value="false"/>
           <property name="eclipselink.ddl-generation" value="create-tables" />
           <property name="openjpa.DynamicEnhancementAgent" value="false"/>
           <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported" />
         </properties>

    </persistence-unit>
</persistence>

MyServer POM file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.webapp</groupId>
    <artifactId>my-server</artifactId>
    <version>0.1.0-SNAPSHOT</version>
    <name>My Server</name>
    <parent>
        <groupId>my.webapp</groupId>
        <artifactId>my-parent-pom</artifactId>
        <version>1.5</version>
    </parent>
    <organization>
        <name>Example</name>
        <url>http://www.example.com</url>
    </organization>
    <repositories>
        <repository>
            <id>eclipselink</id>
            <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>eclipselink</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.3.0</version>
        </dependency>

        <dependency>
            <groupId>utilities</groupId>
            <artifactId>utilities</artifactId>
            <version>0.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>my.webapp</groupId>
            <artifactId>my-database</artifactId>
            <version>0.1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.4.1</version>
        </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2.1</version>
    </dependency>
    </dependencies>

    <packaging>war</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <!-- <configuration> section added to pick up the WEB-INF/web.xml inside
                    WebContent -->
                <configuration>
                    <webResources>
                        <resource>
                            <directory>WebContent</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <scm>
        <connection>scm:svn:https://svn.server/location/in/repo/my_server</connection>
        <developerConnection>scm:svn:https://svn.server/location/in/repo/my_server/trunk</developerConnection>
    </scm>
</project>

MyDatabase persistence.xml file

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="my_persistence_unit" transaction-type="JTA">
      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>my_persistence_unit</jta-data-source>
        <class>my.database.model.Table1</class>
        .
        .
        .
        <class>my.database.model.TableN</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>

         <properties>
           <property name="eclipselink.logging.level" value="FINE"/>
           <property name="validation-mode" value="NONE"/>
           <property name="eclipselink.cache.shared.default" value="false"/>
           <property name="eclipselink.ddl-generation" value="create-tables" />
           <property name="openjpa.DynamicEnhancementAgent" value="false"/>
           <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported" />
         </properties>

    </persistence-unit>
</persistence>

MyDatabase POM file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>my-database</artifactId>
  <version>0.1.0-SNAPSHOT</version>
  <parent>
    <groupId>my.webapp</groupId>
    <artifactId>my-parent-pom</artifactId>
    <version>1.5</version>
  </parent>
  <dependencies>
    <dependency>
      <groupId>eclipselink</groupId>
      <artifactId>eclipselink</artifactId>
      <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mindrot</groupId>
      <artifactId>bcrypt</artifactId>
      <version>0.2.0</version>
    </dependency>
    <dependency>
        <groupId>my.webapp</groupId>
        <artifactId>my-interfaces</artifactId>
        <version>0.1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-jpa_3.0_spec</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.0.5</version>
        <scope>test</scope>
    </dependency>
  </dependencies>
  <scm>
    <connection>scm:svn:https://svn.server/location/in/repo/my_database</connection>
    <developerConnection>scm:svn:https://svn.server/location/in/repo/my_database/trunk/</developerConnection>
  </scm>
  <groupId>my.webapp</groupId>
</project>

my.database.PersistenceStoreManagerImpl class

/**
 *
 */
package my.database.manager;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import my.database.interfaces.PersistenceStoreManager;

/**
 * This class is responsible for providing the entity manager that will manage
 * the entity instances and their life cycles.This class should implement the
 * PersistenceStoreManager interfaces
 *
 */
public class PersistenceStoreManagerImpl implements PersistenceStoreManager
{
    /**
     * This is the default database name which is used for accessing the database.
     * This must match the persistence.xml value
     */
    private static final String DATABASE_NAME = "my_persistence_unit";

    private static EntityManagerFactory EMF = null;
    /**
     * This variable is associated with the persistence context. This variable
     * is used to create and remove persistent entity instances, to find
     * entities by their primary key, and to query over entities.
     */
    private EntityManager em;
    /**
     * This is the instance of the class and should always be fetched by
     * getInstance() method
     */
    private static PersistenceStoreManagerImpl instance;

    /**
     * This is the default constructor of the class, this is made private so
     * that the instance can be created through getInstance()
     */
    private PersistenceStoreManagerImpl() {

    }

    /**
     * Creates the EntityManagerFactory from the supplied database name.
     * This must be done before getInstance() is called.
     *
     * @param databaseName
     */
    public static void init(String databaseName)
    {
        EMF = Persistence.createEntityManagerFactory(databaseName);
        System.out.println("PersistenceStoreManager initialised to use database " + databaseName);
    }


    /*
     * Returns the singleton instance.
     * If the class has not yet been initialised, it will be initialised with the default database name
     *
     * @returns the singleton instance or null if it has not been initialised.
     */

    public static PersistenceStoreManager getInstance()
    {
        if (null == instance)
        {
            // If the database name has not been set, use the default one
            if (EMF == null)
            {
                init(DATABASE_NAME);
            }
            instance = new PersistenceStoreManagerImpl();

        }
        return instance;
    }

    /*
     * (non-Javadoc)
     *
     * @see my.interfaces.PersistenceStoreManager#setConnection()
     */
    @Override
    public void setConnection() {
        this.em = EMF.createEntityManager();
    }

    /*
     * (non-Javadoc)
     *
     * @see my.interfaces.PersistenceStoreManager#
     * getEntityManagerForTransaction()
     */
    @Override
    public EntityManager getEntityManager() {
        setConnection();
        if (!em.getTransaction().isActive()) {
            em.getTransaction().begin();
        }
        return em;
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * my.interfaces.PersistenceStoreManager#commitAndCloseConnection
     * ()
     */
    @Override
    public void commitAndCloseConnection() {
        em.getTransaction().commit();
        em.clear();
        em.close();
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * my.interfaces.PersistenceStoreManager#closeConnection()
     */
    @Override
    public void closeConnection() {
        em.close();

    }

}

my.interfaces.PersistenceStoreManager interface class

/*
 * 
 */
package my.interfaces;

import javax.persistence.EntityManager;

/**
 * This class is responsible for managing the persistence store.
 *
 * 
 */
public interface PersistenceStoreManager {
    /**
     * This method is called to establish the connection with the persistence
     * storage
     */
    public void setConnection();

    /**
     * This method gives the instance of the entity manager that would
     * fetch/persist(add new data)/merge(update existing data). This method
     * should always return an active transaction or begin a new transaction
     *
     * @return entity manager
     */
    public EntityManager getEntityManager();

    /**
     * This method is called to close the existing connection.
     */
    public void closeConnection();

    /**
     * This method is called to commit the transaction , clear the persistence
     * context and then close the existing connection.
     */
    public void commitAndCloseConnection();


}

My Glassfish server is started with the following configuration:

INFO: JVM invocation command line:
  -XX:+UnlockDiagnosticVMOptions
  -XX:PermSize=64m
  -XX:MaxPermSize=192m
  -XX:NewRatio=2
  -Xmx512m
  -client
  -javaagent:/opt/glassfish3/glassfish/lib/monitor/flashlight-agent.jar
  -Dosgi.shell.telnet.maxconn=1
  -Dfelix.fileinstall.disableConfigSave=false
  -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
  -Dfelix.fileinstall.dir=/opt/glassfish3/glassfish/modules/autostart/
  -Djavax.net.ssl.keyStore=/opt/glassfish3/glassfish/domains/MyDomain/config/keystore.jks
  -Dosgi.shell.telnet.port=6666
  -Djava.security.policy=/opt/glassfish3/glassfish/domains/MyDomain/config/server.policy
  -Djava.awt.headless=true
  -Dfelix.fileinstall.log.level=2
  -Dfelix.fileinstall.poll=5000
  -Dcom.sun.aas.instanceRoot=/opt/glassfish3/glassfish/domains/MyDomain
  -Dosgi.shell.telnet.ip=127.0.0.1
  -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
  -Djava.endorsed.dirs=/opt/glassfish3/glassfish/modules/endorsed:/opt/glassfish3/glassfish/lib/endorsed
  -Dcom.sun.aas.installRoot=/opt/glassfish3/glassfish
  -Dfelix.fileinstall.bundles.startTransient=true
  -Djava.ext.dirs=/opt/java/lib/ext:/opt/java/jre/lib/ext:/opt/glassfish3/glassfish/domains/MyDomain/lib/ext
  -Dfelix.fileinstall.bundles.new.start=true
  -Djavax.net.ssl.trustStore=/opt/glassfish3/glassfish/domains/MyDomain/config/cacerts.jks
  -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as
  -Djava.security.auth.login.config=/opt/glassfish3/glassfish/domains/MyDomain/config/login.conf
  -DANTLR_USE_DIRECT_CLASS_LOADING=true
  -Dgosh.args=--nointeractive
Community
  • 1
  • 1
user3337410
  • 94
  • 1
  • 10
  • Please add the code of `PersistenceStoreManagerImpl`. I guess the `eclipselink` groupID is some kind of typo because it should be `org.eclipse.persistence`. – unwichtich Jun 02 '14 at 18:49
  • I've added the classes. The `eclipselink` groupId is not a typo; the parent POM directs maven to pull libraries from our own repo which we maintain. I don't think this is an issue though since the javax.persistence module is still on the Glassfish server. – user3337410 Jun 03 '14 at 08:46
  • poking around trying to resolve this has made me more convinced that the `[as-install]/modules/` directory is the key. An answer to [this](http://stackoverflow.com/questions/22992948) question might help shed some light on this. – user3337410 Jun 03 '14 at 11:43

1 Answers1

0

Despite your initial question, you don't need to and also you should not do all that stuff like managing the transactions manually in your PersistenceStoreManagerImpl when you use JTA (as indicated in your persistence.xml).

It should be used similar to this example:

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class FileDAO {

    @PersistenceContext
    private EntityManager em;

    public void store(File file) {
        em.persist(file);
    }
}

This is nearly all you need. You can use this in another class by injecting it with @EJB annotation.

This doesn't explicitly need the class javax.persistence.Persistence but other classes from the same package :)

If you specifiy transaction type JTA and you want to manage the EntityManager manually anyway, there are some things to consider which are nicely explained in this question.

In my opinion, JTA should be the preferred transaction type if you use application server and JDBC driver which are capable of providing JTA (which you probably have). As you can see in the example it makes a lot of code obsolete. It is also less error-prone.

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • Thanks for the code and suggestions. I'll try implementing them and see how it goes. I'm still hoping for an answer to my original question though. – user3337410 Jun 05 '14 at 12:09