I have a strange problem regarding TomEE and using a DataSource specified in tomee.xml.
It might be worth noting that I'm using Netbeans, TomEE and MySQL. Running on Ubuntu 13.04 (Xubuntu latest)
The tomee.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<Resource id="booktablesDS" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql:localhost:3306/book_tables
UserName juser
Password jpassword
JtaManaged true
</Resource>
</tomee>
And a small codesnippet, testing the connection pool:
#Resource DataSource booktablesDS;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
Connection c = booktablesDS.getConnection();
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM BOOKS");
The output I'm getting from TomEE is:
SEVERE: null
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
Full stacktrace follows.
May 06, 2013 11:08:53 AM org.apache.catalina.util.LifecycleBase start
INFO: The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/EJBTest]] after start() had already been called. The second call will be ignored.
May 06, 2013 11:08:54 AM MainS processRequest
SEVERE: null
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at MainS.processRequest(MainS.java:35)
at MainS.doGet(MainS.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
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:472)
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)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:524)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:493)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:273)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 22 more
May 06, 2013 11:08:55 AM org.apache.catalina.startup.HostConfig deleteRedeployResources
INFO: Undeploying context [/EJBTest]
Basicly it feels like netbeans is deploying the project with another tomee.xml file? Disregarding the values in my tomee.xml, which is under tom-ee/conf/tomee.xml
Help would be awesome.
Looks like your url is wrong.
jdbc:mysql:localhost:3306/book_tables
should be
jdbc:mysql://localhost:3306/book_tables
Can you double-check whether the MySQL driver JAR is really there in tomee/lib folder.
Try to change your code like this:
#Resource(name = "booktablesDS", type = javax.sql.DataSource.class)
DataSource booktablesDS;
Related
My mission is to connect Tomcat 7 to remote IBM MQ. I try create JNDI Resource in server.xml file but it doesn't work. I used example from.
Addinatinaly i added in this example username and password. But there is error when i call JNDI resource from java code.
<Resource
name="jms/MyQCF"
auth="Container"
type="com.ibm.mq.jms.MQQueueConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="<mymqserver>"
PORT="1414"
CHAN="<mychannel>"
TRAN="1"
QMGR="<myqueuemanager>"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="<myqueue>"/>
I've downloaded all required *.jars from [IBM sphere]/lib/java to Tomcat lib folder. Help me please, mb i'm doing somethink wrong. Maybe i need some IBM Client, but i don't know what is it.
Edit:
The error stacktrace
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
VERSION OF IBM MQ LIBS IS:
Implementation-Version: 7.0.1.8 - k701-108-120201
My current Resource in server.xml is:
<Resource
name="jms/MyQCF"
auth="Container"
type="org.springframework.jms.connection.CachingConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="192.168.204.73"
PORT="1415"
username="***"
password="***"
CHAN="JAVA.CHANNEL"
TRAN="1"
QMGR="U.SEND"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="U.RECEIVE"/>
My java code:
System.out.println("servlet page*****************");
Context ctx = null;
try {
ctx = (Context) new InitialContext().lookup("java:comp/env");
System.out.println("ctx: " + ctx);
} catch (NamingException e) {
e.printStackTrace();
}
QueueConnectionFactory qcf = null;
try {
qcf = (QueueConnectionFactory) ctx.lookup("jms/MyQCF");
System.out.println("qcf: " + qcf);
} catch (NamingException e) {
e.printStackTrace();
}
My stacktrace:
servlet page*****************
ctx: org.apache.naming.NamingContext#463b1a3e
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at kz.lalafa.MyServlet.doPost(MyServlet.java:45)
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:310)
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)
My Tomcat lib folder contains:
annotations-api.jar
fscontext.jar
catalina-ant.jar
geronimo-j2ee-management_1.1_spec-1.0.1.jar
catalina-ha.jar
geronimo-jms_1.1_spec-1.1.1.jar
catalina.jar
jasper-el.jar
catalina-tribes.jar
jasper.jar
CL3Export.jar
jms.jar
CL3Nonexport.jar
jndi.jar
com.ibm.mq.commonservices.jar
jsp-api.jar
com.ibm.mq.defaultconfig.jar
jta.jar
com.ibm.mqetclient.jar
ldap.jar
com.ibm.mq.headers.jar
providerutil.jar
com.ibm.mq.jar
rmm.jar
com.ibm.mq.jmqi.jar
servlet-api.jar
com.ibm.mqjms.jar
tomcat-api.jar
com.ibm.mq.jms.Nojndi.jar
tomcat-coyote.jar
com.ibm.mq.pcf.jar
tomcat-dbcp.jar
com.ibm.mq.postcard.jar
tomcat-i18n-es.jar
com.ibm.mq.soap.jar
tomcat-i18n-fr.jar
com.ibm.mq.tools.ras.jar
tomcat-i18n-ja.jar
connector.jar
tomcat-jdbc.jar
dhbcore.jar
tomcat-util.jar
ecj-4.2.2.jar
wmq.jmsra.rar
el-api.jar
My web.xml:
<?xml version='1.0' encoding='utf-8'?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-env-ref>
<resource-env-ref-name>jms/MyQCF</resource-env-ref-name>
<resource-env-ref-type>javax.jms.QueueConnectionFactory</resource-env-ref-type>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>jms/MyQ</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
</web-app>
I just decided to use Spring Boot for this - https://github.com/lzp4ever/IBM_WebSphere_MQ_Spring_Boot_JMS.
But i got new problem. My new problem at this link: multiple jms connection factory
I'm having an OpenShift site which is trying to connect to an external MySQL server. Below is the code I have so far.
public class BaseDAO {
static final String DB_DRIVER = "com.mysql.jdbc.Driver";
DataSource datasource;
public BaseDAO() {
System.out.println("+++++ " +Calendar.getInstance().getTime());
try{
InitialContext ic = new InitialContext();
Context initialContext = (Context) ic.lookup("java:comp/env");
datasource = (DataSource) initialContext.lookup("jdbc/MySQLDS");
Class.forName(DB_DRIVER).newInstance();
} catch(Exception e){
e.printStackTrace();
throw new RuntimeException(e.getCause());
}
}
}
All my DAO classes extend the BaseDAO so I won't have to type all of this 5-6 times.
After some configuration, this does work on a local MySQL server. I have created a small application that either sends me to the index.jsp when the array gathered from the database is not null or not empty, and sends me to the about.jsp if it either is empty or null.
Now in both the local and the external database I have create a table with the same name, column 'day' and inserted 1 value. When I run this locally it sends me to the index page, but when I run this via my OpenShift webpage it sends me to the about page.
This is the error found in the SSH/app-root/logs/jbossews.log (username and serverip commented out)
:
NOTE: THE SERVERIP AND LOGINCREDENTIALS ARE PROVIDED BY THE DATASOURCE OF OPENSHIFT
The path to the DAO is: OpeningsTijdenServlet --> (static)ServiceProvider --> OTService --> OpeningsTijdenDAO (extends BaseDAO)
INFO: Server startup in 10894 ms
+++++ Mon Oct 12 16:07:51 EDT 2015
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user '<<USERNAME>>'#'SERVERIP' (using password: YES))
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1551)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1390)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1046)
at main.java.database.OpeningsTijdenDAO.selectTijden(OpeningsTijdenDAO.java:16)
at main.java.database.OTService.getTijden(OTService.java:13)
at main.java.servlets.GetTijdenServlet.doPost(GetTijdenServlet.java:17)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1042)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLException: Access denied for user '<<USERNAME>>'#'SERVERNAME' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)
Something wrong with your credential. try to change credential or server configuration.
Any of the hosting server you have to select "localhost"/"127.0.0.1" as your DB Host.
I keep getting the following error messages in the catalina.out log on tomcat 7 and i just cant find the source:
java.lang.ClassNotFoundException: play.db.jpa.JPABase
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(Unknown Source)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:150)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
at my.task.task.model.RequestLogManager.add(RequestLogManager.java:44)
at my.task.task.control.RequestLogFilter.logRequest(RequestLogFilter.java:48)
at my.task.task.control.RequestLogFilter.doFilter(RequestLogFilter.java:31)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at my.task.task.control.LoginFilter.doFilter(LoginFilter.java:26)
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:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
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.Http11AprProcessor.process(Http11AprProcessor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1773)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I iam using hibernate 3 and JSF 2 with Mysql server.
In no point i used the play framework.
the exception isn't causing persistence issues, all the transactions are commited in data base. so its actually more annoying then a problem, but i just cant stand having an error message without knowing the source and cleaning my logs.
the code causeing the error is:
public int add(RequestLogBean request) {
if (request.getUserName() == null || request.getUserName().isEmpty()) {
throw new IllegalArgumentException("Missing request user name");
}
int result = -1;
Session session = this.getFactory().openSession();
try {
session.beginTransaction();
result = (Integer) session.save(request);
session.getTransaction().commit();
} catch(HibernateException e) {
if(session.getTransaction() != null) {
session.getTransaction().rollback();
}
e.printStackTrace();
return -1;
} finally {
session.close();
}
return result;
}
at the commit()
I have looked into:
This post
but my case is different i'm not using jBoss but tomcat.
I added to my pom.xml
<dependency>
<groupId>com.google.code.maven-play-plugin.org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.10.Final-patched-play-1.2.5</version>
<scope>compile</scope>
</dependency>
and i know for sure my maven dependencies are added to my classpath.
What is play.db.jpa.JPABase Class used for?
I read that it a base class for any jpa impl on play framework, but i dont even have it installed on my computer.....
Any help will be appreciated.
If you don't use Play, there is no reason to use an artefact with the groupId com.google.code.maven-play-plugin.org.hibernate. This is probably a version of hibernate-core that has been forked and modified to use with the Play framework.
Use the real hibernate core: org.hibernate:hibernate-core.
Consider the following code:
m_Writer = new PrintWriter(new FileWriter("LoginHistory.dat"));
m_Writer.println(Integer.toString(s_NumOfLogins));
m_Writer.println(m_LoginHistoryStr);
m_Writer.close();
Any ideas why I don't find any file called LoginHistory.dat?
Thanks
Update: I've just found that I get an exception after line:
m_Writer = new PrintWriter(new FileWriter("LoginHistory.dat"));
and its details are:
Any ideas what is the real problem?
Listening for transport dt_shmem at address: tomcat_shared_memory_id
27/05/2012 15:52:17 org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/SignInAndGetIp]
27/05/2012 15:52:17 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor SignInAndGetIp.xml from C:\Users\user\.netbeans\7.1.2\apache-tomcat-7.0.22.0_base\conf\Catalina\localhost
27/05/2012 15:52:17 org.apache.catalina.util.LifecycleBase start
INFO: The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SignInAndGetIp]] after start() had already been called. The second call will be ignored.
java.io.FileNotFoundException: LoginHistory.dat (Access denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
at java.io.FileWriter.<init>(FileWriter.java:46)
at signIn.SignInAndShowIPTableServlet.init(SignInAndShowIPTableServlet.java:60)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1228)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1147)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:836)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
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:304)
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:662)
It seems plain that you don't have permission to create that file where you're trying to create it, hence the "Access denied" message. You'd need to find a directory where you're allowed to create files. If you're not sure where a file is going to be created, you can see its full path with File.getAbsolutePath() or File.getCanonicalPath().
The following code:
#POST
#Path("/previous-status/{current}")
#Consumes(MediaType.APPLICATION_XML)
#Produces(MediaType.TEXT_PLAIN)
public String getPreviousStepStatus(#PathParam("current") JAXBElement<WorkflowStep> step) {
WorkflowStep wfStep = step.getValue();
return DBAccessor.getPrevStepStatus(wfStep);
}
Produces the following exception:
javax.servlet.ServletException: Servlet.init() for servlet Jersey Rest Service threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:662)
root cause
com.sun.jersey.spi.inject.Errors$ErrorMessagesException
com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:771)
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:766)
com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:488)
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:609)
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
javax.servlet.GenericServlet.init(GenericServlet.java:160)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:662)
If it is commented I don't get the exception. The currently used libraries in the web application are:
asm-3.1.jar
jersey-core-1.11.jar
jersey-server-1.11.jar
jsr311-api-1.1.1.jar
jersey-servlet-1.11.jar
activation.jar (part of jaxb distribution)
jaxb-api.jar
jaxb-impl.jar
stax-api-1.0.1.jar
woodstox-core-asl-4.1.2.jar
The reason I have included the last 5 libraries in the list is this article from developer works
Furthermore from the tomcat start up log I see the following:
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public java.lang.String restful.SilverLine.getPreviousStepStatus(javax.xml.bind.JAXBElement) at parameter at index 0
SEVERE: Method, public java.lang.String restful.SilverLine.getPreviousStepStatus(javax.xml.bind.JAXBElement), annotated with POST of resource, class restful.SilverLine, is not recognized as valid resource method.
Any ideas will be appreciated?
PathParameter and entity is something different, try following:
#POST
#Path("/previous-status/{order}")
#Consumes(MediaType.APPLICATION_XML)
#Produces(MediaType.TEXT_PLAIN)
public String getPreviousStepStatus(#PathParam("order") int order, JAXBElement<WorkflowStep> step) {
...
WorkflowStep wfStep = step.getValue();
return DBAccessor.getPrevStepStatus(wfStep);
}
in this case, you can do requests like POST http://host/previous-status/10 and put whatever you want into entity.
You had xml in path param (which is part of URL), which is not possible to use. Your request would look like POST http://host/previous-status/<some-xml><foo>bar</foo></some-xml > , which is .. not good idea and not supported.
You should take a look at Jersey user guide: http://jersey.java.net/nonav/documentation/latest/ , topics like path param injection, accessing entity and working with XML are well covered there.