Exception while trying to use jersey and jaxb - java

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.

Related

Having a verify error with solrj 5.5.0 and java 1.7

I get a java.lang.VerifyError: Cannot inherit from final class exception when executing HttpSolrClient solr = new HttpSolrClient("http://localhost:8983/solr/mycore");
I use SolrJ 5.5.0 with Java 1.7. Other than that I use commons-httpclient 3.1. This is the detailed error I get:
Handler processing failed; nested exception is java.lang.VerifyError: org/apache/http/params/SyncBasicHttpParams] with root cause
java.lang.VerifyError: org/apache/http/params/SyncBasicHttpParams
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:158)
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:466)
at org.apache.solr.client.solrj.impl.HttpClientUtil.setFollowRedirects(HttpClientUtil.java:290)
at org.apache.solr.client.solrj.impl.HttpClientConfigurer.configure(HttpClientConfigurer.java:58)
at org.apache.solr.client.solrj.impl.HttpClientUtil.configureClient(HttpClientUtil.java:149)
at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:125)
at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:188)
at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:161)
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.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
There were 2 httpcore libs(httpcore 4.0 from axis2 1.6.2 and httpcore 4.4.1 from solrj 5.5.0) in my .m2 folder. Removing httpcore 4.0 helped me to fix the problem. The reason is org.apache.http.params.BasicHttpParams class in httpcore 4.0 is a final class.

Jersey 500 Error NoClassDefFoundError: org/json/JSONException

Before you mark it as DUPLICATE please understand I've checked all the relevant links but to no avail.
I'm calling the following Service.
#Path("/courses")
public class CourseService {
// #GET
// #Produces(MediaType.TEXT_PLAIN)
// public String hello(){
// return "Hello World !!!";
// }
private DataService _service;
public CourseService(String jsonData) throws ParseException, IOException, JSONException {
_service = new DataService(jsonData);
}
#GET
#Produces(MediaType.APPLICATION_XML)
public ArrayList<Course> getAllCourses(){
return _service.get_handler().getAllCourses();
}
}
If I just run the commented portion of the code my application runs fine and produces "Hello World"
But then when I run my actual service it gives me the following error.
type Exception report
message Servlet.init() for servlet Jersey Web Application threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet Jersey Web Application threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
java.lang.NoClassDefFoundError: org/json/JSONException
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
java.lang.Class.getConstructors(Class.java:1651)
org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.<init>(MethodHandler.java:265)
org.glassfish.jersey.server.model.MethodHandler.create(MethodHandler.java:155)
org.glassfish.jersey.server.model.ResourceMethod$Builder.createInvocable(ResourceMethod.java:550)
org.glassfish.jersey.server.model.ResourceMethod$Builder.build(ResourceMethod.java:536)
org.glassfish.jersey.server.model.Resource$Builder.processMethodBuilders(Resource.java:663)
org.glassfish.jersey.server.model.Resource$Builder.buildResourceData(Resource.java:599)
org.glassfish.jersey.server.model.Resource$Builder.build(Resource.java:655)
org.glassfish.jersey.server.model.Resource.from(Resource.java:798)
org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:465)
org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
This is the structure of my Project Directory
I've tested my CourseService using a TestClient and it works fine. What am I doing wrong.
You shouldn't be defining dependencies like that. All your dependencies should be managed with something like maven or gradle. That being said, did you add it the jar to the class path?
Since your using maven, you would want to add this to your <dependencies> section. For example:
<dependencies>
<!-- other dependencies -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<!-- or w.e. version you wanted to use. -->
<!-- See http://mvnrepository.com/artifact/org.json/json-->
<version>20160212</version>
</dependency>
<!-- other dependencies -->
</dependencies>
Eclipse should automatically add dependencies like the one above to your class path.
Check out one of the official tutorials on maven: https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
java.lang.NoClassDefFoundError: org/json/JSONException
Please make sure JSONException is defined and accessible.

Jersey errors after deploying to tomcat, works fine in Eclipse

I've lost hours trying to pinpoint this annoying issue. I've created a simple Java app that exposes a few REST services using Jersey.
When debugging the application in Eclipse, using a Tomcat 8 server, everything works fine. I then export the project to a WAR file, deploy it to a real Tomcat 8 server, and when I try to call the REST services, I get the below error. I've checked the obvious things: making sure I'm using the correct Java version on the server, making sure the libraries are included, ... But alas, I'm stuck.
type Exception report
message Servlet.init() for servlet Jersey REST Service threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet Jersey REST Service threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:309)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:338)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:171)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:363)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
All important libraries for the project are added in the WEB-INF, which are the following:
aopalliance-repackaged-2.4.0-b10.jar
asm-debug-all-5.0.2.jar
commons-beanutils-1.9.2.jar
commons-collections-3.2.1.jar
commons-collections4-4.0.jar
commons-logging-1.2.jar
gson-2.3.1.jar
hk2-api-2.4.0-b10.jar
hk2-locator-2.4.0-b10.jar
hk2-utils-2.4.0-b10.jar
httpclient-4.4.1.jar
httpcore-4.4.1.jar
java-json.jar
javassist-3.18.1-GA.jar
javax.annotation-api-1.2.jar
javax.inject-2.4.0-b10.jar
javax.json-1.0.2.jar
javax.servlet-api-3.0.1.jar
javax.ws.rs-api-2.0.1.jar
jaxb-api-2.2.7.jar
jersey-client-1.7.jar
jersey-client.jar
jersey-common.jar
jersey-container-servlet-core.jar
jersey-container-servlet.jar
jersey-core-1.7.jar
jersey-guava-2.17.jar
jersey-json-1.7.jar
jersey-media-jaxb.jar
jersey-server.jar
joda-time-2.3.jar
log4j-1.2.17.jar
org.osgi.core-4.2.0.jar
org.restlet.ext.gson-2.3.1.jar
org.restlet.ext.json.jar
org.restlet.jar
osgi-resource-locator-1.0.1.jar
persistence-api-1.0.jar
unboundid-ldapsdk-se.jar
validation-api-1.1.0.Final.jar
I believe this is not because of missing jar.. I believe it is class loading issue. The jersey jars are not being loaded (or) might have been loaded the wrong version. Could you please check the dependencies properly and check for duplicate jars for jersey in your application.
Also Please try by undeploying appliation and deploying again.. This might remove all the classes that were already loaded for taht application and Tomcat might intialize class loading again..
Hope this works...

java.lang.ClassNotFoundException: play.db.jpa.JPABase using hibernate

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.

Why FileWriter doesn't create a new file?

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().

Categories

Resources