I have created REST API for captcha - using JCaptcha in spring framework.
Everything works fine when i place the war file inside tomcat7 server present in windows OS environment.
For deployment, when i use same war file in tomcat7 web server which present in Ubuntu 14.04 the api suddenly start giving http 500 response code with following exception :
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class sun.awt.image.codec.JPEGImageEncoderImpl
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
com.televital.vitalware.services.CORSFilter.doFilterInternal(CORSFilter.java:29)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
I have reffered following link for the development of the API
https://jcaptcha.atlassian.net/wiki/display/general/JCaptcha+and+the+SpringFramework
Please help me.It alredy took my 2 days.
There are two possibilities.
sun.awt.image.codec.* is included in <JDK installation
folder>\jre\lib\rt.jar. So check this jar is already existed in your
Linux machine or not.
The second one is you need to turn on Headless mode in your Linux machine.Before you run tomcat startup script, you need to turn on Headless mode like this
JAVA_OPTS='-Djava.awt.headless=true'
From the stack trace its evident that on Ubuntu the application is not able to locate the sun.awt.image.codec.JPEGImageEncoderImpl class from <JDK installation>\jre\lib\rt.jar.
To resolve the error check below
JDK is installed correctly (if not re-install)
JAVA_HOME is configured correctly
If above two are correct then use headless mode by specifying -Djava.awt.headless=true
Related
I am new to java servlets. I have installed apache-tomcat-9.0.0.M21.
When I run the project containing servlet in eclipse browser, sometimes I get the error-
Error resolving 'localhost': Name or service not known.
Other times the error is -
Error resolving 'localhost' : Temporary failure in name resolution.
This project runs fine in my web browser.
Also, after I add <servlet>...</servlet> and <servlet-mapping>...<servlet-mapping> in web.xml, I get the error - Server Tomcat v9.0 Server at localhost failed to start.
One more thing, I use Ubuntu operating system (if it has to do something with the question).
Please help. I googled for the solution but I am not able to resolve the error.
Try adding the below to your /etc/hosts file.
127.0.0.1 localhost
I have big problem to run activiti-explorer when i try access: http://localhost:8080/activiti-explorer/ tomcat shows me HTTP Status 404 - The requested resource is not available. I'm really don't have any idea why that dosen't work. Can you help me?
This what have I done on my PC:
I'm using 5.19.0 version of activiti-explorer
7.0.63 tomcat
JDK 1.8.0.77 (i think there is no point to downgrade java to previous versions (<=1.7) becouse my main application using this version)
I'm sure I have correctly configured environment variables (JAVA_HOME,JRE_HOME,PATH,CATALINA_HOME)
I configured data base connection (db.properties, context.xml) in activiti-explorer.war and i moved this file to tomcat/webapps
I don't have any errors about activiti during tomcat start
Check if activiti explorer is deployed to tomcat in manager.
http://{host}:{port}/manager/html
More info in https://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html
Check the catalina.out log. There will be something in there that leads you to the solution.
Check Admin Console (cmd that runs behind) after hitting the link. most recent exception occurred will be displayed there.
I have one Linux VPS dedicated just for running a jmeter. The tests run fine, but failed requests are not written to error.jtl with SimpleDataWriter. Java error is written to jmeter.log instead.
I run the tests in non-gui mode:
jmeter -n -t om5.jmx -j results-tmp1/t3-l1-jmeter.log
The error
2016/07/08 16:59:35 ERROR - jmeter.reporters.ResultCollector:
Error trying to record a sample java.lang.IllegalArgumentException: Failed marshalling:class:class
org.apache.jmeter.samplers.SampleResult,content:org.apache.jmeter.samplers.SampleResult#1f605bfa[saveConfig=org.apache.jmeter.samplers.SampleSaveConfiguration#b4a9237e,parent=<null>,
responseData={},responseCode=500,label=03 add to cart,resultFileName=,samplerData=<null>,threadName=Thread Group 1-149,responseMessage=Number of samples in transaction : 2, number of failing samples : 1,
responseHeaders=,contentType=,requestHeaders=,timeStamp=1467989884109,startTime=1467989884109,endTime=1467989975286,idleTime=1001,pauseTime=0,assertionResults=<null>,subResults=[reset basketItems, /some-page],
dataType=,success=false,files=[res-tmp/t400-l5-errors.jtl],dataEncoding=<null>,elapsedTime=90176,latency=0,connectTime=0,startNextThreadLoop=false,stopThread=false,stopTest=false,
stopTestNow=false,isMonitor=false,sampleCount=1,bytes=806,headersSize=192,bodySize=614,groupThreads=400,allThreads=400,nanoTimeOffset=1467988012523,useNanoTime=true,nanoThreadSleep=5000,location=<null>]
at org.apache.jmeter.save.SaveService.saveSampleResult(SaveService.java:345)
at org.apache.jmeter.reporters.ResultCollector.sampleOccurred(ResultCollector.java:557)
at org.apache.jmeter.threads.ListenerNotifier.notifyListeners(ListenerNotifier.java:67)
at org.apache.jmeter.threads.JMeterThread.notifyListeners(JMeterThread.java:819)
at org.apache.jmeter.threads.JMeterThread.doEndTransactionSampler(JMeterThread.java:534)
at org.apache.jmeter.threads.JMeterThread.triggerEndOfLoopOnParentControllers(JMeterThread.java:342)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:258)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
I cannot find what is wrong. It is only that one machine, that gives me this error. Everywhere else I try it, it works correctly.
The OS is Debian Jessie (8.5) - minimal from official repositories. I tried many different versions of java (1.7, 1.8) - currently running on the latest 1.8 (1.8.0_92-b14) and I have the latest apache-jmeter 3.0 r1743807, but previously I used 2.13 r1665067. I don't use any third-party plugins.
I didn't notice exactly when it stopped working, what change was done (some os update, maybe some change in jmx), but I have my tests in git, so I checked out older version from the date of my last full error.jtl and it is not writing the errors to jtl as well.
I reinstalled the Debian to Ubuntu 16.04 and nothing changed.
I don't know how to debug that problem, what should I do, because on any other machine I have an access to, it works fine.
I don't know if you've fixed this problem until now?
I had the same issue, and I fixed it just now.
I guess in your jmeter script, you checked the hostname to record sample result, in jmeter.log, you could find such message: jmeter couldn't get the linux Local IP, so hostname is Null, exception threw out.
So what you need to do is remove 'Save Hostname' from 'Sample Result Save Configuration' tab.
When I run my project, I don't have errors.
But After login, when I try to enter in a form page the application give me the follow error:
GRAVE: Servlet.service() for servlet jsp threw exception
java.util.NoSuchElementException
at java.util.ArrayList$Itr.next(Unknown Source)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1381)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:772)
at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:779)
at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:895)
...
I think the problem is in the configuration of tomcat but I don't understand where.
I have tomcat7.0.52, use java version 1.7.0_60, idem for jdk.
At my colleague work all without problems, we have the same tomcat version, the only difference is that I have STS 3.6 RELEASE, and He have the 3.5.
EDIT:
I try to delete server, and recreate it, but the problem don't change.
I think that the problem is on wrong configuration server because any project I run give me the same error.
This is my catalina arguments:
-Dcatalina.base="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/base-instance"
-Dcatalina.home="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/tomcat-7.0.53.B.RELEASE"
-Dwtp.deploy="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/base-instance/wtpwebapps"
-Djava.endorsed.dirs="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/tomcat-7.0.53.B.RELEASE/endorsed" -Xmx768m -Xss256k -XX:MaxPermSize=256m
-Dinsight.enabled=false -Dspring.profiles.active=dev
Any ideas?
Thank
It looks like the problem is with the version of Tomcat that tcServer is derived from.
This bug which is fixed in Tomcat 7.0.55 is looks like the cause.
I've done some testing and found that the bug is not present in Tomcat 7.0.50, which is used by tcServer Dev Edition 2.9.5.SR1.
So it's either 7.0.51 or 7.0.52 (as you discovered) which introduced the bug.
I have a problem when I try to instantiate Hibernate and connect with a MySQL database (see error message below).
Curiously enough the connection works fine using the exact same hibernate.cfg.xml file when running Junit tests but it refuses to work when run from Tomcat...
I am starting to run out of ideas.
Any clues or tip where to look?
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.DynamicMapEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:69)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at se.fmt.atlantism.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:16)
... 38 more
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 47 more
I'm writing this for future Googlers and reference.
I've done some more research and the root source of the problem is still not known. However the following article throw me on the right track.
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
It seems like the Tomcat (version 6 at least) packages available in Ubuntu (and Debian) are not working correctly. Instead I installed Tomcat using the following guide:
http://www.ctrip.ufl.edu/tomcat6-debian-lenny-howto
While this might not be the premium choice of installation it seems necessary to get Tomcat version 6 running without problems on Ubuntu and/or Debian Lenny.
In my case, this error was resolved by switching the <dependency/> order in my pom.xml. When hibernate (3.2.7.ga) comes before hibernate-annotations (3.4.0.GA) this error occurs. The other way around, it works fine. This is the case even with scope=compile.
I would guess that you need to tweak your classpath, except that (assuming you've dropped both jars in WEB-INF/lib) it should alpha-sort in the correct order. But maybe this will give someone a hint on how to move forward.
In my case it was a simple mistake - the config file *.hbm.xml had a property that the mapped object didnt have! I also heard of cases of that error apearing when you misspell a get/set function - very similar to my case.
I was facing the same problem. It went away after I downloaded "javassist.jar" and put it in the classpath: http://www.java2s.com/Code/Jar/JKL/Downloadjavassistjar.htm
This is how the Tomcat daemon process looks:
root 2605 0.0 0.0 16584 376 ? Ss 15:39 0:00
/usr/bin/jsvc -user tomcat6
-cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat6/bin/bootstrap.jar
-outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat6.pid
-Djava.awt.headless=true -Xmx128M
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6
-Djava.io.tmpdir=/tmp/tomcat6-temp -Djava.security.manager
-Djava.security.policy=/var/lib/tomcat6/work/catalina.policy
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
org.apache.catalina.startup.Bootstrap
This is how the Tomcat process looks when run from within Eclipse using the Sysdeo Tomcat launcher plugin:
(this one actually works)
jzaruba 2655 19.7 4.5 358304 46152 ? Sl 15:43 0:01
/usr/lib/jvm/java-6-sun-1.6.0.15/bin/java
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:37377
-Dcatalina.home=/usr/share/tomcat6
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Djava.io.tmpdir=/var/lib/tomcat6/temp
-Dfile.encoding=UTF-8 -classpath
/usr/share/tomcat6/bin/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.15/lib/tools.jar
org.apache.catalina.startup.Bootstrap start
The working one (Eclipse launched) is run using java-6-sun-1.6.0.15, I'm Windows user so I don't know how to tell which JRE is used for /usr/lib/jsvc (looking at it though), but my guess would be it is some OpenJDK... Could this be the difference?
update: jsvc probably uses the same JRE Sysdeo Tomcat launcher does