We've been using Dynamic Reports directly in our Grails 1.3.7 app with great success. However, when we upgraded to Grails 2.2.4, the images are broken in the HTML view. The hyperlink generated leads to a 404, even for static content such as logos. All the other reports work fine. I am thinking the maybe the image factory servlet needs to be registered in web.xml or something like that. Does anyone have any pointers?
I recommend you to create a new application and to use a visual diff software like meld in order to compare your project directory vs the new application directory. You can find that common files like BuildConfig.groovy or Config.groovy could to need massive corrections. There are another files that you should to review after the migration.
Here is the solution. (Thanks to Ricardo over at DynamicReports help forum!)
The image servlet must indeed be registered in /src/templates/war/web.xml configuration. We did not have to do this in Grails 1.3.7. Hope this helps someone else!
<servlet>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageServlet</servlet-name>
<url-pattern>/image</url-pattern>
</servlet-mapping>
Related
I'm using Vaadin 7.4.3, tomcat 8. During the wizard to create Vaadin 7 project in eclipse, it has a checkbox called "Generate web.xml deployment descriptor".
The new way is to use annotation instead of specify it in the web.xml. Are there any configurations that I have to use web.xml because there's no annotation for it? Is it a good practice to always generate the web.xml even if you might not use it for Vaadin 7.1 projects and up?
Thanks
Yes, there are for sure some aspects of app that cannot be configured using annotations (i.e. there is no annotation to state that you want to have your session cookies "http-only" ).
I would recommend you to create web.xml file when it is needed. Sooner or later it would probably will be used, but don't worry too much in advance. It is not a dark magic to create web.xml file in existing project :)
I want to add a node into web.xml.
I tried to use a webxml grails plugin, but look like it can't manage nodes. Any help or example will be apreciated...
You can use your own web.xml, with any content you want. Run
> grails install-templates
and edit /src/templates/war/web.xml file (it's a template, so don't remove existing Grails code)
See http://grails.org/doc/latest/ref/Command%20Line/install-templates.html
I'm not able to add comments yet, so here it goes.
By looking at your last comment, I suppose that you were looking for grails:exec:
mvn grails:exec -Dcommand=install-templates
Many Grails commands don't have the equivalent wrapper exposed directly through Maven.
I have a plugin with domain, controller and view pages. (Using grails 1.3.6)
I run the plugin as standalone, the views work fine. URL: http://localhost:8080/sample-plugin/gp/list. I am able to view the list page.
I installed the plugin into a main application i.e. plugin-test. Start as run-app within STS and browse to http://localhost:8080/plugin-test/gp/list. I am able to view the list page.
I bundle the application as war i.e. plugin-test.war and deploy to tomcat. When I browse to http://localhost:8181/plugin-test/gp/list I get a 404 error! I am not sure what I am doing wrong.
I have been trying to resolve it for quite sometime now and still no luck. The same main application works fine in STS but not in tomcat.
HTTP Status 404 - /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
type Status report
message /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
description The requested resource (/plugin-test/WEB-INF/grails-app/views/gp/list.jsp) is not available.
Please help.
Thank you.
Jay Chandran.
This sounds worryingly familiar, as I spent a while figuring out this (or a very similar) issue. I ended up raising this Grails bug report:
Plugin layout not found in war when installed from BuildConfig.groovy
Have you installed the plugin as using the new BuidConfig dependency technique? The JIRA documents my workaround.
Sharing some of my lessons learned after experiencing the same exact issue (1.3.7):
Double check your HTML source to make sure that your template really isn't being included. Mine was being included, but my CSS/image URLs were wrong (only while running as a war)...so I wrongly assumed that my template wasn't there.
Don't use the ui performance tags for referencing your static content...doesn't appear to work, even if the plugin attribute is specified.
Don't name your layout main.gsp. You're guaranteed to have conflicts.
Don't use absolute=true on your g:resource tags. This doesn't appear to append the pluginContextPath to the absolute url, even if you specify dir="${pluginContextPath}"
Don't use pluginContextPath, as it's no longer required: http://grails.org/doc/latest/guide/single.html#6.3%20Tag%20Libraries (search "Plugin Paths")
In your g:resource tags in your plugin layout, make sure you specify the plugin attribute. Set it to the name of your plugin.
Move your static images/css from your plugin to a web server. If each application using your plugin has its own copy, your users aren't going to benefit from caching when bouncing between apps.
Note that all of the above applies to the layout gsp in your plugin project, not your consuming application.
Please help with this issue, I'm going mad...
I'm trying to make a client-server web application using Weblogic 10 as an application server and IIS as a webserver (corporate constraints), with EJB 3 and Struts 2. I am however having strage problems which I cannot solve.
Using Struts 2.2 I get the following stack trace while starting the server:
<12-ott-2010 16.02.21 CEST> <Error> <HTTP> <BEA-101165> <Could not load user def
ined filter in web.xml: org.apache.struts2.dispatcher.FilterDispatcher.
java.lang.reflect.InvocationTargetException - Class: com.opensymphony.xwork2.inj
ect.ContainerImpl$MethodInjector
File: ContainerImpl.java
Method: inject
Line: 295 - com/opensymphony/xwork2/inject/ContainerImpl.java:295:-1
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.
java:190)
at weblogic.servlet.internal.FilterManager$FilterInitAction.run(FilterMa
nager.java:320)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
Truncated. see log file for complete stacktrace
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[...]
java.lang.IllegalArgumentException: Javassist library is missing in classpath! P
lease add missed dependency!
at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:165)
[...]
However, the Javassist package is clearly visible in the web classpath (/WEB-INF/lib direcotry) among all the other Struts-related libraries, I can also browse its packages and classes. I also put it in the CLASSPATH library and in Weblogic initializaion parameters but nothing works. I don't know what to think. Is this a Struts 2/Weblogic integration bug?
Even weirder is the fact that initially I managed to make Struts 2 work. Then for some reason (I don't really know what for) it stopped and I can't get rid of that error.
Thanks for your help.
Often solutions come when all hope is lost. Apparently all I had to do was moving all Struts libraries (including Javassist) to the /lib directory of the parent EAR project. This sounds weird to me, but it works and I'm sticking with the solution.
I'm not very familiar with Weblogic and Enterprise apps in general, so it didn't came to mind readily that the server treats the EAR as the base context and not the contained WAR.
Wonder if anyone has come accross this problem. I have created a demo portlet using the grails portlet and liferay plugins.
After installing the grails plugins in a project i simply ran the following commands
grails create-portlet MyFirst
grails generate-portlet-views MyFirst
grails liferay-deploy
The portlet deploys fine. However when i try to add the portlet to a page then i get the following stacktrace. Anyone have any ideas ?
23:04:52,134 ERROR [jsp:165] javax.servlet.ServletException: File "/WEB-INF/grails-app/views/myfirst/render.jsp" not found
I am running liferay version 5.2.3 that has tomcat version 6.0.18 embedded. I am also using JVM 1.6
thanks in advance.
The current versjon of the Grails portlet plugin (0.7) doesn't support portletnames with capital cases. Change MyFirst to myfirst and it will work like a charm (well, almost ;)
Regards
Armaz
It looks like it's not able to find render.gsp (the default gsp for a porltet if no mode specific view is found).
What did generate-portlet-views generate for you?
Take a closer look to your stacktrace - it attempts to look for render.jsp, not gsp. render.jsp is the default template LR attempts to find if it does not find what it is looking for depending on the action.
Read Armaz's answer, he is correct. You must change template folder name to lower case: myFirst => myfirst.
The next problem you might experience is solved here: Grails Liferay portlet not invoking action ;)