I have a problem when trying to include the Elasticsearch java client in my WebApp. I have the required dependencies and I am creating the client (As a simple test) in a initializing/destroying Spring bean like so:
#Override
public void afterPropertiesSet() throws Exception {
try {
client = new TransportClient();
InetSocketTransportAddress addr = new InetSocketTransportAddress("localhost", 9300);
((TransportClient) client).addTransportAddress(addr);
}
catch(Exception e){
System.out.println(e.toString());
}
}
The corresponding destroy() will close the client.
Everything looks ok and the context starts fine however when accessing a JSP I receive the following exception:
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Fountain] threw exception [Filter execution threw an exception] with root cause
java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "javax.servlet.ServletResponseWrapper.getOutputStream()Ljavax/servlet/ServletOutputStream;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, javax/servlet/ServletResponseWrapper, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for interface javax/servlet/ServletResponse have different Class objects for the type vlet/ServletOutputStream; used in the signature
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:186)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:181)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Jan 10, 2014 10:44:46 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.LinkageError: loader constraint violation: when resolving method "javax.servlet.jsp.JspFactory.getPageContext(Ljavax/servlet/Servlet;Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/jsp/ajaxerror_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspFactory, have different Class objects for the type t/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext; used in the signature
at org.apache.jsp.jsp.ajaxerror_jsp._jspService(ajaxerror_jsp.java:59)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:489)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:467)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:412)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:201)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Jan 10, 2014 10:44:46 AM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[exceptionType=java.lang.Throwable, location=/jsp/ajaxerror.jsp]
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving method "javax.servlet.jsp.JspFactory.getPageContext(Ljavax/servlet/Servlet;Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/jsp/ajaxerror_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspFactory, have different Class objects for the type t/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext; used in the signature
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:489)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:467)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:412)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:201)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving method "javax.servlet.jsp.JspFactory.getPageContext(Ljavax/servlet/Servlet;Ljavax/servlet/ServletR equest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/jsp/ajaxerror_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspFactory, have different Class objects for the type t/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext; used in the signature
at org.apache.jsp.jsp.ajaxerror_jsp._jspService(ajaxerror_jsp.java:130)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
... 22 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "javax.servlet.jsp.JspFactory.getPageContext(Ljavax/servlet/Servlet;Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/jsp/ajaxerror_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspFactory, have different Class objects for the type t/ServletRequest;Ljavax/servlet/ServletResponse;Ljava/lang/String;ZIZ)Ljavax/servlet/jsp/PageContext; used in the signature
at org.apache.jsp.jsp.ajaxerror_jsp._jspService(ajaxerror_jsp.java:59)
... 25 more
Without this the context starts and will serve JSPs correctly.
Does anyone have any ideas what may be causing this? I'm assuming the elasticsearch client is using a class that the web-app required but instatiating it in a different classloader.
I've tried explicitly setting the classloader used by elastic search by using ImmutableSettings but this appears not to make any difference:
ClassLoader contextClassLoader = thread.getContextClassLoader();
try {
//thread.setContextClassLoader(ClassLoader.getSystemClassLoader());
Settings s = ImmutableSettings.settingsBuilder()
.classLoader(contextClassLoader)
.build();
Any help would be appreciated! Thanks!
Ok, managed to resolve this problem:
Get a ref to the tomcat 'common' classloader and passed this to the Elasticsearch client:
ClassLoader contextClassLoader = thread.getContextClassLoader();
try {
Settings settings = ImmutableSettings.settingsBuilder().classLoader(contextClassLoader.getParent()).build();
client = new TransportClient(settings);
A side effect of this is that the names.txt file has to be moved from the elasticSearch jar to somewhere on the 'common' classpath.
I still haven't tracked down why this issue is affecting my particular stack and not others but aim to do so and update here.
The solution is to create the elastcisearch client like this :
Settings settings = ImmutableSettings.settingsBuilder()
.put(“path.plugins”, “fakeDirectory:\\”)
.build();
TransportClient client = new TransportClient(settings);
I put a fake directory because ElasticSearch use it when it start to load all eclipse plugins but i d’ont know why !! (see org.elasticsearch.plugins.PluginsService class).
Related
I have added a new action to the Document Library. My java class extends
ActionExecuterAbstractBase
. Inside code I make an HttpsURLConnection and read response like this :
URL url = new URL("https://...................................Get?username="+Name+"&password="+Password);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
Outside Alfresco the java script works perfectly but inside it throws the following error :
Web Script Status 405 - Method Not Allowed
The Web Script /alfresco/s/api/action/cosign/formprocessor has responded with a status of 405 - Method Not Allowed.
405 Description: The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.
Message: 08060002 Script url /api/action/cosign/formprocessor does not support the method GET
Exception: org.springframework.extensions.webscripts.WebScriptException - 08060002 Script url /api/action/cosign/formprocessor does not support the method GET
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:179)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
Server: Community v5.0.0 (d r99759-b2) schema 8.022
Time: 6 Σεπ 2016 11:25:36 πμ
How can I resolve this ?
Finally the problem came from SSL certificate. Alfresco in order to make https url connection should trust the ssl certificate. You can add an SSL in Alfresco/java folder with the following command:
keytool -import -alias test.com -file ../test.cer -keystore ../lib/security/cacerts
I have two projects.
Java SE based let's say abcAPI.
Dynamic Web Project using tomcat server. let's say abc-web
I followed this tutorial automatically build and include one eclipse project into another to include abcAPI into abc-web. So that I have clear separation between these two. I included all necessary dependencies and API's in abcAPI project as well and I believe when using deployment assembly their shouldn't be any problem because underlying referencing project already has reference to it's libraries and dependencies in its libs folder.
I see no error before execution. But after the project runs and BasicDataSource is called I get this exception.
SEVERE: Servlet.service() for servlet [com.trolix.abcAPI.cbf.SrvStart] in context with path [/abc-web] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.commons.dbcp2.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at com.trolix.abcAPI.dbcon.DBConnection.<init>(DBConnection.java:38)
at com.trolix.abcAPI.dbcon.DBConnection.getInstance(DBConnection.java:51)
at com.trolix.abcAPI.dao.DAOStart.<clinit>(DAOStart.java:19)
at com.trolix.abcAPI.controller.CtrlStart.<init>(CtrlStart.java:14)
at com.trolix.abcAPI.manager.MgrStart.<init>(MgrStart.java:14)
at com.trolix.abcAPI.cbf.SrvStart.doPost(SrvStart.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Uptil now I have tried many things as suggested by SO community i.e.
Delete Server
Clean server
Restart Eclipse
Build Code
Deploy Again
etc.
But nothing has yet worked for me. Please guide!
I got the same error using iIntelliJ IDEA, Maven, Tomcat Server. As figured out the problem was in Artifacts(The dependency was not included to WEB-INF/lib).
To fix it - open Project Structure -> Artifacts -> drag-and-drop commons-* from Available Elements to lib
Linux server with Apache2, Tomcat7, PHP 5.5.10 are all up and running
Got this project where we have a JavaBridge installed for report generation, I have this working like a charm on my windows pc in an xampp environment, but on the server I am getting a ClassNotFoundException.
I can access the JavaBridge directly from the site by:
http://mysite:8080/JavaBridge/java/Java.inc
However from the PHP I keep getting this error of ClassNotFoundException
//getting Java.inc
//acquired Java.incdisplay
//java propertiesIn Java.inc
[[o:Exception]:"java.lang.Exception: CreateInstance failed: new com.nlrt.reportgenerator.ReportGenerator([o:PhpParserString], [o:PhpParserString], [o:PhpParserString]).
Cause: java.lang.ClassNotFoundException: com.nlrt.reportgenerator.ReportGenerator VM: 1.6.0_27#http://java.sun.com/" at:
#-32 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
#-31 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
#-30 java.lang.Class.forName0(Native Method)
#-29 java.lang.Class.forName(Class.java:266)
#-28 php.java.bridge.Util.classForName(Util.java:1518)
#-27 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445)
#-26 php.java.bridge.Request.handleRequest(Request.java:458)
#-25 php.java.bridge.Request.handleOneRequest(Request.java:510)
#-24 php.java.servlet.PhpJavaServlet.handleLocalConnection(PhpJavaServlet.java:202)
#-23 php.java.servlet.PhpJavaServlet.handlePut(PhpJavaServlet.java:250)
#-22 php.java.servlet.PhpJavaServlet.doPut(PhpJavaServlet.java:261)
#-21 javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
#-20 javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
#-19 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
#-18 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
#-17 php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126)
#-16 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
#-15 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
#-14 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
#-13 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
#-12 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
#-11 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) #-10 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) #-9 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) #-8 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) #-7 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) #-6 org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
#-5 org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
#-4 org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
#-3 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
#-2 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
#-1 java.lang.Thread.run(Thread.java:679)
#0 /home/dev/public/sanome.com/public/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(1, NULL, 'T', false)
#1 /home/dev/public/sanome.com/public/java/Java.inc(360): java_Arg->getResult(false)
#2 /home/dev/public/sanome.com/public/java/Java.inc(363): java_Client->getWrappedResult(false)
#3 /home/dev/public/sanome.com/public/java/Java.inc(535): java_Client->getInternalResult()
#4 /home/dev/public/sanome.com/public/java/Java.inc(1930): java_Client->createObject('com.nlrt.report...', Array)
#5 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(139): Java->Java('com.nlrt.report...', '372', '/home/dev/publi...', '{"result_id":"4...')
#6 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(65): FileManager->generateAndStreamPDF('1', '372')
#7 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(43): FileManager->handleGenerateAndStreamPDF()
#8 /home/dev/public/sanome.com/public/report_generation/download_pdf.php(76): FileManager->__construct(Array, '1')
#9 {main}]
//500 Encountered exception while trying to create ReportGenerator
The PHP code that is accessing the required resources is as follows:
try
{
// we'll be using JavaBridge
echo "getting Java.inc";
require_once('../java/Java.inc');// http://sanome.com:8080/JavaBridge/java/Java.inc
echo "acquired Java.inc";
echo "display java properties";
//echo java("java.lang.System")->getProperties();
$reportGenerator = new java("com.nlrt.reportgenerator.ReportGenerator", $st_usage_id, $report_generator_directory, json_encode($results_array));
echo "created reportGenerator";
}
catch(Exception $exception)
{
var_dump($exception) ;//$exception;
}
The required JAR has been packaged and added to the WEB-INF/lib directory of the JavaBridge.
Also the php.ini file has the config
allow_url_include=On
I have even followed these steps but I am having no luck.
javabridge setup/installation issue
From what I have provided can anyone please help me?
Please don't criticize the solution for it was not my design. I am just trying to get it working, while adding to it.
Thank you.
I'm working with servlet + spring. The servlet shows this exception in
ApplicationContext context = new ClassPathXmlApplicationContext("my_config.xml");
This is ecxeption text:
28.08.2013 16:27:36 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [my_spring2] in context
with path [/test_spring2] threw exception [Servlet execution threw an
exception] with root cause java.lang.ClassNotFoundException:
org.springframework.context.support.ClassPathXmlApplicationContext at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at main_package.my_spring.doGet(my_spring.java:34) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source) at java.lang.Thread.run(Unknown Source)
28.08.2013 16:27:59 org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/test_spring2] has started
28.08.2013 16:28:00 org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/test_spring2] is completed
I see that the exception you got is java.lang.ClassNotFoundException
Unless you are involved in dynamic class loading and using the Java Reflection API, chances are that the ClassNotFoundException error you are getting is not from your application code but from a referencing API. Another common problem pattern is a wrong packaging of your application code.
Check to see if all the jars are added to your classpath.
Also some jars depend on other jars for their working. In that case you will have to add those jars too !
look at the line 34 in main_package.my_spring.doGet(my_spring.java:34) and see if it is referenced from local class or from an API?
If project-> build automatically is on on your eclipse if using eclipse, then you must be having class file, else you might see errors in the explorer.
most probably the class that you are referencing is from an API, if not try add jars from your project build path.
This question already has answers here:
How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception
(13 answers)
Closed 7 years ago.
So I have a .jar file for the MySQL JDBC driver, it is under my libraries source folder and I have the following code:
public static Connection getConnection() throws SQLException {
Connection conn = null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://50.56.81.42:3306/GUEST_BOOK";
String user = "user";
String password = "pass";
conn = (Connection) DriverManager.getConnection(url, user, password);
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(InstantiationException e){
e.printStackTrace();
}catch(IllegalAccessException e){
e.printStackTrace();
}
return conn;
}
However, it always gives me this error:
INFO: Server startup in 645 ms
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at gbook.DbHelper.getConnection(DbHelper.java:14)
at gbook.DbHelper.getGuestBook(DbHelper.java:51)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Dec 1, 2011 1:41:05 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/JDBC-MySQL] threw exception [javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Connection] with root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Connection
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at gbook.DbHelper.getGuestBook(DbHelper.java:52)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Here's how I added the jar file. I created a lib folder and put the jar inside and then I go to configure build path in eclipse and added the jar inside the lib folder to the project.
You missed mysql-connector-j jar file in your classpath. Use "java -cp .:mysql.jar...". Ou. It's a webapp! Then put mysql jar file to WEB-INF/lib folder.
Right click Libraries ->Add JAR/Folder and choose mysql-connector-java.jar file
if you are using Apache Tomcat, you may have to add the driver to the path using "Configure Tomcat" in Java Tab.