Jars needed for Objectify4 - java

We have a legacy system that was just ported to AppEngine. So now we need to use Objectify4, however the legacy application we have is not yet "mavenized" so we add jars manually. What are all the jarts needed to be placed in WEB-INF/lib folder so Objectify jars and its depenedencies will work.
The current AppEngine version we set in the classpath is 1.7.2

You can download the builds from the Maven repo here:
https://objectify-appengine.googlecode.com/svn/maven/com/googlecode/objectify/objectify/
That being said, there doesn't appear to be any guarantee with these files so use at your own discretion.
Depending on when how soon you plan to deploy your product, it may make more sense to build your service using v3 as opposed to v4 for now.

Quoting from Objectify documentation:
Add objectify-N.N.N.jar to your project's WEB-INF/lib directory. There are no other jar dependencies.
Edit: The jars are located in the Maven Repository, by browsing the source. For example, here you can find the objectify-4.0a4.jar.
Hope this helps!

Related

Make JAR available to JDK and JRE

I am running a web application using Tomcat, JDK8 and Netbeans IDE (using ANT for build and IVY for dependency management).
I currently place JARs that need to be available to the JRE (servlet-api.jar, jsp-api.jar, el-api.jar, tomcat-dbcp.jar) in JAVA_HOME/jre/lib/ext.
I'm upgrading to a new JDK version (JDK17), which no longer has the JRE extensions folder. I'm wondering where I should place these JARs.
According to this post (and others I've seen), it is better practice to use a dependency manager and add these jars to your classpath anyway.
I currently use IVY to manage my dependencies and have customized my ANT build to add run-time dependencies to the WEB-INF/lib folder of the built WAR file.
However, I do not need the JARs I listed above to be available to my application at runtime, I need them to be available to the JRE. That is, I do not want the JARs (servlet-api.jar, etc.) to be in WEB-INF/lib of my built WAR file.
How can I do this?
Sharpening my final questions:
How can I make certain JARs/dependencies available to the JRE in Netbeans in my development environment?
How can I make certain JARs/dependencies available to the JRE in the built WAR file used on my production environment?
Am I correct in saying that these JARs need to be available to the JRE? All of the posts I've seen discuss compile-time vs run-time dependencies but it seems the case I'm describing is a different category of dependency. Is this correct?
I currently place JARs that need to be available to the JRE (servlet-api.jar, jsp-api.jar, el-api.jar, tomcat-dbcp.jar) in JAVA_HOME/jre/lib/ext.
That's not the best way to do things. See Is putting external jars in the JAVA_HOME/lib/ext directory a bad thing?
Note that the jre/lib/ext mechanism has been removed from newer versions of Java, so this will not work anymore if you use a newer version of Java. (This has been removed in JDK 9).
However, I do not need the JARs I listed above to be available to my application at runtime, I need them to be available to the JRE.
Why?
That is, I do not want the JARs (servlet-api.jar, etc.) to be in WEB-INF/lib of my built WAR file. How can I do this?
Why not? Putting the dependencies that your application needs in WEB-INF/lib is the normal thing to do in Java web applications. Why do you want to do things the non-standard way?
But: Some JAR files, such as servlet-api.jar, jsp-api.jar and el-api.jar are not supposed to be included in your application. Those JAR files define standard Java EE / Jakarta EE APIs and will be provided to your application at runtime by the application server (Tomcat, etc.) that you deploy your WAR file in.
You can add those JAR files as dependencies using Maven with provided scope, which means they will be used while compiling, but won't be packaged into your application.
Am I correct in saying that these JARs need to be available to the JRE?
No, those JARs do not need to be available to the JRE. JAR files that contain standard APIs will be provided by your Java EE / Jakarta EE container at runtime. Other JAR files should be included in your application in WEB-INF/lib.

Jar picks wrong dependency version from on-premise lib

I have a system where modules are build and deployed into a system. All jars are located under lib folder in that system. My jar has a dependency to commons-io of version 2.0 and other module has dependency to commons-io, too but of version 1.1. So, both versions are deployed to lib folder. There is a method that exists in 2.0 but not in 1.1. When I ran my own jar, it goes and picks old version which is 1.1 ,and it causes NoSuchMethodError. I am using maven. Is there a way to force my module to use the version that I set in pom.xml? I cannot ask other module maintainer for a version change as this lib comes as 4th level transitive dependency.
If you have two different versions of the same JAR in the lib folder and load the whole lib folder onto the classpath, then you are playing roulette.
The JVM may pick one or the other version, and while in theory, you probably can figure out the rules, in practise, it is just unstable.
So, what can you do? Some alternatives:
Remove the version 1.1 from the lib folder and see whether the other module runs with 2.0 as well (often, version upgrades are more or less compatible)
Use two different lib folders, or construct the classpath manually for the two JARs. Only possible if they do not run in the same JVM.
Use the maven shade plugin to shade the required library into your own JAR.
Most of commons-io is obsolete by now because adequate classes/methods are already part of the JDK (from Java 8 upwards). So you might just be able to remove commons-io from your project and do the file handling with Java itself.

Add Maven Classpath

My project requires some external libraries to build in in Eclipse. They live in /trunk/lib whereas my project is in /trunk/projectA. To get Eclipse to find the libraries on all machines we set a variable PROJECT_A_HOME.
Now I'm trying to get some builds going with maven and I can not figure out how to add that path (be it environmental variable or relative to $(basedir)) to the build. I really do not want to set up a repository for these dependencies, as I keep them in source control and want builds to continue to work in Eclipse.
I've seen talk about but that hasn't worked for me.
Ideas ?
You should put your static configuration files in resources/ dir. If you have your own or proprietary jars you should set a your own repository so you can download them from the repository or better yet just install them manually , here is how
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Setting up a file-based repository as suggested in this previous question would allow to keep the libs in your version control system and work seamlessly at the Eclipse level (the libs would be treated like any other dependency). The only problem I can think of could be at the continuous integration level: a build of projectA would require a checkout of trunk/lib. Many CI tools would allow to implement this though. And if not, moving the libs under projectA (or another mavenized project project if you need to share them between modules) would do the trick.

How do I make Eclipse automatically include jars I place in my WEB-INF/lib folder into my project?

When I was doing JSP/Servlet programming, whenever I dropped 3rd party libraries into the WEB-INF/lib folder, they were automatically included in the project classpath. In GWT, this is not the case. Anyone know why? I loved how easy this was in JSP and I'd like these jars to be included automatically the same way.
If you are using the Google Plugin for Eclipse then my understanding is that a Google Web Application Project is just not the same animal than a Dynamic Web Project and thus behave differently. So if your project depends on libraries not provided by the GWT and App Engine SDKs, you'll need to put them in war/WEB-INF/lib and to add them explicitly to your Java build path.
In Eclipse Galileo, right click the web project and select build path then select the Java EE Module Dependencies and add the jars.
There is a plug-in technique that may help you if you want a directory where new jars are automatically updated in your build path, see this other post:
Eclipse buildpath automatically taking all JARs of a internal directory
The reason it works like this for your JSP's is because that is how the Dynamic Web Project was made to behave.
"If you remove a library path entry but not the JAR file, the library entry will be re-added to the path automatically." from http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.wst.webtools.doc.user/topics/ccwebprj.html
You could adopt Maven and use the Maven Eclipse Plugin; this plugin would update your classpath whenever you add a dependency. There may be a similar plugin for Ivy.

How to get Netbeans 6.5 shareable libraries working

I created a Web application in Netbeans 6.5. Now I want to use the Joda Time library. I want to share this library via subversion, because I don't want my team mates to be dependend on some Netbeans configuration.
Just to get the project working, I first added the library to the Netbeans library (Tools->Library). This worked OK. The JAR is added to the classpath, and is also deployed.
But when I create a shared library (via Project Properties->Libraries->Browse/New Libraries Folder), the JAR is not in the classpath. I get the error message package org.joda.time does not exist on the code import org.joda.time.*.
Any ideas?
What is the scope of this library? Is this library used for just this particular web-application?
If so, can we put the library in the WEB-INF/lib directory and check that into subversion as well?
Libraries in the WEB-INF/lib directory should be automatically added to the classpath of the project.
Here is what I did:
Tools -> Library -> New Library...
called the library joda-time
add added the joda-time-1.6.jar file to it
Project -> Properties -> Libraries
under the compile tab
Add library...
selected joda-time
(Edit, think I see the issue now - but perhaps not).
You need to add the library to the compile libraries AND add it to the distribution libraries. Or am I misunderstanding the question?
when creating a 'new project', there is an option to enable 'dedicated folder for libraries'. That way, the libraries will also be committed to the repository and your peer developer can checkout your project with all the libraries, your project has dependencies upon, thereby eliminating netbeans configuration bound.
In scenario where a project depends on JARs which can be placed in different locations for different users, a named IDE variable can be used.
http://wiki.netbeans.org/NewAndNoteWorthyNB65#section-NewAndNoteWorthyNB65-VariableBasedPathsInJ2SEJ2EEProjects
Another option would be to use the Maven plugin which already works quite well in NetBeans 6.5. A Intranet repository for the Artifact Jar files could be placed on a file server, or managed through a Maven Proxy like Nexus.
This blog entry describes a hack that worked in NetBeans 5. I don't know if it will work in NetBeans 6.5. I also don't know if this will work if you are building files nightly on a server.
http://blogs.oracle.com/gjmurphy/entry/using_netbeans_free-form_projects_as
I remember setting up shared libraries like this 8 years ago in JBuilder. I wish Netbeans had it by now.

Categories