Javax.persistance not available in TomEE - java

When running my Java EE app on TomEE I get the following error:
java.lang.NoClassDefFoundError: javax/persistence/NamedStoredProcedureQuery
There are no compile time errors when I build the app.I am developing in Eclipse and have Apache TomEE selected under targeted runtimes in the project properties, so that the project has access to Java EE.
As the project uses Hibernate I have the following jars in the WEB-INF\lib directory (it's my understanding that these jars in turn use javax.persistence):
hibernate-commons-annotations-4.0.4
hibernate-core-4.3.5
hibernate-jpa-2.1
I've seen a bunch of questions like this one detailing that the solution is to add the required JPA jar into the lib directory of the app and all will be well. But although that solution may work it sounds hacky to me, I want TomEE to manage the JPA libraries itself. It's a Java EE server so why doesn't it do this. Whats a clean solution?

#JB Nizet's answer is the accepted solution:
This class exists since JPA 2.1. I guess your TomEE version only
supports JPA 2.0. And indeed, thehome page of TomEE says: "Java EE 6
Web Profile". Java EE 6 includes JPA 2.0, not 2.1. – JB Nizet

Related

How to integrate standalone Java EE 6 inside Eclipse IDE

I am facing issue with Maven 3.x where I am getting Guice Provision error.
With further debugging and investigation, I found the core issue that it is due to Java EE 6 not present inside my Eclipse IDE (Java EE 5 is there with one web server installed) and Guice library is looking for some Java Class which is available with Java EE 6.
Is it possible that I integrate the standalone JavaEE 6 inside Eclipse IDE without installing any webserver or updating the current one?
You can add a maven dependency for Java EE 6 (http://search.maven.org/#artifactdetails%7Cjavax%7Cjavaee-api%7C6.0%7Cjar) to your project, and eclipse will gladly understand it.
However, your runtime will also need to be a Java EE 6 compliant container. Otherwise, you'd simply be looking for trouble. You may run into problems at runtime if you use a pre-Java EE 6 container (especially if you use newer features -- such as CDI).
Alternatively, if your library wants a specific feature (like, as I dare to guess, the CDI api), then you can add just the CDI jars to your classpath (check http://search.maven.org/#artifactdetails%7Cjavax.inject%7Cjavax.inject%7C1%7Cjar)

FakeHttpServer breaks when upgrading to Jetty 9

I am migrating an application that used Jetty 7.4.5.v20110725 to Jetty 9.3.0.M2, using Maven. I already had upgraded the javax.servlet-api to 3.1.0.
But I am using the FakeHttpServer version 0.3.0 for tests, and at this time there is no newer version. It uses the org.eclipse.jetty.server.nio.SelectChannelConnector class that used to exist up to Jetty 8.x, but does not exists anymore in Jetty 9.
Currently my projects breaks at runtime with a NoClassDefFoundError due to the removed class in Jetty that FakeHttpServer tries to use, holding me back from upgrading Jetty. What can I do to fix that?
Note, this was also cross-posted in the Portuguese StackOverflow version: https://pt.stackoverflow.com/q/64548/132
Upgrade the code that uses Jetty on FakeHttpServer for Jetty 9.
That is your only choice if you want to use Jetty 9 with FakeHttpServer.
Looking at the project page for FakeHttpServer, it seems that there have been no updates (commits) to the project tree since Dec 2012.
You'll either have to convince the project leads to update it, or do it yourself.
Note that Jetty contains several ways of testing webapps. Look at the unit tests in the jetty source code and I'm sure you will find the equivalent of FakeHttpServer.
ServletTester comes to mind as one example. Or just create a Server using the LocalConnector is another way.

Build web service with jax-ws reference implemetation bundled in JDK 6

I used to saw a tutorial about this topic. But when I try to make my example application by following the example. I can't find com.sun.xml.ws.transport.http.servlet.WSServletContextListener on my classpath.
but I found com.sun.xml.internal.ws.transport.http.servlet.WSServletContextListener
It confused me, why Oracle move those classes in com.sun.xml.xxx to com.sun.xml.internal? I am using JDK1.6.0_45. I saw some people said, form JDK6U4, jax-ws reference implementation is bundled in JDK, so we should be able to publish a web service by running a light weight http server just with JDK and no other dependencies needed, is that ture? You should notice that in the tutorial I mentioned above, additional dependencies is still needed, see step 5 "JAX-WS Dependencies".
And I also found that in IBM JDK, even com.sun.xml.internal.ws.transport.http.servlet.WSServletContextListener can't be found.
Yes, JAX-WS RI (same as JAX-B RI) is shipped with JDK since Jdk6. All the packages except for javax.xml.* are changed to .internal. in order to avoid conflicts between JDK's and standalone JAX-WS versions.
Using JDK's version, you can deploy web service using just JDK; if you want deploy WS in tomcat or in some AS, you still need JAX-WS standalone version.
If you check grepcode for (non-internal) WSServletContextListener, it shows you, the class is shipped with jaxws-rt/webservice-rt jar.
By looking for the internal WSServletContextListener, you can't find a jar shipping it. (but grepcode also contains the sources of openJDK)
Also, I tried to find WSServletContextListener in my local jdk7, but can't find it. But maybe some third-party jdk ship with the class.
Anyway, if you look into the tutorial again, you will find that jaxws-rt.jar is necessery for the application. Probably you should add it?

Not able to Create a JSF Project in new Eclipse Indigo M6a Java EE using JBOSS Tools 3.3.o M1

I have followed the below link to install and configure JBOSS Tools in Eclipse Indigo to work on a JSF project
http://planet.jboss.org/post/jboss_tools_milestone_for_eclipse_3_7_m6_indigo
Steps i followed.
1.Installed Eclipse
2.Configured Proxy
3.Loaded the Urls as specified in above link
however many of the packages fails during installation and i cant see a JSF project in the new project list.
What could be wrong here?. Please help me with some pointers.
You're reading an outdated tutorial. Eclipse Indigo was already finalized a few weeks after that tutorial was written. Even more, it's already in SR1 stage. You can download it here. Finally, you can try to install the JBoss tools through the following URL:
http://download.jboss.org/jbosstools/updates/development/indigo/
It works at least for me.
Please note that you do not necessarily need JBoss Tools in order to be able to create a JSF project. It's already built in Eclipse for Java EE. Just create a new Dynamic Web Project. JSF is available as one of the project facets which is configureable in the Configuration option of the 1st step of the Dynamic Web Project wizard.
The JBoss Tools is just an additional plugin which eases JSF development with several additional (autocomplete) wizards.
See also:
JSF 2.0 tutorial with Eclipse and Glassfish - contains a lot of helpful screenshots

Problem whille adding project into the websephere 6.1

I am using IBM web-sphere 6.1 as a application server and eclipse as IDE. so i have one project name as MobileBank.ear which contain deployment descriptor file which has one module name as amsejb.jar which is ejb project and some jar files. so while adding MobileBank.ear into the server i am getting the following error " Web-Sphere v6.0 only supports J2EE 1.2, 1.3, and 1.4 Enterprise applications." due to this error i am not able to deploy my ear can anyone guide me please... also MobileBank.ear contains web project though i am not able to add the ear. Kindly Guide me...
Thanks in advance...
Vinod
I am using IBM web-sphere 6.1 ... Web-Sphere v6.0 only supports ... Are you sure you are using WAS 6.1 ?? May be this is what causing the problem
Well, 6.1 really doesn't support more than 1.4 and you're attempting to use newer versions.. You should
Edit the project facets in the project properties to utilize older versions
Not select 6.0 when generating the project as the target. That is used for the remote deployment etc. Eclipse does not really support 6.1/7.x deployment so please generate the generic projects instead.
i deleted the EAR folder ,created new Enterprise Application Project and added all project in that . error got resolved .
I am using WAS 7.0
U need to change the WebSphere Application Server version under Coniguration section while creating a project in Eclipse/RAD.
Then Dynamic Web module version will get changed from 3.0 to 2.5
While creating a dynamic web project,
-- On entering the "project name"
-- we have an option to check "Add project to EAR"
-- Enter the EAR name
-- choose the EAR version on of these - 1.2, 1.3, 1.4 and 5.0
On doing this, we would be able to add the EAR to WAS (I have been using v7)

Categories