You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ulrich Wolf <m...@il.wolf-u.li> on 2008/11/12 22:08:29 UTC

OpenJPA (together with jtds) cannot find javax.persistence?

Hello,

 

in a project of a new customer we have to add several functionalities to an
existing desktop application (swing) which accesses a mssql-database-server.
To simplify the process of testing and packaging for a team of 4 developers,
we've set up maven.

 

Problem is, that we have to use openjpa (the application already uses it).
But I have some serious issues with the javax.persistence which is needed
for openjpa:

 

[INFO] Exception in thread "main" java.lang.NoClassDefFoundError:
javax/persistence/Persistence

[INFO] at tld.company.appname.database.meta (Startup.java:19)

[INFO] Caused by: java.lang.ClassNotFoundException:
javax.persistence.Persistence

[INFO] at java.net.URLClassLoader$1.run(Unknown Source)

 

As you can see, javax.persistence is not available in the classpath. I have
added the following dependency to my pom.xml to hopefully solve this issue,
but it didn't work:

<dependency>

                <groupId>javax.persistence</groupId>

                <artifactId>persistence-api</artifactId>

                <version>1.0</version>

                <type>jar</type>

                <scope>compile</scope>

</dependency>

 

Sill doesn't find the persistence api.The other (important) dependencies for
the database-connection are:

 

<dependency>

                <groupId>org.apache.openjpa</groupId>

                <artifactId>apache-openjpa</artifactId>

                <version>1.2.0</version>

                <type>pom</type>

                <scope>compile</scope>

</dependency>

<dependency>

                <groupId>net.sourceforge.jtds</groupId>

                <artifactId>jtds</artifactId>

                <version>1.2.2</version>

                <type>jar</type>

                <scope>compile</scope>

</dependency>

 

I've searched a lot, but didn't find other solutions than converting the
project to hibernate or to install the j2ee-sdk. The first solution
(hibernate) is a little too much at the moment (this would require a bigger
amount of time and probably a change-request). The second one would be my
last choice, as we have nothing to do with j2ee until now.

 

Is there any easier way (hopefully simply by adding some package to the
pom.xml)? Or did I overlook something? Everything works without the
database, every additional library (e.g. iText) can be found, so what can I
do?

 

If you need any descriptions or additional information, let me know!

 

Thanks in advance!

Regards,

Uli


AW: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Ulrich Wolf <m...@il.wolf-u.li>.
Thanks for the hint. I've tried it together with javax.persistence and
without, adding some other packages of hibernate, but had no luck.

I've solved the problem for now by using a EJB injection. I don't know any
other way to solve this.

Thanks anyway for your answer!

Uli

>I thought you could use Hibernate's JPA stuff just for JPA, without needing
to use the full Hibernate package.  For example,
>
>        <dependency>
>            <groupId>org.hibernate</groupId>
>            <artifactId>ejb3-persistence</artifactId>
>            <version>1.0.1.GA</version>
>        </dependency>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Rusty Wright <ru...@gmail.com>.
I thought you could use Hibernate's JPA stuff just for JPA, without needing to use the full Hibernate package.  For example,

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>ejb3-persistence</artifactId>
            <version>1.0.1.GA</version>
        </dependency>


Ulrich Wolf wrote:
> Hello,
> 
>  
> 
> in a project of a new customer we have to add several functionalities to an
> existing desktop application (swing) which accesses a mssql-database-server.
> To simplify the process of testing and packaging for a team of 4 developers,
> we've set up maven.
> 
>  
> 
> Problem is, that we have to use openjpa (the application already uses it).
> But I have some serious issues with the javax.persistence which is needed
> for openjpa:
> 
>  
> 
> [INFO] Exception in thread "main" java.lang.NoClassDefFoundError:
> javax/persistence/Persistence
> 
> [INFO] at tld.company.appname.database.meta (Startup.java:19)
> 
> [INFO] Caused by: java.lang.ClassNotFoundException:
> javax.persistence.Persistence
> 
> [INFO] at java.net.URLClassLoader$1.run(Unknown Source)
> 
>  
> 
> As you can see, javax.persistence is not available in the classpath. I have
> added the following dependency to my pom.xml to hopefully solve this issue,
> but it didn't work:
> 
> <dependency>
> 
>                 <groupId>javax.persistence</groupId>
> 
>                 <artifactId>persistence-api</artifactId>
> 
>                 <version>1.0</version>
> 
>                 <type>jar</type>
> 
>                 <scope>compile</scope>
> 
> </dependency>
> 
>  
> 
> Sill doesn't find the persistence api.The other (important) dependencies for
> the database-connection are:
> 
>  
> 
> <dependency>
> 
>                 <groupId>org.apache.openjpa</groupId>
> 
>                 <artifactId>apache-openjpa</artifactId>
> 
>                 <version>1.2.0</version>
> 
>                 <type>pom</type>
> 
>                 <scope>compile</scope>
> 
> </dependency>
> 
> <dependency>
> 
>                 <groupId>net.sourceforge.jtds</groupId>
> 
>                 <artifactId>jtds</artifactId>
> 
>                 <version>1.2.2</version>
> 
>                 <type>jar</type>
> 
>                 <scope>compile</scope>
> 
> </dependency>
> 
>  
> 
> I've searched a lot, but didn't find other solutions than converting the
> project to hibernate or to install the j2ee-sdk. The first solution
> (hibernate) is a little too much at the moment (this would require a bigger
> amount of time and probably a change-request). The second one would be my
> last choice, as we have nothing to do with j2ee until now.
> 
>  
> 
> Is there any easier way (hopefully simply by adding some package to the
> pom.xml)? Or did I overlook something? Everything works without the
> database, every additional library (e.g. iText) can be found, so what can I
> do?
> 
>  
> 
> If you need any descriptions or additional information, let me know!
> 
>  
> 
> Thanks in advance!
> 
> Regards,
> 
> Uli
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: AW: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Stephen Coy <st...@resolvesw.com>.
So you are running from inside Eclipse?

Your original message had "INFO] at java.net.URLClassLoader 
$1.run(Unknown Source)" in the stack trace.

Are all the dependencies available to this class loader?


On 16/11/2008, at 11:52 PM, Ulrich Wolf wrote:

>> How are you adding these jars to your runtime classpath?
> Maven downloads them from the central repository as soon as I run  
> maven. I
> did not add any external repositories, I'm using the default one.
>
> Why do I assume, that everything is included into the classpath?  
> I've also
> included itext, junit and javadoc via pom.xml and these work  
> flawlessly
> without any changes.
> My ".classpath" looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> 	<classpathentry kind="src" output="target/classes"
> path="src/main/java"/>
> 	<classpathentry excluding="**" kind="src" output="target/classes"
> path="src/main/resources"/>
> 	<classpathentry kind="src" output="target/test-classes"
> path="src/test/java"/>
> 	<classpathentry excluding="**" kind="src"
> output="target/test-classes" path="src/test/resources"/>
> 	<classpathentry kind="con"
> path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
> 	<classpathentry kind="con"
> path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
> 	<classpathentry kind="output" path="target/classes"/>
> </classpath>
>
> Perhaps this helps to figure out why javax.persistence doesn't work  
> on my
> project...
>
> Uli
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Ulrich Wolf <m...@il.wolf-u.li>.
> How are you adding these jars to your runtime classpath?
Maven downloads them from the central repository as soon as I run maven. I
did not add any external repositories, I'm using the default one.

Why do I assume, that everything is included into the classpath? I've also
included itext, junit and javadoc via pom.xml and these work flawlessly
without any changes.
My ".classpath" looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" output="target/classes"
path="src/main/java"/>
	<classpathentry excluding="**" kind="src" output="target/classes"
path="src/main/resources"/>
	<classpathentry kind="src" output="target/test-classes"
path="src/test/java"/>
	<classpathentry excluding="**" kind="src"
output="target/test-classes" path="src/test/resources"/>
	<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
	<classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
	<classpathentry kind="output" path="target/classes"/>
</classpath>

Perhaps this helps to figure out why javax.persistence doesn't work on my
project...

Uli


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Stephen Coy <st...@resolvesw.com>.
How are you adding these jars to your runtime classpath?

On 15/11/2008, at 1:58 AM, Ulrich Wolf wrote:

>> This is the jar that contains all of the javax.persistence classes.
>> You may need the other dependencies listed in the OpenJPA POM too.
>
> I've now included the following artifacts, as you suggested. I  
> thought, that
> these will be resolved by the pom-file itself. Problem is, that the  
> failure
> is still the same.
>
> <groupId>javax.persistence</groupId>
> <artifactId>persistence-api</artifactId>
>
> <groupId>net.sourceforge.jtds</groupId>
> <artifactId>jtds</artifactId>
>
> <groupId>org.apache.openjpa</groupId>
> <artifactId>openjpa</artifactId>
>
> <groupId>org.apache.geronimo.specs</groupId>
> <artifactId>geronimo-jpa_3.0_spec</artifactId>
>
> <groupId>org.apache.geronimo.specs</groupId>
> <artifactId>geronimo-jta_1.1_spec</artifactId>
>
> <groupId>org.apache.geronimo.specs</groupId>
> <artifactId>geronimo-jms_1.1_spec</artifactId>
>
> <groupId>commons-pool</groupId>
> <artifactId>commons-pool</artifactId>
>
> <groupId>commons-collections</groupId>
> <artifactId>commons-collections</artifactId>
>
> <groupId>commons-lang</groupId>
> <artifactId>commons-lang</artifactId>
>
> <groupId>commons-logging</groupId>
> <artifactId>commons-logging</artifactId>
>
> <groupId>net.sourceforge.serp</groupId>
> <artifactId>serp</artifactId>
>
> <groupId>org.apache.openjpa</groupId>
> <artifactId>openjpa-xmlstore</artifactId>
>
> <groupId>org.apache.openjpa</groupId>
> <artifactId>openjpa-persistence-jdbc</artifactId>
>
> <groupId>org.apache.openjpa</groupId>
> <artifactId>openjpa-persistence</artifactId>
>
> <groupId>org.apache.openjpa</groupId>
> <artifactId>openjpa-jdbc</artifactId>
>
> <groupId>org.apache.openjpa</groupId>
> <artifactId>openjpa-kernel</artifactId>
>
> <groupId>org.apache.openjpa</groupId>
> <artifactId>openjpa-lib</artifactId>
>
> My Code goes like this:
>
> 	EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("appname");
> 	EntityManager em = emf.createEntityManager();
>
> And the error
> 	[INFO] Exception in thread "main" java.lang.NoClassDefFoundError:
> javax/persistence/Persistence
>
> Which comes up in the first line, of this code. Imports are correct,  
> eclipse
> did them.
>
> When I use the Injection like this:
> 	@PersistenceContext(unitName = "grademaster")
> 	private static EntityManager em;
>
> it works, but the main-problem is a really strange Error...
>
> The injection solved it (at least for me, we'll see, what my  
> database-coder
> says) for me ;)
>
> Uli
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Ulrich Wolf <m...@il.wolf-u.li>.
> This is the jar that contains all of the javax.persistence classes.  
> You may need the other dependencies listed in the OpenJPA POM too.

I've now included the following artifacts, as you suggested. I thought, that
these will be resolved by the pom-file itself. Problem is, that the failure
is still the same.

<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>

<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>

<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>

<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_3.0_spec</artifactId>

<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>

<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>

<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>

<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>

<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>

<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>

<groupId>net.sourceforge.serp</groupId>
<artifactId>serp</artifactId>

<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-xmlstore</artifactId>

<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-persistence-jdbc</artifactId>

<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-persistence</artifactId>

<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-jdbc</artifactId>

<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-kernel</artifactId>

<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-lib</artifactId>

My Code goes like this:

	EntityManagerFactory emf =
Persistence.createEntityManagerFactory("appname");
	EntityManager em = emf.createEntityManager();

And the error
	[INFO] Exception in thread "main" java.lang.NoClassDefFoundError:
javax/persistence/Persistence

Which comes up in the first line, of this code. Imports are correct, eclipse
did them.

When I use the Injection like this:
	@PersistenceContext(unitName = "grademaster")
	private static EntityManager em;

it works, but the main-problem is a really strange Error...

The injection solved it (at least for me, we'll see, what my database-coder
says) for me ;)

Uli


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Problem accessing resources

Posted by "Pruitt, Byron S" <st...@hp.com>.
I can't get a link to an javadoc external resource to work.  The javadoc plugin FAQ suggests ${basedir}/src/main/javadoc.

I couldn't get this work because the constructed link references target/.../apidocs/"package path"/resource.  The resource is not copied from its location in the src directory to the expected target directory location.

The javadoc documentation suggests putting the resource in a folder named doc-files whose parent is one of the package folders.  I tried src/../com/doc-files, but the resource is not getting copied to anywhere in the target/site folder.

I guess my question is how does, or what triggers javadoc to copy a resource from somewhere in the src directory to somewhere in the target directory?

My link looks like @see <a href="r4[1].core.pdf">OSGi Core Release 4</a>.  Until I know where the resource gets copied in target, I don't know how to build the link.


-Steve

Re: AW: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Wayne Fay <wa...@gmail.com>.
> For reasons best known to themselves the Open* guys decided to package their
> own versions of the javax.* classes, rather than using the standard ones.
> They are normally found in the org.apache.geronimo.specs group.

You simply don't know the history of this issue. The "standard" ones
have only just recently become licensed under terms which would permit
them to be more freely available (eg in Central, without a click-thru
license agreement on Sun.com) and used or bundled with other bits and
distributed by anyone without a specific license agreement with Sun to
do so.

For this reason, the Geronimo guys created their own version of the
APIs which are essentially whiteroom clones of the APIs delivered by
Sun (built using the API documentation, I assume). And the Geronimo
license permits easier use and distribution of these APIs as it is
using the Apache license 2.0. While the Geronimo specs are, for all
intents, identical to what Sun was delivering, that doesn't mean
Geronimo should be allowed to publish their artifacts under the
javax.* groupId.

Sun has just recently (in the last 2 years) begun converting their
licenses to more open models, so people like Geronimo will not have to
repeat these efforts in the future, hopefully.

You can read more here:
http://maven.apache.org/guides/mini/guide-coping-with-sun-jars.html

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: AW: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Stephen Coy <st...@resolvesw.com>.
Hi,

The POM for this version of OpenJPA refers to the following dependency:

         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jpa_3.0_spec</artifactId>
         </dependency>

This is the jar that contains all of the javax.persistence classes.  
You may need the other dependencies listed in the OpenJPA POM too.

For reasons best known to themselves the Open* guys decided to package  
their own versions of the javax.* classes, rather than using the  
standard ones. They are normally found in the  
org.apache.geronimo.specs group.

Cheers,

Steve C



On 13/11/2008, at 10:45 PM, Ulrich Wolf wrote:

>> What kind of project is this -- jar, war, ear, etc? And are you sure
>> the artifact providing the Persistence class is available in the
>> classpath at runtime?
>
>> Are you sure the type=pom is appropriate for the openjpa artifact?
> This was wrong of course, thank you. I've tried too many  
> configurations
> for openjpa...The correct configuration would be:
>
> <dependency>
> 	<groupId>org.apache.openjpa</groupId>
> 	<artifactId>openjpa</artifactId>
> 	<version>1.2.0</version>
> 	<type>jar</type>
> 	<scope>compile</scope>
> </dependency>
>
>> The persistence-api is just that, an API, eventually someone has to
>> provide an implementation somewhere in the project for things to  
>> work.
> I've used an example from the manual of openjpa, but now I found a way
> to solve my issue by using a EJB injection. Hopefully this will work
> with two databases.
>
> I installed the J2EE-SDK, but this didn't solve my issue...for now I
> will use the injection.
>
> Thank you for your answer!
>
> Uli
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Ulrich Wolf <m...@il.wolf-u.li>.
> What kind of project is this -- jar, war, ear, etc? And are you sure
> the artifact providing the Persistence class is available in the
> classpath at runtime?

> Are you sure the type=pom is appropriate for the openjpa artifact?
This was wrong of course, thank you. I've tried too many configurations
for openjpa...The correct configuration would be:

<dependency>
	<groupId>org.apache.openjpa</groupId>
	<artifactId>openjpa</artifactId>
	<version>1.2.0</version>
	<type>jar</type>
	<scope>compile</scope>
</dependency>

> The persistence-api is just that, an API, eventually someone has to
> provide an implementation somewhere in the project for things to work.
I've used an example from the manual of openjpa, but now I found a way
to solve my issue by using a EJB injection. Hopefully this will work
with two databases.

I installed the J2EE-SDK, but this didn't solve my issue...for now I
will use the injection.

Thank you for your answer!

Uli


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Ulrich Wolf <m...@il.wolf-u.li>.
Sorry, I forgot to answer the first two questions, perhaps
these could lead to a solution.

> What kind of project is this -- jar, war, ear, etc?
It's a JAR-project.

> And are you sure the artifact providing the Persistence class is
> available in the classpath at runtime?
As every other artifact is available, I think: Yes, it's available.

Uli


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: OpenJPA (together with jtds) cannot find javax.persistence?

Posted by Wayne Fay <wa...@gmail.com>.
> As you can see, javax.persistence is not available in the classpath. I have
> added the following dependency to my pom.xml to hopefully solve this issue,
> but it didn't work:

What kind of project is this -- jar, war, ear, etc? And are you sure
the artifact providing the Persistence class is available in the
classpath at runtime?

Are you sure the type=pom is appropriate for the openjpa artifact? The
persistence-api is just that, an API, eventually someone has to
provide an implementation somewhere in the project for things to work.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org