users@glassfish.java.net

Re: [glassfish embedded] Retrieving EntityManager in the Jersey XmlAdapter

From: <glassfish_at_javadesktop.org>
Date: Tue, 22 Jun 2010 01:34:45 PDT

Hi, thanks for your reply

Regarding 1st method / problem it is 99,99 % not a classpath problem because all of the rest of my tests on glassfish are passing through, they are retrieving SessionBeans from JNDI and operate on Entity Beans or I invoke rest client which connects to Http on embedded and invokes SessionBeans with jax-rs annotations, so if there will be problems with classpath they will also raise issues but nothing like that happens.

Regarding 2nd method / problem if this will be the problem with the classpath I will not be able to deploy the war on embedded. I think this is not the direct classpath problem because I can invoke the beans by JNDI.

Method of invoking embedded server (imports are from org.glassfish.api.embedded.* or org.glassfish.api.*):

Server.Builder builder = new Server.Builder("embeddedTestServer");

                EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
                efsb.instanceRoot(new File(INSTANCE_ROOT));
                
                EmbeddedFileSystem efs = efsb.build();
                builder.embeddedFileSystem(efs);
                Properties properties = new Properties();
                //properties.put("java.util.logging.config.file", "conf/logging.properties");
                server = builder.build(properties);

                //ContainerBuilder<EmbeddedContainer> containerBuilder = server.createConfig(CONTAINER_TYPE);
                server.addContainer(ContainerBuilder.Type.all);
                //containerBuilder.create(server);
                try {
                        server.createPort(SERVER_PORT);
                        server.start();
                } catch (Exception e) {
                        throw new RuntimeException(e);
                }

//// and then deploying
deployer = server.getDeployer(); // type is EmbeddedDeployer
DeployCommandParameters deployParams = new DeployCommandParameters();
deployParams.name = applicationName;

File archive = new File(archiveName);
applicationName = deployer.deploy(archive, deployParams);

In my opinion there is something wrong with exporting some resources to the JNDI, or the deployer for glassfish embedded works differently from production version. Structure of my war:
WEB-INF/classes - containes Session Beans, Entity Beans, XmlAdapters etc.
WEB-INF/classes/META-INF - contains (persistence.xml + orm.* files, I am using mostly xml entities).

structure of my persistence.xml:
-----------------------------------------------------------------------------------
<?xml version="1.0"?>
<persistence 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_1_0.xsd"
        version="1.0">

        <persistence-unit name="brexPU" transaction-type="JTA">

                <provider>
                        org.eclipse.persistence.jpa.PersistenceProvider
                </provider>

                <jta-data-source>jdbc/brex</jta-data-source>

                <mapping-file>META-INF/orm.xml</mapping-file>
                <mapping-file>META-INF/orm-platform.xml</mapping-file>
                <mapping-file>META-INF/orm-filesystem.xml</mapping-file>
                <mapping-file>META-INF/orm-emailqueue.xml</mapping-file>
                <mapping-file>META-INF/orm-validation.xml</mapping-file>
                <mapping-file>META-INF/orm-crm.xml</mapping-file>
                <mapping-file>META-INF/orm-meta.xml</mapping-file>
                <properties>
                        <property name="eclipselink.target-database" value="PostgreSQL" />


                        <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />

                        <property name="eclipselink.logging.level" value="INFO" />
                        <property name="eclipselink.logging.level.cache" value="INFO" />
                        <property name="eclipselink.logging.level.sql" value="FINEST" />

                </properties>

        </persistence-unit>

</persistence>
-----------------------------------------------------------------------------------

thanks in advance
[Message sent by forum member 'jszczepankiewicz']

http://forums.java.net/jive/thread.jspa?messageID=475331