Is there a direct way to get a full ejb/servlet application example for glassfish - servlets

I have an application that is currently running on JBoss AS but does not work on Glassfish. I'm trying to work through the documentation here but I'm having trouble figuring out things like what the file structure of the application should be and what (if any) additional files are needed. This documentation also refers to examples but to get the examples you need to install Netbeans and access an update tool tied to the glassfish instance installed with Netbeans. When I do this the server won't start, the update tool won't run, and I can't get the examples. Is there an easy way to get these examples (e.g. a simple download)? I've found other examples such as this one, but they are also dependent upon Netbeans.
Is there a simple and complete ejb/servlet example for Glassfish that can be simply downloaded and does not depend upon Netbeans or other IDE?

The obvious example is the Java EE CargoTracker. It was written to show what a "real" application might look like with pure Java EE APIs so should work on both JBoss and GlassFish. You will need Maven installed to build and run it, but there are more complete details in the readme for the project. Note that some of the information is a little out of date (mostly links to java.net which has been sunset in favour of a GitHub site) but the application itself is still a good example of Java EE 7 APIs.
https://github.com/javaee/cargotracker

I found the examples on github here:
https://github.com/javaee/glassfish-samples
To get and build the examples you will need Git and Maven. These examples are small, complete, and concise. The example that was helpful for my particular problem was this example:
glassfish-samples\ws\javaee5\enterprise\servlet-stateless-ear
It demonstrated that I needed to change the structure of my project such that the servlet was in a .war file and not in a .jar file in the lib folder of my project.

Related

Unable to create a JavaFX project in Netbeans IDE 16 [duplicate]

I've been banging my head on this one for ages and all of the tutorials I've found don't seem to work. When I try to create a new JavaFX project in Netbeans 14, using JDK 18 and the latest JFX download for Windows here:
https://gluonhq.com/products/javafx/
Also tried with JDK and JFX 17 and still no luck. I get this error:
I've added the libraries like so:
If I try to add the platform folder, it won't let me progress through the dialogue:
I can't find solutions to this anywhere and, again this is the same with JDK 17 and 18, and JFX 17 and 18. I've checked the documentation and there's nothing that seems to solve the issue.
It says to go to the JavaFX tab and enable JavaFX, but there's no JavaFX tab... Unless they mean this:
But if that's it then, as you can see, it's already enabled and it's still not working. I'm totally lost. I don't understand why the documentation is so poor for FX, for every IDE. It's honestly like they don't want people to use it and every tutorial I'm finding is using outdated versions of NetBeans, the JDK and JFX D-: (they also don't solve the issue even if I do follow them).
If anyone could help guide me, I'd really appreciate it.
I would suggest you go to New Project -> Java with Maven -> either Simple JavaFX Maven Archetype(Gluon) or FXML JavaFX Maven Archetype(Gluon). Use the POM to change your version of JavaFX from the default to whatever version you like. I also use the POM to change the JavaFX-Maven-Plugin to the latest version.
I strongly endorse the approach using maven suggested here. This project started exactly the same way; I'd welcome learning of any issues you encounter.
Alternatively, follow the steps outlined in JavaFX and NetBeans: Non-modular projects: IDE. You've created a JavaFX library, but "Don't try to create a JavaFX project." Instead, choose Java with Ant and Java Application to create a new project, shown below, then follow the remaining steps carefully. It's a convenient alternative for a scratch project while you assay maven.
Addendum: The ant code for a JavaFX project, not selected in the image above, may attempt to package dependencies that are no longer required. In particular, a project using module javafx.web may fail with the following error, seen here and here. The easiest fix is to recreate the Java application by choosing Java Project with Existing Sources.
Unable to create javax script engine for javascript.
Alternatively, a simple example using a custom ant script is cited here.

Stuck with creating Keyword library using Java in Eclipse and using that JAR file in RIDE

I'm new to ROBOT framework and must create library keyword using java and utilize the JAR files in RIDE editor. I have followed the below steps. But still have confusions in where to start up. Please help me to achieve this.
Steps:
1) Installed Python, wxPython, pybot, RIDE, selenium2library successfully and I'm able to work with RIDE using predefined keywords.
2) For creating own java library, Installed Eclipse Mars, Java, ROBOT IDE manually using the link https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Installation
The question here is,
Anything i'm missing to install?
How to proceed further with Robot Framework coding?
Note: I'm reading many materials in parts to proceed things. But that is confusing me what are the steps to be followed. Is there any single material that i can get having the sequences of steps that need to be followed for my requirements?
The below links I referred with,
https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Usage
Maven error "Failure to transfer..."
Create a Maven project in Eclipse complains "Could not resolve archetype"
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-set-test-suite-global-variable-keywords
Let's start with the basics. RIDE is an editor for Robot Script files. Robot Script files are executed by the Robot Framework robot application. It is important to understand the difference between these two applications. One creates files and the other uses them.
Assuming for a moment here that you have some custom functionality in a Jar file that you would like to make available inside the Robot Script files test cases. If this is indeed the case then your focus should be on create Robot Test Libraries. In the documentation there are numerous java examples given for basing your own library on.
This means that you do not need Maven, unless you want to, to create your library. Also Eclipse IDE is not needed nor is RIDE. The library you create can be used by Robot Framework even when it's run from the command line. Feel free to use them for what they are good at: writing Robot Scripts efficiently and running Robot through menu options instead of command line windows.
When you are familiar with Eclipse and comfortable with it's features, then I can also recommend using the Eclipse Application RED which is a mature Eclipse add on for creating, running and debugging Robot scripts.
There are two ways of implementing a Java routine in Robot Framework and it depends a bit on how you run Robot Framework: Python or Jython. Running Python means that you need to run the Java in a separate JVM container and connect to it. The simplest way is via Command Line interaction. This may cause some security concerns. The second approach is to use the Remote Library approach. A good example of this is the Robot Framework Sikuli Library. An added bonus is that you can run Robot and your Java application on two separate machines/servers.
The Jython way has been discussed on StackOverflow before and I gladly refer to it. Please bear in mind that although the examples refer to RIDE, the Library org.company.Keywordlibrary works in all IDE's, provided robot framework is run using Jython.
In the Jython documentation it clearly explains how to setup an Eclipse based IDE with Jython. Do keep in mind that it's recommended to use the same interpreter in development and production. I.e. if you create your scripts in Jython, do run them in 'production' also using Jython. Otherwise you open yourself up to interpreter differences where functionality does not work or behaves differently then expected.
An alternative approach with Jython is the all-in-one Robot Framework Maven JAR plugin. Adding a custom Java Library in this setup is not too difficult. A nice short tutorial can be found on the blog of Valerio Bruno. If this is your preferred route for development, then you may want to read the RED howto on integrating the Robot Framework Maven jar.
Working on your custom functionality is likely going to be a independent project in Eclipse, but can be linked to an Robot project via the Class Path settings in red.xml if you use RED or the CLASS_PATH environment variable.
Done! I have installed RED and required add on using following below steps. It worked successfully with predefined keywords. Now I'm gonna create user defined keywords/libraries using the same editor. I don't know where to start up. Will it work creating just a java project? Should I need to include any additional libraries?
Steps followed to proceed with RED:
1. RED Version Conclusion: https://github.com/nokia/RED/blob/master/release.md
2. RED Installation Instructions: https://github.com/nokia/RED/blob/master/installation.md
3. ROBOT Framework prerequisites using RED: https://github.com/nokia/RED/blob/master/red_help/first_steps/download_install.html.md
4. To verify Installations in Eclipse: Help -> Installation Details to check if RED is visible on installed features list
5. Create Project and Tests using RED in Eclipse: https://github.com/nokia/RED/blob/master/red_help/first_steps/create_run.html.md
6. RED Steps: https://github.com/nokia/RED/blob/master/First_steps.md
7. Quick STart: https://github.com/nokia/RED/blob/master/red_help/user_guide/quick_start.html.md

Adobe CQ5 Setup in production

I am not a CQ guy. I have to use CQ5 for one of my project. I have a CAT and a production environment. I have following doubts-
I want to use author instance of my CAT only. Once I publish the content in CAT it should publish in Production also. Is it possible ?
Once I update the build of AdobeCQ in my production say new build, code changes etc- will my content be lost ?
I read somewhere about Content package in cq5. Can I separate content changes and code changes in one CQ5 environment ?
Thanks in advance.
To answer question 1...
This is not a recommended setup, but a common misconception for someone unfamiliar with AEM/CQ5. The "author" and "publish" instances should be part of the same environment. For example you should have a production author, probably behind your firewall, and production publish to serve pages to the public.
Your CAT environment should have the same thing. You want your testing environment to match as closely as possible to your production environment, including web server and dispatcher setup, to ensure quality.
Consider this. You can use one production publish instance, but it's a single point of failure. It's a general best practice to load balance across at least two. Two is sufficient for most websites. If you do this, you'd want to mimic the architecture in CAT.
To answer question 2...
If your code is written, built, and deployed correctly, it should not delete your content. Just make sure you are never deploying anything to /content (to avoid deleting content) and to /libs and most of /etc to avoid overriding platform functionality. AEM/CQ5 is a very open product, so you can do very bad things. But, if you know what not to do you are safe.
Code deployments should typically be done as part of a CRX Content Package, which brings me to...
To answer question 3...
The way we build and deploy code is to have Maven compile the Java, package everything up in a CRX Package, then deploy to the instance using the Package Manager REST API. Adobe provides a Maven Archetype that will facilitate this.
A CRX Package is a file system representation of your content repository, wrapped in what is effectively an annotated Zip file. Your compiled Java code is included in that file system representation, in a folder (to become node) named "config". That compiled Java is an OSGi bundle, which is an annotated JAR. When CRX Package Manager deploys all those nodes to the system, OSGi accepts the bundle, assuming it's valid. This is why you can do "hot" deployments of live, production AEM/CQ5 instances, with very little risk.
So...
This is a very high level answer to some very big topics. I encourage you to do a lot more research before you set this up. There are many good blog posts and documentation pages out there to help you get this set up according to best practice. Good luck!

Jar to include to use javax.annotation.*

I'm a bit confused. I need to compile a project in jDeveloper 11.1.1.6.0. The server side of the project is deployed on the Glassfish server. On the machine of the project's creator everything compiles without any problems.
Using project properties -> Libraries and Classpath I added the libraries such as gf-client.jar, security etc. from $glassfish_home/glassfish/modules and some others (e.g. hibernate3.jar from hibernate dir).
When I try to compile the project I receive the following errors:
package javax.annotation.security does not exist
and
package javax.persistence does not exist.
I suppose that I miss some jars to include. I tried to find which jars (from Glassfish or from JDK) contain javax.annotation.* and javax.persistence.* but I couldn't.
If you have any ideas I would be thankful!
I was having the same problem and was able to solve it by adding a couple of dependencies to the Maven pom.xml file. See this answer for more details.
So I found the source of the problem. The application consists of 2 projects, of which only one (mentioned in the question) uses EJB. I'm not sure if it is the way it should be, but I tried adding ejb-files to another project. And after clean all and rebuild all it compiled like a charm for me. I hope this will help somebody in the future.

Flex Mojo Maven Compile Question

I am trying to get the flex mojos maven compiler to run my projects.
Anyone with feedback on the below information is appreciated.
I am using this configuration for the maven compiler plugin and for
some reason every time I run the clean install on my SWF project I
still see the following in the compile step for the app.
info.rvin.mojo
flex-compiler-mojo
true
true
-compiler.accessible=false
-compiler.actionscript-file-encoding UTF-8
-compiler.allow-source-path-overlap=false
-compiler.as3=true
-compiler.debug=false
That means I can not connect to my app via the Flex Builder's debug
tool. Any thoughts on how I should properly configure the plugin in
the pom.xml?
Thanks!
adam, we're just starting to build out the chapter on flexmojos in Maven: The Definitive Guide. For starters, use the new plugin groupId, artifactId that is listed in that chapter. velo moved the flexmojos project over to the Sonatype Forge a few months ago, and we're just getting the 3.0 release out.
To anyone out there reading this: remember Maven is a build tool; it only (typically) executes (parts of) your code as a consequence of executing the tests you've implemented.

Resources