I'm trying to work with Eclipse Mars 2 and Glassfish 3.1.2, but when I use EclipseLink 2.1 to create the entitites from tables, javax.persistence is not found in the buildpath.
Is this the normal behaviour?
I created the Oracle db connection with eclipse
I installed JEE 6 SDK with Glassfish 3
I started the glassfish server and configured the data source and connection pool.
I created a JPA project and created the entities from the db connection tables.
Something I find curious is that the jee.jar that is inside glassfish/lib only contains a pom.xml
Isn't Glassfish supposed to contain all the jars needed to develop with the jee standard?
Is my project meant to be a Maven project in order to automatically download this jars? Could I fix this by configuring my project as a Maven project?
Isn't Glassfish supposed to contain all the jars needed to develop with the jee standard?
Yes, and it contains all the jars needed but in an indirect way. Even though it is a single jar file with only one file, namely, MANIFEST.MF and a directory maven which contains the pom file you mentioned.
But if you open the MANIFEST.MF file you'll see that it is pointing to a lot of jar files in the Class-Path: entry which you need to be able develop JavaEE applications.
So everything is there and you only need to add this file into your dependency to be able to compile your JavaEE (Servlets, JSF, EJB, JPA, ...) classes and deploy on the server. But this (javaee.jar) must be a compile time dependency, i.e., should not be packaged with your application as the jars are already contained in the server.
Is my project meant to be a Maven project in order to automatically download this jars?
No. Your project can be but should not be a maven project. Let us say, for example, you have an Eclipse project where you want to develop an EJB application. Just right click on the project
go to the Properties -> Build Path page and change to Libraries tab
click on Add External Jars ...
go to the Glassfish lib directory and add the javaee.jar, and you are done.
now you can use all the JavaEE annotations and classes.
Related
I've build a spring-based web project in Eclipse using Maven. Dependencies and class path are correct and the deployment assembly also lists spring-web*.jar correctly. However, when I deploy it using WebSphere 8 from within Eclipse the mentioned JAR file is missing from the created libs folder under .metadata.plugins\org.eclipse.wst.server.core\tmp2*\WEB-INF\lib . This JAR however is listed under the module section as a submodule for the container. I wasn't able to find out, why this JAR is listed there and why it is not copied to the LIB folder.
It works with a Tomcat server, it works when I export the WAR and deploy it manually and it also works when I manually copy the JAR to the lib folder.
Q1: Is this specific to Websphere?
Q2: Why is SPRING-WEB listed as submodule and what effect has this?
Q3: How can I automatically deploy it correctly?
This seems to be a bug in WAS as reported here
You can either copy the missing JARs manually or you can use the "Run server with resources on server" option in the "Publishing settings for WebSphere Application Server" server settings.
I am developing a simple application with EJB 3.0 using OpenEJB for deployment and Eclipse as an IDE.
I created the project as a 'dynamic web application' in Eclipse. When I tried creating the first stateless session bean, I realized that the #Remote annotation could not be resolved.
What is the right way to fix this problem ?
Delete the project and create a new 'enterprise application project' (this seems to be pretty heavy weight, so I am not sure I want to go in this direction) ?
Delete the project and create an EJB project (this does not seem to be right because I believe such a project will only let me bundle the EJB part of the application) ?
Add some libraries to my existing project (is there a library pack for EJB 3.x) ?
Add a facet to my existing project (I tried to see if I can add a facet, but I cannot see an EJB facet within the context of this project) ?
Thanks for helping.
Update:
I found the answer.
TomEE's installation has a directory containing all the jar files needed to compile and run EJB's 'apache-tomee-webprofile-1.0.0-beta-2/webapps/openejb/lib'
I created a User Library in Eclipse containing all the jars from the lib folder described above and added it to the build path.
The EJB interfaces now compile properly.
Create an new Enterprise Application Project (EAP)
Create an new EJB Project and add it to the EAP
Add to the EAP your existent WEB project
Now you can create EJBs in the EJB project and call them from the WEB project.
And you can deploy or debug your EAP on an Application Server (like JBoss) that supports Enterprise Application Projects.
The EAP is deployed as a unique file with .ear extension.
If you use Tomcat for example you cannot deploy the ear packages.
Here a page with a description about creating ear with Eclipse.
A simple way to add eclipse library support for TomEE or TomEE+ is the following:
Create a Tomcat 7 server in eclipse. (Change the name to reflect it's TomEE)
Point it to your tomEE install directory.
In your project goto: Properties -> Java Build Path -> Libraries.
Press "Add library".
Select "Server runtime", and press next.
Select the TomEE server profile you just created and click finish.
Click OK.
The tomEE libraries have been added to your eclipse project.
I'm using maven and get it work with the following simple steps:
Open Project -> Properties -> Deployment Assembly
Click 'Add...'
Choose 'Java Build Path Entries'
Choose 'Maven Dependencies'
That's it!
I build a java enteprise application in netbeans 7.1 which consists of two EJB modules. One of the EJB modules has a reference to another class library project, lets call it MyUtilities. When i deploy the application, its ear file does not contain MyUtilities.jar file. When i add to the other EJB module libraries MyUtilites project, although its not necessary, the ear file is built correctly and under its lib folder, MyUtilities.jar exists.
Anyone with the same issue?
Thanks
Did you check the setting of the checkbox "Package required JARs in EJB jar" in the Build | Packaing dialog?
This is a new option which I found after upgrading a NetBeans 6.5.1 EJBModule project which had also no longer the references JARs bundled in the EJB jar.
I am using eclipse and added tomcat 6 server. whenever i try to start the server it automatically copies the server api jar into the WEBINF/lib folder and the app does not start
INFO: validateJarFile(/media/01CB9CAC704E03A0/Projects/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/myapp/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
I got the same problem and finally got it to work after looking at this among other pages. I am going to list it here in case other people run into the same issue.
In my case, the myeclipse project was created from a maven .pom file which lists the JEE 1.5 files as "provided" scope i.e. these files will be provided by the container (in my case tomcat 6). So if I create a war file using maven and drop it in the webapps dir it just works fine. It gets a little tedious doing that every time you make a change, so I decided to go for exploded deployment and thats when I ran into the same issue.
Since the project file was created from the pom file, these dependencies came in but Eclipse project file does not recognise these as "provided" and not to be deployed. And TOMCAT is not happy when it finds two implementations of the spec:
"Servlet spec 2.3 sec 9.7.2 recommends … The classloader that a container uses to load a servlet in a WAR must allow the developer to load any resources contained in library JARs within the WAR following normal J2SE semantics using getResource. It must not allow the WAR to override J2SE or Java servlet API classes. It is further recommended that the loader not allow servlets in the WAR access to the web container’s implementation classes. It is recommended also that the application class loader be implemented so that classes and resources packaged within the WAR are loaded in preference to classes and resources residing in container-wide library JARs."
I toyed with the above solution to change my deplyment assembly config but that is not helpful alone since these jars get bundled in if I select the "JARS from the build path"
in the menu project properties/MyEclipse/Web/Deplyment/Configure workspace settings.
And I need to do that cos I have other dependencies jars (not provided by container).
Solution:
I removed these jars from the dependencies in the build path manually.
Instead I added a dependency on User Library - JAVA EE5.
And in the deployment configuration I removed the option of JARS exported from User Libraries of required projects.
YMMV. But in any case if you read the servlet spec definition above and then look at the config in your workspace, you can sort it out.
Hope this helps.
Go to your project properties and look under Deployment Assembly page. This page describes how your app will be packaged for deployment or export. Take a look at entries regarding libraries. You have to figure out which of those entries points to the servlet api jar and remove it. If the entry points to other jars that do need to be packaged, you will need to split it into several separate build path entries, so you can tell Eclipse exactly what does and does not need to be packaged.
Summary
Classes from 3rd party jar files are accessible when added to build path while running a standalone JUnit test, but "ClassNotFoundException" when accessed through plain old java objects from within a dynamic web project.
IDE used: Eclipse
Web Server: Apache 7
Details
My project required a lot of 3rd party jars, namely sqlite, eclipse jdt & jsoup. I had created this project as a standalone project and all the classes from the jars were accessible fine.
But now I have copied the entire "src" folder into a "dynamic web project". I have created a folder "jars" which contains all these 3rd party jars and ensure that all of these are added to the build path by following these steps:
Project properties --> Java Build Path --> Libraries --> Add jars --> Select all the jar files from jars folder.
These jars are accessible fine when I run a standalone JUnit test inside the web project. Note that this junit test does not require a server by any means.
But when I try to "Run on Server.." , I keep on getting ClassNotFoundException like these for all the 3rd party classes:
java.lang.ClassNotFoundException: org.sqlite.JDBC
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1672)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1517)
I'm sure this has got to do something with my lack of knowledge of how applications are deployed on the web.
The runtime classpath can be different from the build classpath. Create an explicit launch configuration. The default will start with the build classpath but you may have to manually tweak it to include those 3rd party jars.
I've run into this problem before with Eclipse and the Web Server Tools project. Check your .settings files and other files for configuring the plugins that you're using with your project. You may have to remove some filters in the Eclipse view. WST constructs its build path differently, so it may not be using the jars that you've included in your project.
I figured it out. I just had to put all the jars in the WEB-INF/lib directory. I assumed that Eclipse would do all the required settings for me when I asked it to use the mentioned jars. But I guess there are somethings that are not automated very well.