I'm trying to implement SSO for a web project that will be deployed on Weblogic. In the examples that I found the user identity is retrieved using weblogic's inner classes e.g. :
import weblogic.security.Security;
...
Subject subject = Security.getCurrentSubject();
I believe a jar containing this "weblogic.security.Security" is in weblogic's classpath, but how am I supposed to compile the project? This dependency is not available from maven so there's no way to mark it as "provided".
Is there a common solution to this problem or I should get this jar from the weblogic directory and add it to the project's classpath?
Thanks
You will have to get the jar, add it to your local maven repository (or your organisation one, generally nexus or artifactory) and set the scope as provided.
See http://docs.oracle.com/cd/E21764_01/web.1111/e13702/maven_deployer.htm for an example on how to deploy your jar in your local maven repo.
Related
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.
I am using Tomcat server and I've got multiple versions of a product that is built on Maven, they are using almost same library.
How can I centralize the library of all versions in one place, when I do
not want to place that library in the Tomcat 'lib' folder?
Maven itself has a concept of centralized repository. Use can specify the location of centralized repository in settings.xml file of maven.
I have a java web application which is deployed on several servers. The project uses maven dependency management tool.
The war file that is created after including all the dependencies is quite large. If I use scope "provided" for all dependencies, the war fail created is quite small. I want to use the latter war file for deployment and manage dependencies on the remote servers itself.
I can add a folder containing those dependencies to all the servers and include it in the tomcat class path but if in future I add another dependency I will have to add that dependency to all the servers. Please suggest a workaround.
I'm working on a Java Web-related project. At this moment, I try to combine some frameworks all together (Hibernate ORM, Apache Shiro). Of course, in the nearest future, I might need some add-ons via maven dependencies. Is it possible to pack it all together, thus for an emergency case also to pack maven? Due to policy restrictions, there is no chance to install the necessary development tools to make it work.
Is it possible to import maven into WEB - project as JAR?
It seems like you want to just keep your entire project directory if I'm understanding you correctly.
Are you sure that they cannot install Maven? If so then you'd want to package maven with the project.
Could you give me more details about the environment you'd be using?
You could easily import the jar into the maven web project. Under the modules section the web projects pom.xml just specify the directory if it is in the same project. If not, you'll have to add it as a dependency. You'll need the group and artifact ID of the jar you want to add. You can find some pointers here.
An example for the project directory structure:
<modules>
<module>the web part</module>
<module>the backed part</module>
</modules>
Each different module would be a sub module of a master project.
This should help you with setting up the classpath. Also take a look # this:
http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them
I have a pretty basic Java web application (created using Eclipse openshift plugin). The app runs fine on the OpenShift server. Now I need to use an external JAR library for JSON parsing and creation in Java. I can't understand my way around how to add that JAR to openshift server.
I went to project properties>>BuildPath>>Add external JAR. While that does import the JAR, it does not work on openshift server and gives error relating to that file's import (NoClassDefFound, I guess). Could you tell me how to import external jars into openshift project?
Since we use Maven for the build process, all you have to do is add it as a dependency in your pom.xml
Here is an example that adds a mongo driver
https://github.com/thesteve0/openshift-mongo-spatial-jee6/blob/master/pom.xml
Look under the dependencies tag
You can add the jar as a dependency in your pom.xml file. This will cause the jar to be included in your war. If the jar is not available in a public maven repo, please see here: http://www.billdecoste.net/?p=16
[Updates in 2017]
You might want to take a look at this link from OpenShift itself.
It includes information about adding jars with and without maven dependencies.