EJB calls from grails to glassfish - grails

I need to use EJB remote calls from my grails application. For this in previouse Servlet application I used client glassfish jar(gf-client.jar) and is's worked.
How I can include gf-client.jar into build path in grails app for call EJB methodth?
thank you.

the answer was to copy all libraries of GlassFish application server to client mashine (directory with gf-client.jar and 2 levels up, check dependencies in gf-client.jar) and add only gf-client.jar to classpath of application. Ather dependencies will loaded automatically, when gf-client will loaded.
note 1: in my case for grails application witch I deploying to tomcat servlet container write full path to gf-client.jar to shared.loader section of catalina.properties file in conf dir, and restart tomcat.
note 2: for GlassFish v3.1 and up, replace gf-client.jar with gf-client-module.jar

Put gf-client.jar into the lib directory of your grails app. Any jar files in the lib directory of your grails app will automatically be included when you run your application as well as be packaged in generated war files.

Related

Common Facelets files in shared library JAR outside /WEB-INF/lib

I have a common shared Library (that is setup as a Shared Library in Websphere Application server).
The folder structure of that jar is:
UtilityJAR
----src
-com
-test
-TestClass.java
---- META-INF
-resources
-template.xhtml
-css
-style.css
In my web Project, I have a template client file called User.xhtml that uses the template file from the above Shared Library using
ui:composition template="/template.xhtml"
When I have the above jar file in the WEB-INF/lib folder of the Web application, the application works fine without any issues (template.xhtml is recognized). When I remove the jar from the Lib folder of this application and put it as a Shared Library in Websphere (because I need this jar file from more than 4 applications and I don't want to copy this jar in all the 4 applications), I get the following error message.
[9/24/14 14:09:17:936 EDT] 00000113 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: java.io.FileNotFoundException: /template.xhtml Not Found in ExternalContext as a Resource
The Utility jar has faces-config in it and has #ManagedBean annotations that work when the jar is inside the application's WEB-INF/lib folder.
Anybody faced this problem before? thanks for your help.
Web fragment JARs containing webapp resources MUST be placed in webapp's /WEB-INF/lib.
From Servlet 3.0 specification page 37 (emphasis mine):
4.6 Resources
...
The getResource and getResourceAsStream methods take a String with a leading
“/” as an argument that gives the path of the resource relative to the root of the
context or relative to the META-INF/resources directory of a JAR file inside the
web application’s WEB-INF/lib directory. These methods will first search the root
of the web application context for the requested resource before looking at any of the
JAR files in the WEB-INF/lib directory. The order in which the JAR files in the
WEB-INF/lib directory are scanned is undefined. This hierarchy of documents may
exist in the server’s file system, in a Web application archive file, on a remote server,
or at some other location.
...
If you really want to place them elsewhere (bad idea!), then you'd need to homegrow a custom Facelets resource resolver. You can find a kickoff example here: How to create a modular JSF 2.0 application?
See also:
JSF facelets template packaging

creating a config file in grails

I am attempting to get a Grails project working but need help setting it up. I have an Ubuntu server running on a VM that has Redis installed. The project won't run unless I create a config file that can use Redis on the Ubuntu server. This is the settings I pulled down from GitHub located in the grails-app/conf/Config.groovy file.
http://snag.gy/eYhUY.jpg
I was told I need to create a separate config file that will override these parameters so my project will talk to the ubuntu server on my machine. This is a noob question but where do I create a config file? I can't seem to find a .grails folder. I know I'm suppose to reference my config file, once i've created one, in the grails-app/conf/Config.groovy file
http://snag.gy/SpGGt.jpg
Look at the grails.config.locations specified in your Config.grooy and you can create any of those locations for creating the external Config file.
I prefer using the classpath route. Here is what I would do.
Create a folder (say appConfig) and place it in the tomcat/conf folder.
Add the application config file (proghorn-config.groovy in your case) to the folder, with the required configurations in the file.
Add the folder to the Tomcat classpath by updating either the tomcat/conf/catalina.properties or by creating the tomcat/bin/setenv.sh
The location of the .grails folder depends upon the user account running the container (Tomcat, Jetty, etc.) which hosts your Grails application.
For example on Debian 6 running Tomcat 6.x the location is:
/usr/share/tomcat6/.grails/
You can also use static paths as well:
file:/usr/local/tomcat/conf/myspecific-config.groovy

Grails war deployement on WSAS

I generate a war using grails war, but when I deploy it to Websphere I have errors, what features I need to add so I can run my war under WSAS, here are the errors → http://paste.ubuntu.com/6179593/
Note: The web page show me this error → Context Root Not Found
According log there is no problem and application has started successfully.
Check your Virtual Hosts settings.
There is good article about grails application deployment.

how to access grails application on Tomcat

I'm trying to deploy a simple grails application on my test-server which is tomcat. I've built the WAR with grails war command so I've got a war file named: simplgrailsapp-0.1.war
When I deploy this to tomcat I'm getting a lot of errors which I'm going to resolve one-by-one. But the URL for the app from tomcat manager (mytestserver:8080/manager) is http://mytestserver:8080/simplegrailsapp-0.1/ which doesn't seem correct. Because when I run the app locally the url is: localhost:8080/simplegrailsapp
I've also tried to access the app by http://mytestserver:8080/simplegrailsapp but that doesn't work either.
How can I fix this?
By default, when you deploy a WAR to tomcat it will fall under the context of the name of the WAR file. So in your case, the context becomes simplegrailsapp-0.1. You can:
rename your war file to whatever you want the context to be before you deploy it
define a Context for the application in Tomcat
If you go with defining a context this can be added to the WAR file by creating a META-INF folder in the web-app folder of your project and creating the context.xml file there.

How create an executable file or an set up file of an Java web application

I would like to know how to create an set up file or an executable file of a java web application in which I have used Struts and jsp for development in net beans 7.1.2 IDE. So please Help me.
You need stuts plugins (something like that struts2 plugin for netbeans)
and you can find many examples how to create web app with struts for example this
example 1
example 2
Download excelsior and run your Java EE web project as example.exe file
http://www.excelsior-usa.com/

Resources