Using Maven dependencies in JDeveloper 12c - jsf

I'd like to know how I can use a dependency provided by Maven in JDeveloper.
For example: I define a dependency in my pom.xml for primefaces UI components.
Why I can't use it in JDeveloper?
In the components window there are no primefaces components!
The WAR project is build properly with jars in WEB-INF/lib.

Adding those kind of dependencies is not IDE depentend. It rather depends on the project type, in this case you should use a Maven Project. It has it's own structure organization. So the first option would be to create such a project (JDev does even have an include option for maven projects).
Nevertheless JDev 12C has it's own support mechanism, but you need to do some little configuration into your project. Here you have a good tutorial explaining it: Introducing Maven Support in JDev 12C

Related

Upgrading Liferay 6.2 maven plugins into Liferay 7 module

There are many sites which provides articles for upgrading liferay 6.2 to dxp but only for ant project. How can we upgrade liferay 6.2 maven project to liferay dxp gradle project ?
The strategy to upgrade your code is exactly the same. Liferay's Plugins SDK defaulted to Ant until 6.2, now you have the choice between liferay-workspace (gradle based), gradle and maven - just choose the build environment you'd like (sounds like you'd like to continue with maven) and add your code to an empty blueprint for the project of your choice.
There's an upgrade tool in Liferay IDE that might help you - even if it doesn't use the build tool of your choice or if eclipse isn't the IDE of your choice: The upgrade tool is a one-off tool to use during upgrade. No matter what the result is on: You can always check (for example) Liferay's blade-sample project to find the proper build descriptors for Maven - and adapt them to your project.
Edit: After the clarification: Your main task is still the upgrade of the code. As of moving from Maven to gradle: Identify the dependencies and translate from pom.xml syntax to gradle's declaration - the contents are similar (e.g. group, name, version), only how you're writing them down is different. If you have made elaborate custom modifications to your pom.xml try to go without them first. You can start with a stock build.gradle (e.g. from blade-samples that most closely match your project) and then fix compile-time dependencies as you go.
I'm not aware of an automated process that does this translation for you (and most likely you'd bump up a few version numbers in the process anyway)

Netbeans cannot find the CDI package javax.enterprise.context.*

I am creating a simple JSF application with one of my university colleagues, and I am having some trouble when I pull down the application from our repository. When I import the project into NetBeans IDE 8.0.1, the program does not compile correctly on the following CDI based annotation:
#Named
#RequestScoped
public class LoginController implements Serializable {...
It is informing me that it cannot find the following package:
import javax.enterprise.context.*;
Initially I had thought that I did not have the EJB and EAR plugin installed, however I have installed the Java EE bundle which I downloaded from the netbeans website. Are there any other JAR's, which I may be possibly missing, causing this specific error.
On my colleagues local machine everything works as expected without any issues at all, so I am left unclear why this is not happening on my computer.
yeah it seem this netbeans version lacking javax.enterprise package. Here is the solution
1) If you are using maven project, add javax.enterprise(cdi-api.jar) as dependency
2) For other projects, download cdi-api.jar, add this as external jar from project properties, it will enable CDI.
Yes you need to include another library. You are using the part that belongs to Java EE. By default java includes Java SE. So you need to add this library in your project.
Go to
Project Properties -> Libraries -> Add Library -> Java EE Web 7 Api Library
I had this problem too. The glassfish library structure has changed somewhat so instead of using the "Java EE from Glassfish" library we used the "Java EE from API" library and that fixed it.
Both proposed solutions are valid but the simplest one is the second one because you've got already everything needed in NetBeans 8.0.
Your problem is clearly the consequence of the default Java EE bundle (version 7) present in GlassFish 4.1. Of course, it is a NetBeans bug. Netbeans should have added the needed library to your project when you chose to work with Java EE 6.

jdk1.7's javac can't find javafx jar without -cp option

I've read several questions on this site and elsewhere that indicate that when Oracle JDK7 is installed, it should not be necessary to specify the classpath to jfxrt.jar when the JDK is installed correctly. Unfortunately, my installation does not seem to be correct, but I cannot figure out what is wrong.
I used the correct RPM for my Red Hat Enterprise Linux 6.2 Server and I'm able to build JavaFX apps in Eclipse when I added the jfxrt.jar to the External Jars. But when trying to compile and run from the command line, it does not find JavaFX classes unless I specify the -cp option to javac and java. The server was originally using openjdk-1.6, but I used alternatives to configure javac and java to point to the newly installed JDK. It looks like that is working fine, except for this issue.
I found that the same problem plagued me when trying to run the JavaFX Exporter. I was trying to export a project that runs fine in Eclipse. But it could not find the JavaFX classes when trying to run. And I haven't worked out how to tell the exporter where the jfxrt.jar file is located.
For reference, the jfxrt.jar is located at /usr/java/jdk1.7.0_21/jre/lib/jfxtr.jar on my system.
when Oracle JDK7 is installed, it should not be necessary to specify the classpath to jfxrt.jar when the JDK is installed correctly.
That is not true.
If you want to compile and run a JavaFX application in Java 7 (u21) and you are not using the JavaFX packaging tools, you need to add jfxrt.jar to your classpath.
See Compile code using JavaFX 2.0 (using command line) for samples of setting the JavaFX classpath for compiling (with javac) and running (with java) a JavaFX 2 application from the command line.
Some IDEs or IDE extensions are aware of this and will automatically add jfxrt.jar to your classpath (e.g. the e(fx)clipse plugin or the NetBeans JavaFX project type).
Some 3rd party tools such as the JavaFX Maven Plugin or the JavaFX Gradle Plugin also package JavaFX applications so that you don't need to add jfxrt.jar to your classpath.
For Eclipse development, use of the e(fx)clipse plugin is recommended, as it takes care of classpath issues (as well as providing other useful capabilities for JavaFX developers).
For Java 8, jfxrt.jar is on the default classpath, so you don't need to explicitly set your classpath to use JavaFX with tools like javac.exe or java.exe for that Java version.
OpenJdk7 does not include jfxrt.jar. Use Oracle Jdk7 instead will help.

Adding libraries to app from JBoss 7.1.1 modules

I'm using Intellij Idea 12 and the JBoss 7.1.1 app server. Do I need to add the javaee6 jar to my application library in order to deploy it?
Or, can I just add the libraries that contain implementations of Java EE technologies, such as Faces, EJB, the Java EE jar file itself and so on from the modules in JBoss AS 7.1.1?
What if, for example, I want to add JSF libraries to my app library from the modules in JBoss 7.1.1? How can I do that?
And what is situation with Maven? How are the dependencies resolved in that case?
JBoss is a Java EE 6 compliant application server, meaning that it has all the implementations of the Java EE standard on board already, These libraries are avaliabel to applications at runtime, so there is no need to add any additional libraries to use all Java EE 6 features.
If you are using maven, simply reference the libraries to be used at runtime ('provided' scope) like this
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
If you are not sure where to start, try one or several projects from the JBoss quickstarts. There is at least one for each major Java EE technology and some examples that put those technologies together.
EDIT: It seems that the real question here is how to add Java EE libs to your poroject, It depends on the build system. If you are using maven, and I would advise you to, pick a quickstart from the list - the kitchesink is a good example and take a look at the pom.xml. It is not a good idea to add an implementation of a Java EE standard to your project other than the ones provided by the application server. This might cause problems on deployment or at runtime.

Maven workspace resolution missing jars for local Tomcat testing

I have a mavenized project with dependencies upon 4 others mavenized projects that my team is currently working on. We have "workspace resolution" enabled.
If I publish to Tomcat, jars are not available for the 4 projects so I see all sorts of NoClassDefFoundError exceptions.
I don't see any problems with JUnit testing or packaging. (I run the package goal and the resulting war file includes the SNAPSHOT jars that I expect.)
I see a lot of people advocating for using workspace resolution, but if we need to test in Tomcat should we disable this? Or what else might I be missing?
We use Eclipse Helios, the m2eclipse plugin, Maven 3.0.3. I even installed m2extras to see if that helped, but I didn't see any difference.
Thanks
You can get this setup to work (we have been working with the same toolchain and setup here) if you can live with some manual refreshes, after you have been using m2eclipse goals to build.
The problem is, that not all external changes via m2eclipse builds to workspace projects are synched correctly to your deployed web application in tomcat.
So if you are experiencing NoClassDefFoundError exceptions after building via m2eclipse the following should help (not all are necessary everytime):
Do a Project/Clean on your maven projects
Do a Refresh (F5) on your maven projects
Clean the deployed web application (Server Context menu)
Yes, it is cumbersome but one can live with it.
Remove the dependency project from the workspace.
Delete .settings directory and .project files.
Import the project again.
Update maven dependencies in all projects.

Resources