Spring Webmvc NoClassDefFoundError for class 'ModelAndViewDefiningException' - noclassdeffounderror

I have looked into this similar post here: NoClassDefFoundError ModelAndViewDefiningException on spring+was8.5.5.13, but it had no solutions.
I have unpacked my war file, and unpacked a library within it to verify it does contain the class mentioned in the NoClassDefFoundError:
spring-webmvc-4.3.6.RELEASE.jar contains org/springframework/web/servlet/ModelAndViewDefiningException.class.
These are all my spring-related dependencies:
lib/metrics-spring-3.1.0 2 2.jar
lib/metrics-spring-3.1.0 2 3.jar
lib/metrics-spring-3.1.0 2.jar
lib/metrics-spring-3.1.0 3.jar
lib/metrics-spring-3.1.0.jar
lib/micrometer-spring-legacy-1.1.0.jar
lib/spring-aop-4.3.6.RELEASE.jar
lib/spring-aspects-4.3.6.RELEASE.jar
lib/spring-beans-4.3.6.RELEASE.jar
lib/spring-boot-2.1.1.RELEASE.jar
lib/spring-boot-actuator-2.1.1.RELEASE.jar
lib/spring-boot-actuator-autoconfigure-2.1.1.RELEASE.jar
lib/spring-boot-autoconfigure-2.1.1.RELEASE.jar
lib/spring-boot-starter-2.1.1.RELEASE.jar
lib/spring-boot-starter-actuator-2.1.1.RELEASE.jar
lib/spring-boot-starter-logging-2.1.1.RELEASE.jar
lib/spring-cloud-aws-autoconfigure-2.0.1.RELEASE.jar
lib/spring-cloud-aws-context-2.0.1.RELEASE.jar
lib/spring-cloud-aws-core-2.0.1.RELEASE.jar
lib/spring-cloud-starter-aws-2.0.1.RELEASE.jar
lib/spring-context-4.3.6.RELEASE.jar
lib/spring-context-support-4.1.6.RELEASE.jar
lib/spring-core-4.3.6.RELEASE.jar
lib/spring-data-commons-1.12.7.RELEASE.jar
lib/spring-data-jpa-1.10.7.RELEASE.jar
lib/spring-expression-4.3.6.RELEASE.jar
lib/spring-jdbc-4.3.6.RELEASE.jar
lib/spring-orm-4.3.6.RELEASE.jar
lib/spring-security-core-4.0.2.RELEASE.jar
lib/spring-test-4.3.6.RELEASE.jar
lib/spring-tx-4.3.6.RELEASE.jar
lib/spring-web-4.3.6.RELEASE.jar
lib/spring-webmvc-4.3.6.RELEASE.jar
The last one only containing the specified class "ModelAndViewDefiningException" in the NoClassDefFoundError.
I have scanned through the unpacked jar file using my bash script to verify that the ModelAndViewDefiningException does indeed exist.
#!/bin/bash
for filename in lib/*spring*.jar; do
x=`jar -tvf "$filename" | grep 'ModelAndViewDefiningException'`
if test ! -z "$x"
then
echo $filename " class found is: " $x
fi
done
It does indeed exist, through my script above:
lib/spring-webmvc-4.3.6.RELEASE.jar class found is: 854 Wed Jan 25 13:16:28 AEDT 2017 org/springframework/web/servlet/ModelAndViewDefiningException.class
ip-192-168-0-13:WEB-INF

This occurs because of maxed out file handles. This application runs on an Amazon instance production server, doing loads of volume. Running applications like Nginx, and some of our own applications.
That's why the JVM was unable to load in the class, because there weren't any file handles, hence the NoClassDefFoundError exception was being thrown.

Related

PHP Warning: Module 'imagick' already loaded in Unknown on line 0, need some assistance

So I checked my spam folder today and had 122 messages send through the server stating:
PHP Warning: Module 'imagick' already loaded in Unknown on line 0
Non stop it keeps sending me this.
Googled it and still have no clue on how to fix it as I need a step by step answer.
Found a similar question on stack but it's too complicated for me to understand.
I'm on the latest Plesk Onyx and OS=Ubuntu 16.04.6 LTS‬.
As I'm running php 7.3 I hoped when I uninstalled php 7.0 in plesk it would go away but unfortunately it didn't.
It's send from here
Cron <root#server> [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
And after php --ini (read about it on a forum) this was the result:
PHP Warning: Module 'imagick' already loaded in Unknown on line 0
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/00-ioncube-loader-7.0.ini,
/etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/15-xml.ini,
/etc/php/7.0/cli/conf.d/20-calendar.ini,
/etc/php/7.0/cli/conf.d/20-ctype.ini,
/etc/php/7.0/cli/conf.d/20-curl.ini,
/etc/php/7.0/cli/conf.d/20-dom.ini,
/etc/php/7.0/cli/conf.d/20-exif.ini,
/etc/php/7.0/cli/conf.d/20-fileinfo.ini,
/etc/php/7.0/cli/conf.d/20-ftp.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-gettext.ini,
/etc/php/7.0/cli/conf.d/20-iconv.ini,
/etc/php/7.0/cli/conf.d/20-imagick.ini,
/etc/php/7.0/cli/conf.d/20-imap.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-mbstring.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/7.0/cli/conf.d/20-phar.ini,
/etc/php/7.0/cli/conf.d/20-posix.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/20-shmop.ini,
/etc/php/7.0/cli/conf.d/20-simplexml.ini,
/etc/php/7.0/cli/conf.d/20-sockets.ini,
/etc/php/7.0/cli/conf.d/20-sqlite3.ini,
/etc/php/7.0/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.0/cli/conf.d/20-sysvsem.ini,
/etc/php/7.0/cli/conf.d/20-sysvshm.ini,
/etc/php/7.0/cli/conf.d/20-tokenizer.ini,
/etc/php/7.0/cli/conf.d/20-wddx.ini,
/etc/php/7.0/cli/conf.d/20-xmlreader.ini,
/etc/php/7.0/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.0/cli/conf.d/20-xsl.ini,
/etc/php/7.0/cli/conf.d/20-zip.ini,
/etc/php/7.0/cli/conf.d/zend_extensions_psa.ini
I already know it's probably easily fixed when you know linux but I'm learning on the go and posses very little knowledge yet.
Could anyone assist me with the right commands?
Cheers
Locate where is your php.ini file by:
php -i | grep Configuration
Configuration File (php.ini) Path => /usr/local/etc/php/7.4
Loaded Configuration File => /usr/local/etc/php/7.4/php.ini
Open the php.ini file and remove the line:
extension=imagick.so
or change the line to a comment:
; extension=imagick.so

Where to find logs for a cloud-init user-data script?

I'm initializing spot instances running a derivative of the standard Ubuntu 13.04 AMI by pasting a shell script into the user-data field.
This works. The script runs. But it's difficult to debug because I can't figure out where the output of the script is being logged, if anywhere.
I've looked in /var/log/cloud-init.log, which seems to contain a bunch of stuff that would be relevant to debugging cloud-init, itself, but nothing about my script. I grepped in /var/log and found nothing.
Is there something special I have to do to turn logging on?
The default location for cloud init user data is already /var/log/cloud-init-output.log, in AWS, DigitalOcean and most other cloud providers. You don't need to set up any additional logging to see the output.
You could create a cloud-config file (with "#cloud-config" at the top) for your userdata, use runcmd to call the script, and then enable output logging like this:
output: {all: '| tee -a /var/log/cloud-init-output.log'}
so I tried to replicate your problem. Usually I work in Cloud Config and therefore I just created a simple test user-data script like this:
#!/bin/sh
echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt
echo "I am out of the output file...somewhere?"
yum search git # just for fun
ls
exit 0
Notice that, with CloudInit shell scripts, the user-data "will be executed at rc.local-like level during first boot. rc.local-like means 'very late in the boot sequence'"
After logging in into my instance (a Scientific Linux machine) I first went to /var/log/boot.log and there I found:
Hello World. The time is now Wed, 11 Sep 2013 10:21:37 +0200! I am
out of the file. Log file somewhere? Loaded plugins: changelog,
kernel-module, priorities, protectbase, security,
: tsflags, versionlock 126 packages excluded due to repository priority protections 9 packages excluded due to repository
protections ^Mepel/pkgtags
| 581 kB 00:00
=============================== N/S Matched: git =============================== ^[[1mGit^[[0;10mPython.noarch : Python ^[[1mGit^[[0;10m Library c^[[1mgit^[[0;10m.x86_64 : A fast web
interface for ^[[1mgit^[[0;10m
...
... (more yum search output)
...
bin etc lib lost+found mnt proc sbin srv tmp var
boot dev home lib64 media opt root selinux sys usr
(other unrelated stuff)
So, as you can see, my script ran and was rightly logged.
Also, as expected, I had my forced log 'output.txt' in /root/output.txt with the content:
Hello World. The time is now Wed, 11 Sep 2013 10:21:37 +0200!
So...I am not really sure what is happening in you script.
Make sure you're exiting the script with
exit 0 #or some other code
If it still doesn't work, you should provide more info, like your script, your boot.log, your /etc/rc.local, and your cloudinit.log.
btw: what is your cloudinit version?

How to start a Scala method from command line?

This question may sound a bit stupid, but I couldn't figure out, how to start a Scala method from the command line.
I compiled the following file Test.scala :
package example
object Test {
def print() {
println("Hello World")
}
}
with scalac Test.scala.
Then, I can run the method print with scala in two steps:
C:\Users\John\Scala\Examples>scala
Welcome to Scala version 2.9.2 (Java HotSpot(TM) Client VM, Java 1.6.0_32).
Type in expressions to have them evaluated.
Type :help for more information.
scala> example.Test.print
Hello World
But what I really like to do is, to run the method directly from the command line with one command like scala example.Test.print.
How can I achieve this goal ?
UPDATE:
Suggested solution by ArikG does not work for me - What I am missing ?
C:\Users\John\Scala\Examples>scala -e 'example.Test.print'
C:\Users\John\AppData\Local\Temp\scalacmd1874056752498579477.scala:1: error: u
nclosed character literal
'example.Test.print'
^
one error found
C:\Users\John\Scala\Examples>scala -e "example.Test.print"
C:\Users\John\AppData\Local\Temp\scalacmd1889443681948722298.scala:1: error: o
bject Test in package example cannot be accessed in package example
example.Test.print
^
one error found
where
C:\Users\John\Scala\Examples>dir example
Volume in drive C has no label.
Volume Serial Number is 4C49-8C7F
Directory of C:\Users\John\Scala\Examples\example
14.08.2012 12:14 <DIR> .
14.08.2012 12:14 <DIR> ..
14.08.2012 12:14 493 Test$.class
14.08.2012 12:14 530 Test.class
2 File(s) 1.023 bytes
2 Dir(s) 107.935.760.384 bytes free
UPDATE 2 - Possible SOLUTIONs:
As ArikG correctly suggested, with scala -e "import example.Test._; print" works well with Windows 7.
See answer of Daniel to get it work without the import statement
Let me expand on this solution a bit:
scala -e 'example.Test.print'
Instead, try:
scala -cp path-to-the-target-directory -e 'example.Test.print'
Where the target directory is the directory where scala used as destination for whatever it compiled. In your example, it is not C:\Users\John\Scala\Examples\example, but C:\Users\John\Scala\Examples. The directory example is where Scala will look for classes belonging to the package example.
This is why things did not work: it expected to find the package example under a directory example, but there were no such directory under the current directory in which you ran scala, and the classfiles that were present on the current directory were expected to be on the default package.
The best way to do this is to extend App which is a slightly special class (or at least DelayedInit which underlies it is):
package example
object Test extends App {
println("Hello World")
}
It's still possible to add methods to this as well, the body of the object is executed on startup.
Here you go:
scala -e 'example.Test.print'

Default configuration in Play 2.0 causes IOException?

Is this a bug with the default configuration of Play 2.0? I have just installed Play 2.0 and when I create an application for the first time, I get this:
Error during sbt execution: java.io.IOException: Cannot write parent directory: Path(/home/hanxue/play/myFirstApp/app) of /home/hanxue/play/myFirstApp/app/views
The app subdirectory does not have write permissions:
hanxue#ubuntu-dev:~/play$ ls -l myFirstApp/
total 16
dr-xr-xr-x 2 hanxue hanxue 4096 2012-03-13 11:22 app
It also seems that the $PLAY/framework/sbt/boot/ directory need to be world-writable or otherwise play will throw an IOException about not being able to create /opt/play-2.0/framework/sbt/boot/sbt.boot.lock . Is this by design?
I solved it by giving it world-writable permission
chmod -R o+w /opt/play-2.0/framework/sbt/boot/
This is not a bug, it is just how sbt works(and play-2.0 uses sbt). Sbt downloads all necessary parts first time when its started, and default behavior of play is that all dependency go to same directory and this is place where you extracted play-2.0, so this directory needs write permissions. You will probably need write permissions on /opt/play-2.0/repository too.

JBOSS | Jasper report error

My application generates some reports to it's clients. But there's an error when generating the reports here's the exception:-
java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer.<init>(Lorg/eclipse/jdt/internal/compiler/env/IBinaryType;)V
net.sf.jasperreports.engine.design.JRJdtCompiler$1.findType(JRJdtCompiler.java:235)
net.sf.jasperreports.engine.design.JRJdtCompiler$1.findType(JRJdtCompiler.java:204)
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:119)
org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getType(PackageBinding.java:126)
org.eclipse.jdt.internal.compiler.lookup.Scope.findType(Scope.java:1355)
org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2472)
org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2194)
org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:39)
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:141)
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:104)
org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1107)
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperclass(ClassScope.java:767)
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:947)
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:266)
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:195)
org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:301)
org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:315)
net.sf.jasperreports.engine.design.JRJdtCompiler.compileClass(JRJdtCompiler.java:392)
net.sf.jasperreports.engine.design.JRJdtCompiler.compileReport(JRJdtCompiler.java:109)
net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:106)
net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:128)
net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:110)
Recently I moved this application to JBOSS 4.0.5.GA. This application was running fine and there's no errors in generating reports in Tomcat 5
Thanks.
I believe there is a conflicting JAR file:
jdt-compiler-3.1.1.jar
I created a script to set the CLASSPATH before Tomcat runs:
#!/bin/bash
IREPORT_HOME=$HOME/bin/ireport
CLASSPATH=$IREPORT_HOME/platform9/modules/org-netbeans-core.jar:
for j in \
$IREPORT_HOME/ireport/modules/ext/*.jar \
$IREPORT_HOME/ide10/modules/ext/*.jar; do
BASENAME=$(basename $j)
# Append file names to the CLASSPATH, except those with Tomcat conflicts.
if [ "$BASENAME" != "jdt-compiler-3.1.1.jar" ]; then
CLASSPATH=$j:$CLASSPATH
fi
done
export CLASSPATH=$CLASSPATH.
Save it as setenv.sh and place it in $CATALINA_HOME/bin. You will have to change the IREPORT_HOME variable accordingly.