GRAILS: groovy.lang.MissingPropertyException: No such property. - grails

I'm trying to debug a Grails application. Unfortunately, I have no prior experience in said language.
When I do grails generate-all org.example.Book, I get back a vague error:
Generating controller for domain class org.example.Book ...
groovy.lang.MissingPropertyException: No such property: Event for class: SimpleTemplateScript6
at SimpleTemplateScript6.run(SimpleTemplateScript6.groovy:22)
at _GrailsGenerate_groovy.generateForDomainClass(_GrailsGenerate_groovy:88)
at _GrailsGenerate_groovy$_run_closure1.doCall(_GrailsGenerate_groovy:48)
at GenerateAll$_run_closure1.doCall(GenerateAll.groovy:42)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Error running generate-all: No such property: Event for class: SimpleTemplateScript6
After looking at the generated org.example.BookController.groovy source, I noticed that it was not fully generated (stopped at List fields = []):
package org.example
// import needed for export plugin
import org.codehaus.groovy.grails.commons.ConfigurationHolder
class BookController {
...
def exportService
def export = {attrs ->
def response = attrs.response
List fields = []
This error appears to be caused by the following code in templates/scaffolding/Controller.groovy:
<%=packageName ? "package ${packageName}\n\n" : ''%>
// import needed for export plugin
import org.codehaus.groovy.grails.commons.ConfigurationHolder
class ${className}Controller {
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]^M
def exportService
...
def export = {attrs ->
def response = attrs.response
List fields = []
<% excludedProps = Event.allEvents.toList() << 'version'
allowedNames = domainClass.persistentProperties*.name << 'id' << 'dateCreated' << 'lastUpdated'
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.eachWithIndex {p, i -> %>fields.push("${p.name}"<%="\n"%><% } %>
Map labels = [:]
<% props.eachWithIndex { p, i -> %>labels.putAt("\${p.name}", "\${p.naturalName}")<%="\n "%><% } %>
Map formatters = [:]
Map parameters = [:]
response.setHeader("Content-disposition", "attachment; filename=${domainClass.propertyName}s.\${attrs.extension}")
if("\${attrs.extension}" == "xml") {
exportService.export(attrs.format, response.outputStream, attrs.exportList, fields, [:], formatters, parameters)
} else {
exportService.export(attrs.format, response.outputStream, attrs.exportList, fields, labels, formatters, parameters)
}
}
...
}
It appears that the def export {} block seems to be causing problems. Is there something wrong with the above code?

What is the Event class? Is there an import for it?

Check your domain class for syntax errors. Make sure that in your domain class, you've included necessary packages, in your case, package org.example.

Related

Initialize Audit Trial Plugin in Jenkins using Groovy

My approach:
import hudson.plugins.audit_trail.AuditTrailPlugin
import hudson.plugins.jobConfigHistory.JobConfigHistory
import net.sf.json.JSONObject
def auditTrialPlugin = Jenkins.getInstance().getPlugin(AuditTrailPlugin.class)
// println(auditTrialPlugin.getConfigXml().asString())
println("Going to configure...")
def logger = new JSONObject()
logger.put("log", "Vibin")
logger.put("limit", "1")
logger.put("count", "2")
logger.put("stapler-class", "hudson.plugins.audit_trail.LogFileAuditLogger")
logger.put("\$class", "hudson.plugins.audit_trail.LogFileAuditLogger")
def plugin = new JSONObject()
plugin.put("name", "audit-trail")
plugin.put("pattern", "")
plugin.put("logBuildCause", true)
plugin.put("loggers", logger)
auditTrialPlugin.configure(null, plugin)
Error happening:
java.lang.NoSuchMethodException: hudson.plugins.audit_trail.LogFileAuditLogger.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
Caused: java.lang.InstantiationException: hudson.plugins.audit_trail.LogFileAuditLogger
at java.lang.Class.newInstance(Class.java:427)
at hudson.model.Descriptor.newInstance(Descriptor.java:578)
Caused: java.lang.Error: Failed to instantiate class hudson.plugins.audit_trail.LogFileAuditLogger from {"log":"Vibin","limit":"1","count":"2","stapler-class":"hudson.plugins.audit_trail.LogFileAuditLogger","$class":"hudson.plugins.audit_trail.LogFileAuditLogger"}
at hudson.model.Descriptor.newInstance(Descriptor.java:600)
at hudson.model.Descriptor.newInstancesFromHeteroList(Descriptor.java:1055)
at hudson.model.Descriptor.newInstancesFromHeteroList(Descriptor.java:1017)
at hudson.plugins.audit_trail.AuditTrailPlugin.configure(AuditTrailPlugin.java:78)
at hudson.plugins.audit_trail.AuditTrailPlugin$configure$1.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at Script1.run(Script1.groovy:24)
I tried to follow the code base of the plugin which I found on GitHub. There is a 'configure' function for the plugin which I tried to use which isn't working.
Codebase of plugin: GitHub link
Try this:
import jenkins.model.*;
import hudson.plugins.audit_trail.AuditTrailPlugin;
import hudson.plugins.audit_trail.LogFileAuditLogger;
def log = "Vibin"
def limit = 1
def count = 2
LogFileAuditLogger logFileAuditLogger = new LogFileAuditLogger(log, limit, count)
Jenkins j = Jenkins.getInstance();
AuditTrailPlugin plugin = j.getPlugin(AuditTrailPlugin.class);
plugin.loggers.clear()
plugin.loggers.add(logFileAuditLogger)
plugin.pattern = "" // empty pattern?
plugin.save()
plugin.start()
I think using LogFileAuditLogger class is more clear than 'configure' function.

Grails "Template not found error"

I am getting the following error when trying to render my GSP (using Grails 2.3.6):
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Template not found for name [/shared/mymenu] and path [/shared/_mymenu.gsp]
...long stacktrace omitted
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
Inside the /shared/_mymenu.gsp:
<g:render template="/shared/mmenustub" model="${['root':appmenu]}">
</g:render>
Am I missing something here? Perhaps a plugin attribute or something? If so, what am I missing and what should its value be?
The globalmenu taglib is define as follows:
class GlobalMenuTagLib {
def globalmenu = { attrs, body ->
List<NavigationScheme> allNavigationSchemes = navigationSchemeService.listAll()
def mapped = allNavigationSchemes.groupBy { menu -> menu.appreference }
def registeredApps = registerInfoService.listAllActive()
def activePage = attrs.activepage
def tempName = attrs.tempName?:'anothermenu'
out << render(template: "/shared/$tempName", model:[navscheme: mapped, regApps: registeredApps, activepage:activePage])
}
}
It is failing to find the /shared/_mymenu.gsp file. If this file exists in a plugin, then you need to reference it with the "plugin" argument in the render method so that it knows where to search for the file.
out << render(template: "/shared/$tempName", model:[navscheme: mapped, regApps: registeredApps, activepage:activePage], plugin: "myplugin")
where "myplugin" is the name of your plugin.

JavaMail SMTPAddressFailedException: 550 5.7.1 Unable to relay for ... (Grails)

I am trying to send mail using javamail from my Grails application (via a service).
Both the from and to addresses being used have the organization domain names.
The same code, when run via command line as a groovy script (on the same server) works as expected.
However, running on the grails server (under war mode) produces the following exception :
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for ---#---.com
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1873)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1120)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at javax.mail.Transport$send.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at cs.MailService.mail(MailService.groovy:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
The code is written as follows :
import javax.mail.internet.*
import javax.mail.*
import javax.activation.*
class Mailer {
def static mail(String toAddress, String subject, String body) {
println "mail called"
println "${toAddress}, ${subject}, ${body}"
try {
def fromAddress = "---#---.com"
def properties = new Properties()
properties.setProperty("mail.transport.protocol","smtp")
properties.setProperty("mail.smtp.host","---------")
def sessionInstance = Session.getDefaultInstance(properties,null);
def msg = new MimeMessage(sessionInstance)
def stringTokenizer = new StringTokenizer(toAddress,";")
def toAddressList = []
while(stringTokenizer.hasMoreElements()){
toAddressList.add(new InternetAddress(stringTokenizer.nextElement().toString()));
}
def to = new InternetAddress[toAddressList.size()]
to = (InternetAddress[]) toAddressList.toArray(to)
msg.setRecipients(MimeMessage.RecipientType.TO,to)
def from = new InternetAddress(fromAddress)
msg.setFrom(from);
msg.setSubject(subject)
def mimeMultipart = new MimeMultipart()
def mimeBodyPart = new MimeBodyPart()
mimeBodyPart.setContent("<p style='font-family:calibri;color:blue;font-size:20px;text-align:center;'>"+body+"</p>", "text/html")
mimeMultipart.addBodyPart(mimeBodyPart)
msg.setContent(mimeMultipart)
def transporter = sessionInstance.getTransport("smtp")
transporter.connect()
transporter.send(msg)
} catch(Exception e) {
e.printStackTrace()
}
}
public static void main(String[] args) {
def to="---#---.com"
def subject="Call Scheduler Notification"
def body='<font face="Segoe UI"><p><b><font color="#6B0667">Hi --- ---,<br><br>Your Call (id: 1281) Was Updated Successfully</b></font></p><table cellpadding="10" bgcolor="#B799B6"><caption><b><font color="#6B0667">Call Details</font></b></caption><tr><td><b>Title</b></td><td>---------</td></tr><tr><td><b>Start</b></td><td>---------</td></tr><tr><td><b>End</b></td><td>---------</td></tr><tr><td><b>Number</b></td><td>---------</td></tr><tr><td><b>Passcode</b></td><td>---------</td></tr><td><b>Special Instructions</b></td><td></td></tr><td><b>Callback Number</b></td><td>---------</td></tr></table><br><p><b><font color="#6B0667">Regards<br>Call Scheduler</b></font></p></font>'
mail(to, subject, body);
}
}
How do i get past this error ?
Update : Still not entirely sure what was wrong here. But resetting all the tcp/ip connections (from the mail server) resolved the issue.
You probably need to authenticate.
I don't know why it works from the command line.

Error deploying grails portlet on liferay 6

I want to test a simple liferay portlet with grails.
I am using: Liferay version liferay-portal-6.1.1-ce-ga2 that has tomcat version
tomcat-7.0.27 embedded , Grails 2.1.0 , IDE Groovy/Grails Tool Suite Version: 3.0.0.RELEASE andJDK1.7.0_05
I have instaled plugins.portlets=0.9.2 and plugins.portlets-liferay=0.4
After installing the grails plugins in a project i simply ran the following commands: create-portlet directorio.testLiferay and generate-portlet-views directorio.testLiferay
I have configurated Config.groovy following like http://grails.org/plugin/portlets-liferay
My portlet class looks like follow:
package directorio
import javax.portlet.*
class TestLiferayPortlet {
def title = 'Grails test'
def description = '''Portlet de pruebas.'''
def displayName = 'GrailsTest'
def supports = ['text/html':['view', 'edit', 'help']]
//uncomment to declare events support
//def events = [publish: ["event-1"], process: ["event-2"]]
//uncomment to declare public render parameter support
//def public_render_params = ["prp-1","prp-2"]
// DEFINITIONS FOR liferay-display.xml
def liferay_display_category = 'SCRD'
// DEFINITIONS FOR liferay-portlets.xml
def liferay_portlet_ajaxable = 'true'
def liferay_portlet_header_portlet_css = [
'/css/protoFlow.css'
]
def liferay_portlet_header_portlet_javascript = [
'/plugins/richui-0.5/js/flow/lib/prototype.js',
'/plugins/richui-0.5/js/flow/lib/scriptaculous.js',
'/plugins/richui-0.5/js/reflection/reflection.js',
'/plugins/richui-0.5/js/flow/protoFlow.js'
]
def actionView = {
//TODO Define action phase for 'view' portlet mode
portletResponse.setRenderParameter("prp-1", "value-1");
}
def eventView = {
//TODO Define event phase for 'view' portlet mode.
def eventValue = portletRequest.event.value
}
def renderView = {
//TODO Define render phase for 'view' portlet mode.
//Return the map of the variables bound to the view,
//in this case view.gsp if it exists or render.gsp if not
['mykey':'myvalue']
}
def resourceView = {
//TODO define resource phase for 'view' portlet mode.
//Render HTML as response
render {
html {
head()
body {
"Render me!!"
}
}
}
}
def actionEdit = {
//TODO Define action phase for 'edit' portlet mode
portletResponse.setEvent("event-1","event-1")
portletResponse.setPortletMode(PortletMode.VIEW)
}
def renderHelp = {
//TODO Define render phase for 'help' portlet mode
//Return the map of the variables bound to the view,
//in this case help.gsp if it exists or render.gsp if not
['mykey':'myvalue']
}
def doResource = {
//TODO Define handling for default resource URL handling method, independent of porlet mode
//Return the map of the variables bound to the view,
//in this case resource.gsp
['mykey':'myvalue']
}
//invoked by setting 'action' param in resourceURL (as an example) to 'doSomethingAjaxy'
def doSomethingAjaxy = {
//render JSON
render(contentType:"text/json") {
example(mykey:"myvalue")
}
}
//invoked by setting 'action' param in eventURL (as an example) to 'handleThisEvent'
def handleThisEvent = {
//render thisEvent.gsp
render(view:"thisEvent")
}
}
If i execute run-app and war, it works fine. However when i put the war into deploy liferay directory and startup tomcat, i get error:
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
18:44:16,665 ERROR [GrailsDispatcherPortlet:276] Context initialization failed
java.lang.NullPointerException
at org.codehaus.grails.portlets.container.AbstractPortletContainerAdapter.getInstance(AbstractPortletContainerAdapter.java:25)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.initPortletContainerAdapter(GrailsPortletApplicationContext.java:37)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.setPortletContext(GrailsPortletApplicationContext.java:28)
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:349)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:116)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:256)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:221)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:140)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:41)
at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:310)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:546)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:321)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:120)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:188)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:151)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:141)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:64)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:56)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:52)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
18:44:16,667 ERROR [pool-2-thread-1][PortletBagFactory:313] java.lang.NullPointerException
java.lang.NullPointerException
at org.codehaus.grails.portlets.container.AbstractPortletContainerAdapter.getInstance(AbstractPortletContainerAdapter.java:25)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.initPortletContainerAdapter(GrailsPortletApplicationContext.java:37)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.setPortletContext(GrailsPortletApplicationContext.java:28)
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:349)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:116)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:256)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:221)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:140)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:41)
at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:310)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:546)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:321)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:120)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:188)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:151)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:141)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:64)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:56)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:52)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
18:44:16,668 INFO [GrailsDispatcherPortlet:98] Initializing portlet 'TestLiferay'
18:44:16,671 INFO [GrailsDispatcherPortlet:263] FrameworkPortlet 'TestLiferay': initialization started
18:44:16,672 ERROR [GrailsDispatcherPortlet:276] Context initialization failed
java.lang.NullPointerException
at org.codehaus.grails.portlets.container.AbstractPortletContainerAdapter.getInstance(AbstractPortletContainerAdapter.java:25)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.initPortletContainerAdapter(GrailsPortletApplicationContext.java:37)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.setPortletContext(GrailsPortletApplicationContext.java:28)
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:349)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:116)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:256)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:221)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:140)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:41)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortletApp(PortletHotDeployListener.java:598)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:328)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:120)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:188)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:151)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:141)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:64)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:56)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:52)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
18:44:16,673 ERROR [pool-2-thread-1][HotDeployImpl:191] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for testLiferayPortlet-0.1
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for testLiferayPortlet-0.1
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:46)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:123)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:188)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:151)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:141)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:64)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:56)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:52)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at org.codehaus.grails.portlets.container.AbstractPortletContainerAdapter.getInstance(AbstractPortletContainerAdapter.java:25)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.initPortletContainerAdapter(GrailsPortletApplicationContext.java:37)
at org.codehaus.grails.portlets.GrailsPortletApplicationContext.setPortletContext(GrailsPortletApplicationContext.java:28)
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:349)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:116)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:256)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:221)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:140)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:41)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortletApp(PortletHotDeployListener.java:598)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:328)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:120)
... 24 more
I really apreciate any help.
Many tx.
It's a bug in liferay 6.1.1
http://issues.liferay.com/browse/LPS-29103
It appears hot deployment rearranges the listeners in web.xml when it merges it.
Might be better to stick with 6.1.0, or manually fix the web.xml everytime you redeploy
Add compile 'javax.portlet:portlet-api:2.0' in your dependencies of BuildConfig.groovy
:D

commonsMultipartFile trouble

Hi I have am trying to implement a file upload in my application where the file uploaded is parsed and an entry is created in the database using that information.
def save = {
def file = request.getFile("file");
def filename = file.getOriginalFilename();
def type = filename.split('\\.');
if(!file.isEmpty()){
if(type[1] == "properties"){
redirect(action:"parsePropertyFile", params:params);
}
}
}
def parsePropertyFile = {
println "\n"
println params.file;
println "\n";
def f = params.file;
println f;
def filename = f.getOriginalFilename();
println filename;
}
when I print out f this is output:
org.springframework.web.multipart.commons.CommonsMultipartFile#29d32df9
but when I try to call getOriginalFilename() on f I get the following error:
groovy.lang.MissingMethodException: No signature of method:
java.lang.String.getOriginalFilename() is applicable for argument types: () values: []
I also printed out file from the save function and the output of that is also:
org.springframework.web.multipart.commons.CommonsMultipartFile#29d32df9
so why am I getting the error?
Instead of redirecting, can you just call your another function? Redirect will issue an http redirect with the file as param with no need.
if(type[1] == "properties") {
parsePropertyFile(file)
}
And then:
private def parsePropertyFile(def file) {
String filename = file.getOriginalFilename();
...
}
In your parsePropertyFile action you aren't getting a File object, you're getting the String from params. Just like in your save action, you need to do
def f = request.getFile('file')
println f.getOriginalFilename()

Resources