You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Targa <de...@bodnar.ws> on 2009/03/10 15:48:25 UTC

Why doesn't unpacked openjpa works like packed openjpa.jar?

Hello!
I'm using maven2 tool to build my OpenJPA application with embedded database
and run into strange OpenJPA behavior. What I want is just get JAR with all
dependencies included in unpacked form. So there is maven-assembly-plugin
used with <unpack>true</unpack> option. This actually creates big jar with
all *.class dependencies included.
When I try to run this jar, it doesn't work properly:
Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, prop); returns
NULL. I thought there could be an issue with persistence.xml, but If I
manually include openjpa-persistence-1.2.0.jar to my package and add it to
classpath - everething works fine... 
So I suppose there could be a problem with classloading (although I didn't
use any custom classloaders). I tryed to manually set up classloader before
call Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, prop); without
any success.

Please, tell me what's the problem? Why I can't just unzip
openjpa-*-1.2.0.jar and include *.class files in my JAR bundle? Is there any
trick I should know?

Thanks in advance to all!
-- 
View this message in context: http://n2.nabble.com/Why-doesn%27t-unpacked-openjpa-works-like-packed-openjpa.jar--tp2455600p2455600.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Why doesn't unpacked openjpa works like packed openjpa.jar?

Posted by Targa <de...@bodnar.ws>.
Thanx! I can't believe! My jar bundle become 2 times larger but it works!

Hm... Very interesting =) 


Michael Dick wrote:
> 
> Have you tried
>        <dependency>
>            <groupId>org.apache.openjpa</groupId>
>            <artifactId>openjpa</artifactId>
>            <version>1.2.0</version>
>        </dependency>
> 
> Instead of openjpa-persistence and openjpa-persistence-jdbc?
> 

-- 
View this message in context: http://n2.nabble.com/Why-doesn%27t-unpacked-openjpa-works-like-packed-openjpa.jar--tp2455600p2456406.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Why doesn't unpacked openjpa works like packed openjpa.jar?

Posted by Michael Dick <mi...@gmail.com>.
Have you tried
       <dependency>
           <groupId>org.apache.openjpa</groupId>
           <artifactId>openjpa</artifactId>
           <version>1.2.0</version>
       </dependency>

Instead of openjpa-persistence and openjpa-persistence-jdbc?

-mike

On Tue, Mar 10, 2009 at 10:24 AM, Targa <de...@bodnar.ws> wrote:

>
> Hi, Mike! Thanks for your reply!
>
>
> Michael Dick wrote:
> > My first guess is that the services files aren't extracted "properly".
> > When
> > you use the maven-assembly-plugin is the
> > META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation file
> > included?
>
> This was one of my gueses, I checked this  - all service files extracted
> and
> actually included in my META-INF/services/. More over, I tryed manually
> unpack openjpa-*.jar files and put their content to my bundle in respect
> locations (from META-INF - to META-INF, for instance) with no luck =(
>
> The strange thing is that Persistence.createEntityManagerFactory doesn't
> throw  any exception and no messages is added to log (logging with default
> level TRACE).
>
> There is my pom.xml:
>
> <dependencies>
>        <dependency>
>            <groupId>h2</groupId>
>            <artifactId>h2</artifactId>
>            <version>1.1.106</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.openjpa</groupId>
>            <artifactId>openjpa-persistence</artifactId>
>            <version>1.2.0</version>
>            <!-- I also tryed 1.0.1 version -->
>        </dependency>
>        <dependency>
>            <groupId>org.apache.openjpa</groupId>
>            <artifactId>openjpa-persistence-jdbc</artifactId>
>            <version>1.2.0</version>
>        </dependency>
>    </dependencies>
>
>    <build>
>        <plugins>
>            <plugin>
>                <groupId>org.apache.maven.plugins</groupId>
>                <artifactId>maven-compiler-plugin</artifactId>
>                <configuration>
>                    <source>1.6</source>
>                    <target>1.6</target>
>                    <failOnError>true</failOnError>
>                </configuration>
>            </plugin>
>            <plugin>
>                <artifactId>maven-antrun-plugin</artifactId>
>                <executions>
>                    <execution>
>                        <phase>process-classes</phase>
>                        <configuration>
>                            <tasks>
>                                <java
> classname="org.apache.openjpa.enhance.PCEnhancer"
>                                      classpathref="maven.runtime.classpath"
>                                      dir="target/classes" fork="true"/>
>                            </tasks>
>                        </configuration>
>                        <goals>
>                            <goal>run</goal>
>                        </goals>
>                    </execution>
>                </executions>
>            </plugin>
>            <plugin>
>                <artifactId>maven-assembly-plugin</artifactId>
>                <configuration>
>                    <descriptorRefs>
>                    <descriptorRef>jar-with-dependencies</descriptorRef>
>                    </descriptorRefs>
>                    <archive>
>                        <manifest>
>                            <mainClass>ru.btr.locawiki.Locawiki</mainClass>
>                            <packageName>ru.btr.locawiki</packageName>
>                        </manifest>
>                        <manifestEntries>
>                            <mode>release</mode>
>                            <url>${pom.url}</url>
>                        </manifestEntries>
>                    </archive>
>                </configuration>
>                <executions>
>                    <execution>
>                        <id>make-assembly</id>
>                        <!-- this is used for inheritance merges -->
>                        <phase>package</phase>
>                        <!-- append to the packaging phase. -->
>                        <goals>
>                            <goal>single</goal>
>                            <!-- I also tryed "attached" here-->
>                        </goals>
>                    </execution>
>                </executions>
>            </plugin>
>        </plugins>
>    </build>
>
>
> --
> View this message in context:
> http://n2.nabble.com/Why-doesn%27t-unpacked-openjpa-works-like-packed-openjpa.jar--tp2455600p2455844.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Re: Why doesn't unpacked openjpa works like packed openjpa.jar?

Posted by Targa <de...@bodnar.ws>.
Hi, Mike! Thanks for your reply!


Michael Dick wrote:
> My first guess is that the services files aren't extracted "properly".
> When
> you use the maven-assembly-plugin is the
> META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation file
> included?

This was one of my gueses, I checked this  - all service files extracted and
actually included in my META-INF/services/. More over, I tryed manually
unpack openjpa-*.jar files and put their content to my bundle in respect
locations (from META-INF - to META-INF, for instance) with no luck =(

The strange thing is that Persistence.createEntityManagerFactory doesn't
throw  any exception and no messages is added to log (logging with default
level TRACE).

There is my pom.xml:

<dependencies>
        <dependency>
            <groupId>h2</groupId>
            <artifactId>h2</artifactId>
            <version>1.1.106</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-persistence</artifactId>
            <version>1.2.0</version>
            <!-- I also tryed 1.0.1 version -->
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-persistence-jdbc</artifactId>
            <version>1.2.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <configuration>
                            <tasks>
                                <java
classname="org.apache.openjpa.enhance.PCEnhancer"
                                      classpathref="maven.runtime.classpath"
                                      dir="target/classes" fork="true"/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>ru.btr.locawiki.Locawiki</mainClass>
                            <packageName>ru.btr.locawiki</packageName>
                        </manifest>
                        <manifestEntries>
                            <mode>release</mode>
                            <url>${pom.url}</url>
                        </manifestEntries>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- this is used for inheritance merges -->
                        <phase>package</phase>
                        <!-- append to the packaging phase. -->
                        <goals>
                            <goal>single</goal>
                            <!-- I also tryed "attached" here-->
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


-- 
View this message in context: http://n2.nabble.com/Why-doesn%27t-unpacked-openjpa-works-like-packed-openjpa.jar--tp2455600p2455844.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Why doesn't unpacked openjpa works like packed openjpa.jar?

Posted by Michael Dick <mi...@gmail.com>.
Hi,

My first guess is that the services files aren't extracted "properly". When
you use the maven-assembly-plugin is the
META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation file
included?

If you can post an example pom.xml that shows the problem it might help us
to diagnose.

Regards,
-mike

On Tue, Mar 10, 2009 at 9:48 AM, Targa <de...@bodnar.ws> wrote:

>
> Hello!
> I'm using maven2 tool to build my OpenJPA application with embedded
> database
> and run into strange OpenJPA behavior. What I want is just get JAR with all
> dependencies included in unpacked form. So there is maven-assembly-plugin
> used with <unpack>true</unpack> option. This actually creates big jar with
> all *.class dependencies included.
> When I try to run this jar, it doesn't work properly:
> Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, prop); returns
> NULL. I thought there could be an issue with persistence.xml, but If I
> manually include openjpa-persistence-1.2.0.jar to my package and add it to
> classpath - everething works fine...
> So I suppose there could be a problem with classloading (although I didn't
> use any custom classloaders). I tryed to manually set up classloader before
> call Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, prop);
> without
> any success.
>
> Please, tell me what's the problem? Why I can't just unzip
> openjpa-*-1.2.0.jar and include *.class files in my JAR bundle? Is there
> any
> trick I should know?
>
> Thanks in advance to all!
> --
> View this message in context:
> http://n2.nabble.com/Why-doesn%27t-unpacked-openjpa-works-like-packed-openjpa.jar--tp2455600p2455600.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>