Grails - trying to deploy a nojars application into glassfish 3.0.1 - grails

Because of memory constraint i am trying to build a grails app with smaller memory footprint. I build the war with this argument "--nojars". I created a war file without all the jar and when i deploy within the glassfish i encounter this error
Exception while loading the app : java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.web.util.Log4jConfigListener
It seems like the application fail to find where is the jar file.
I had already indicates the path to the library before deploying the application in glassfish.
did i miss out somethinng?

It is commonly recommended to use GlassFish's Common Classloader. That means putting the shared JARS into the $domain-dir/lib folder (but not into a subfolder of that).
You're probably trying to use the Application Classloader with the asadmin deploy --libraries command. This is more complicated and error-prone. If you don't need different versions of the same JARs with different web applications, you should definitely go for the Common Classloader as specified above.
Also see The Classloader Hierarchy for a reference.
EDIT Updated as per the questioner's comment:
The domain/domain1/lib folder definitely works (I've tested that). To validate that, put log4j.jar into that folder and add a test.jsp to domain1/applications/$applicationName, that just contains:
<% out.println(
org.apache.log4j.Logger.getLogger(this.getClass())); %>
If that works but your other code does not, there may be another point to consider: Are you using Log4J's Logger.getLogger(..) or Apache Commons' LogFactory.getInstance(..) in your code?
See the article Taxonomy of class loader problems encountered when using Jakarta Commons Logging for related issues. - I'd also like to advise you to post your complete stacktrace.

Related

Vaadin 23 application doesn't recognize vaadin-dev-server dependency when running in development mode

I'm in the process of upgrading a Vaadin Flow application from Vaadin 14 to Vaadin 22. I'm using Gradle 6.9.1 to build the application. When I run the application in Eclipse, I get warnings and errors in the logs identical to those documented in issue 11982. According to this issue, this initial warning about the vaadin-dev-server dependency is the most relevant message:
WARN [] [VaadinServletService] [qtp819245704-14] no DevModeHandlerManager implementation found but dev server enabled. Include the com.vaadin.vaadin-dev-server dependency.
I have included the dependency in my build.gradle file. Here are the dependencies that are relevant to Vaadin:
dependencies {
implementation "com.vaadin:vaadin-core:22.+"
implementation "com.vaadin:vaadin-dev-server:9.0.0"
}
I can see vaadin-dev-server-9.0.0.jar in my Referenced Libraries within Eclipse along with the other Vaadin .jar files. All of them are located in my Gradle cache.
Am I missing something, or is there anything I can do to resolve this issue? Let me know if there's any more information I can provide.
Edit: I'm now trying to upgrade the application to Vaadin 23 instead and I'm experiencing the same issue. I'm also getting the webpack error referenced in this question. If it helps, I'm running the project locally using embedded Jetty and I'm manually instantiating and invoking the initializers used by Vaadin as described in this answer.

How to Import existing Grails app into Intellij

I'm having a hard time importing an existing Grails 3 application into Intellij, in what feels like the "right way". I have the looked through the official intellij documentation but haven't found much to help me (what I have found hasn't fixed any of my issues). It's possible that I simply didn't find what I needed. This post here doesn't quite help me out either.
Here's what I've tried:
Note: The application I'm importing is grails 3.1.9 and works fine using the Grails CLI.
Import the project on build.gradle
I get the following errors/warnings:
Warning:<i><b>root project 'app': Unable to build Grails project configuration</b>
Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':compileCopy'.
Caused by: java.lang.RuntimeException: A conflict was found between the following modules:
- jline:jline:2.12
- jline:jline:2.11</i>
Warning:<i><b>root project 'app': Unable to build Grails project configuration</b>
Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':compileCopy'.
Caused by: java.lang.RuntimeException: A conflict was found between the following modules:
- jline:jline:2.12
- jline:jline:2.11</i>
However if I ignore those warnings, I can get the application to run by using a gradle run/debug configuration, using bootRun. If I try to setup a run/debug with Grails, intellij doesn't let me pick an "application". Adding Grails as a framework does not change this behavior. I'm also missing some of the grails specific features that Intellij gives you.
Create the project from existing sources
Following this series of menu's, I have no idea what to pick. With the defaults that Intellij selects, I am still unable to set a Grails run/debug configuration. I assume I just have to select the right sources, but I have no idea what I should be selecting.
If someone could give me a list of steps to perform, or point out exactly where I need to go in the documentation, that would be very helpful and appreciated.

Resources plugin with cached-resources

Grails 2.3.7 and the cached resources plugin, at least with lesscss resources are not working properly.
The cached plugin returns an erro which is the same error as described in this thread:
<dt>Class</dt><dd>java.lang.NullPointerException</dd><dt>Message</dt><dd>Cannot invoke method cache() on null object</dd></dl><h2>Around line 31 of <span class="filename">grails-app/resourceMappers/org/grails/plugin/cachedresources/HashAndCacheResourceMapper.groovy</span></h2>
<pre class="snippet"><code class="line"><span class="lineNumber">28:</span> if (log.debugEnabled) {</code><code class="line"><span class="lineNumber">29:</span> log.debug "Setting caching headers on ${req.requestURI
http://grails.1312388.n4.nabble.com/Grails-resources-bug-Unable-to-load-resources-at-startup-td4652307.html
The problem is that cacheHeadersService is not injected or null in the cacheheaders plugin.
Trying to solve this I copied the contents of the cached-resources-plugin 1.1 from target/work/plugins to a local folder and added the following line:
grails.plugin.location.'cached-resources' = "../grailsplugins/cached-resources-1.1"
The intention was to fix this bug myself.
However, strangely enough, when the plugin is locally used the problem with injecting the cacheHeadersService is gone!
How can the plugin act differently when used locally versus when installed normally?
Perhaps it is a loader issue where now the cache-resources-plugin is loaded after whatever is declaring the service, but nonetheless worth reporting.
In the dependencies.groovy in the cache-resources plugin it declares the dependency:
compile ":cache-headers:1.0.4"
but obviosuly it is not loaded before the plugin unless loaded from local directory, strange!
I am also wondering, since the cache-resources plugin declares a dependency on tomcat :
build(":tomcat:$grailsVersion",
":release:2.0.3",
":rest-client-builder:1.0.2") {
export = false
}
is tomcat a requirement? Trying to change to Jetty in the main application the build process fails, saying that tomcat can not be found in the repository.
build ":jetty:2.0.3"// ":tomcat:7.0.52.1"
I just found these similar questions as well:
Cached-resources plugin is not working?
Grails Cache resources not working
Resource not found on grails appliction with cache plugins

Grails JBOSSAS Plugin -- How To get it To Work?

Newbie Question:
I've been required to deploy a grails app to jboss 5. I'm having a hell of a time figuring out how to take advantage of the grails jbossas plugin. I've followed the documentation as best as I know how, but I get the same exceptions just as if the plugin was never there.
Here's the documentation i've been following:
http://grails-plugins.github.com/grails-jbossas/docs/manual/guide/2%20Usage.html
I've added the plugin to the BuildConfig.groovy plugin{} closure. I then called grails war. Nothing happens and my war deploy bombs out.
Could somebody give a newbie a little hand holding to get this plugin to work? Unfortunately, I'm finding the documentation to be wanting in the regard of actually telling you how to use it, or when the plugin will do its magic.
UPDATE:
My environment:
Mac OS X Lion Dev machine
Grails 2.0.3
JBoss 5.1.0 -- running a Liferay instance.
Burt, I've done the following:
grails generate-jboss-deploy 5
grails war.
scp the generated war file to the deploy-jboss directory on my remote server.
Dutifully, jboss picked up the new war and attempted to deploy it. I'm getting the following (now dreaded) exception:
Caused by: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator
Per the usage instructions, I've modified Datasource.groovy's hibernate configuration:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
validator.apply_to_ddl = false
validator.autoregister_listeners = false
}
The only file that seems to have been modified or created by running the generate-jboss-delpoy 5 script is WEB-INF/jboss-web.xml. It's contents are:
<jboss-web>
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
sappi-label:loader=sappi-label.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
I confirmed that the jboss-web.xml file is present in the generated war file (exploded, then checked the directory).
Burt: what files other than jboss-web.xml should have been altered?
UPDATE (Again):
I don't think there's anything wrong with the jbossas plugin. I've done more testing and see that the plugin is doing what it is supposed to do: remove jars, put in jboss-web.xml. I haven't been able to confirm that it modifies the hibernate config, but I assume it is. I think the problem lies within the server I'm attempting to deploy to, a Liferay instance.
regardless of what I'm doing I get an exception saying that slf4j was unable to load successfully. Nothing more, nothing less. I'll keep whacking away at the problem, but it is out of scope of my original question. Burt, thanks for your help. If you have any ideas about why slf4j vomits in a Liferay/jboss environment, please let me know.
Regards.
Thanks!
I guess I didn't make it clear that you need to run the generate-jboss-deploy script, passing in the major version of JBoss that you're using, so in your case generate-jboss-deploy 5. I've updated the docs to describe this.
If this doesn't help please update your question with some indication of what the errors that you're seeing are.

Standalone OpenEJB packaging with dependencies

there's some documentation/specification about how to package and deploy EJB with dependencies on OpenEJB?
I tried to deploy an EAR package:
service.ear/lib/activemq-all.jar
service.ear/META-INF/application.xml
service.ear/model.ejb!META-INF/ejb-jar.xml
service.ear/model.ejb!com/example/MyActivemqDependentService.class
It was deployed successfully, client can find using JNDI, but, when it initialized, NoClassDefFound exception ocurr.
ActiveMQ already comes with OpenEJB, I wouldn't expect it to work including it in the EAR as well.
That could very likely be the source of your NoClassDefFoundErrors. Removing that activemq-all.jar is the first thing I'd try.

Resources