I am working on a Spring MVC app in which I am creating a route containing a list of route stop objects. Following is my RouteModel class:
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
#Entity
#Table(name="Route")
public class RouteModel {
#Id
#Column(name="routeid")
#GeneratedValue
private int routeId;
#Column(name="routename")
private String routeName;
#Column(name="routedesc")
private String routeDesc;
#OneToMany(mappedBy = "routeModel")
#Cascade({CascadeType.ALL})
private List<RouteStopModel> routeStopList;
}
and RouteStopModel:
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
#Entity
#Table(name="RouteStop")
public class RouteStopModel {
#Id
#Column(name="routestopid")
#GeneratedValue
private int routeStopId;
#Column(name="routestopname")
private String routeStopName;
#Column(name="routestopdesc")
private String routeStopDescription;
#ManyToOne
#JoinColumn(name="routeid")
private RouteModel routeModel;
#Column(name="locationid")
private int locationId;
}
After setting, rout stop list, following dao code I am using to persist route model and routestop list:
session.persist(routeModel);
But I am getting following exception:
org.hibernate.PersistentObjectException: detached entity passed to persist: com.bizmerlin.scm.model.RouteModel
23:11:59,058 ERROR [stderr] (http--127.0.0.1-9090-4) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:141)
23:11:59,058 ERROR [stderr] (http--127.0.0.1-9090-4) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:78)
23:11:59,074 ERROR [stderr] (http--127.0.0.1-9090-4) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:772)
23:11:59,074 ERROR [stderr] (http--127.0.0.1-9090-4) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:746)
23:11:59,089 ERROR [stderr] (http--127.0.0.1-9090-4) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:750)
23:11:59,089 ERROR [stderr] (http--127.0.0.1-9090-4) at com.bizmerlin.scm.dao.RouteDao.updateRoute(RouteDao.java:64)
23:11:59,089 ERROR [stderr] (http--127.0.0.1-9090-4) at com.bizmerlin.scm.dao.RouteDao$$FastClassByCGLIB$$71cea667.invoke(<generated>)
23:11:59,105 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
23:11:59,105 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:713)
23:11:59,121 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
23:11:59,121 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
23:11:59,136 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
23:11:59,136 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
23:11:59,152 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
23:11:59,152 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:646)
23:11:59,167 ERROR [stderr] (http--127.0.0.1-9090-4) at com.bizmerlin.scm.dao.RouteDao$$EnhancerByCGLIB$$da879638.updateRoute(<generated>)
23:11:59,183 ERROR [stderr] (http--127.0.0.1-9090-4) at com.bizmerlin.scm.services.RouteService.updateRoute(RouteService.java:40)
23:11:59,199 ERROR [stderr] (http--127.0.0.1-9090-4) at com.bizmerlin.scm.controller.RouteController.editRoute(RouteController.java:115)
23:11:59,214 ERROR [stderr] (http--127.0.0.1-9090-4) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
23:11:59,214 ERROR [stderr] (http--127.0.0.1-9090-4) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
23:11:59,214 ERROR [stderr] (http--127.0.0.1-9090-4) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
23:11:59,230 ERROR [stderr] (http--127.0.0.1-9090-4) at java.lang.reflect.Method.invoke(Method.java:606)
23:11:59,230 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
23:11:59,246 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
23:11:59,261 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
23:11:59,261 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748)
23:11:59,277 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
23:11:59,277 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
23:11:59,292 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
23:11:59,292 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
23:11:59,308 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
23:11:59,308 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
23:11:59,308 ERROR [stderr] (http--127.0.0.1-9090-4) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
23:11:59,324 ERROR [stderr] (http--127.0.0.1-9090-4) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
23:11:59,324 ERROR [stderr] (http--127.0.0.1-9090-4) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
23:11:59,339 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
23:11:59,339 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
23:11:59,355 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
23:11:59,355 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
23:11:59,371 ERROR [stderr] (http--127.0.0.1-9090-4) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
23:11:59,371 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
23:11:59,386 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
23:11:59,386 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
23:11:59,402 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
23:11:59,433 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
23:11:59,464 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
23:11:59,464 ERROR [stderr] (http--127.0.0.1-9090-4) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
23:11:59,480 ERROR [stderr] (http--127.0.0.1-9090-4) at java.lang.Thread.run(Thread.java:744)
try put CascadeType.ALL annotation in your entity
#ManyToOne(cascade = CascadeType.ALL)
#JoinColumn(name="routeid")
private RouteModel routeModel;
Related
HEELP!!
I have a problem running the code, it does not execute the Sql statement and I cannot locate the error between the DAO class and the rest service.
I already added the exceptions of SQLException and ClassNotFound in the DAO class but I still cannot locate the error, and I already executed the code in a separate class and if the request of the BD returns, which means that the driver is well configured.
package com.DAO;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.connection.ConexionPSQL;
import com.IDAO.EmployeIDAO;
import com.model.EmployeObject;
public class EmployeDAO implements EmployeIDAO {
#Override
public List<EmployeObject> obtener() {
Connection co = null;
Statement stm = null;
ResultSet rs = null;
String sql = "SELECT * FROM TABLE_EMPLOYES";
List<EmployeObject> listaCliente = new
ArrayList<EmployeObject>();
try {
co = ConexionPSQL.crearConexion();
stm = co.createStatement();
rs = stm.executeQuery(sql);
while (rs.next()) {
EmployeObject e = new EmployeObject();
e.setId(rs.getInt(1));
e.setNombre(rs.getString(2));
e.setApellido(rs.getString(3));
listaCliente.add(e);
}
stm.close();
rs.close();
co.close();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return listaCliente;
}
}
`` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` `
package com.IDAO;
import java.util.List;
import com.model.EmployeObject;
public interface EmployeIDAO {
public boolean registrar(EmployeObject employe);
public List<EmployeObject> obtener();
public boolean actualizar(EmployeObject employe);
public boolean eliminar(EmployeObject employe);
}
`` ``` ``` ``` ``` ``` ``` ``` ``` ```
package REST;
import java.util.List;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import com.DAO.EmployeDAO;
import com.model.EmployeObject;
import javax.ws.rs.Produces;
// http://localhost:8080/RestService/resources/MyRestService/verEmpleados
#GET
#Path("/verEmpleados")
#Produces(MediaType.APPLICATION_JSON)
public List<EmployeObject> VerEmpleado() {
List<EmployeObject> verEmpleados = empleados.obtener();
return verEmpleados;
}
`` ``` ``` ``` ``` ``` ``` ``` ``` ```
I hope I can help, thank you very much
Here are the error messages
10:55:27,125 ERROR [stderr] (default task-2) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
10:55:27,125 ERROR [stderr] (default task-2) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
10:55:27,125 ERROR [stderr] (default task-2) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
10:55:27,125 ERROR [stderr] (default task-2) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
10:55:27,126 ERROR [stderr] (default task-2) at java.lang.Class.forName0(Native Method)
10:55:27,126 ERROR [stderr] (default task-2) at java.lang.Class.forName(Unknown Source)
10:55:27,126 ERROR [stderr] (default task-2) at com.connection.ConexionPSQL.crearConexion(ConexionPSQL.java:17)
10:55:27,126 ERROR [stderr] (default task-2) at com.DAO.EmployeDAO.obtener(EmployeDAO.java:55)
10:55:27,127 ERROR [stderr] (default task-2) at REST.RestService.VerEmpleado(RestService.java:46)
10:55:27,127 ERROR [stderr] (default task-2) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:55:27,127 ERROR [stderr] (default task-2) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
10:55:27,127 ERROR [stderr] (default task-2) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
10:55:27,127 ERROR [stderr] (default task-2) at java.lang.reflect.Method.invoke(Unknown Source)
10:55:27,127 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
10:55:27,128 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
10:55:27,128 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
10:55:27,128 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
10:55:27,128 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:406)
10:55:27,129 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:213)
10:55:27,129 ERROR [stderr] (default task-2) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)
10:55:27,129 ERROR [stderr] (default task-2) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
10:55:27,129 ERROR [stderr] (default task-2) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
10:55:27,130 ERROR [stderr] (default task-2) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
10:55:27,130 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
10:55:27,130 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
10:55:27,130 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
10:55:27,130 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
10:55:27,131 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:55:27,131 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
10:55:27,131 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
10:55:27,131 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:55:27,131 ERROR [stderr] (default task-2) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
10:55:27,132 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
10:55:27,132 ERROR [stderr] (default task-2) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
10:55:27,132 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
10:55:27,132 ERROR [stderr] (default task-2) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
10:55:27,134 ERROR [stderr] (default task-2) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
10:55:27,134 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:55:27,134 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
10:55:27,135 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:55:27,135 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
10:55:27,135 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:55:27,135 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
10:55:27,136 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
10:55:27,136 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
10:55:27,136 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
10:55:27,136 ERROR [stderr] (default task-2) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
10:55:27,137 ERROR [stderr] (default task-2) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
10:55:27,137 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
10:55:27,137 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:55:27,137 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:55:27,138 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:55:27,138 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
10:55:27,138 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
10:55:27,138 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
10:55:27,138 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
10:55:27,139 ERROR [stderr] (default task-2) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
10:55:27,139 ERROR [stderr] (default task-2) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
10:55:27,139 ERROR [stderr] (default task-2) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
10:55:27,139 ERROR [stderr] (default task-2) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
10:55:27,139 ERROR [stderr] (default task-2) at java.lang.Thread.run(Unknown Source)
well i created a restful webservice wi th a get method that returns a list of bank transactions based on an account id. the service works fine when i test.
Then i created a restful client in my managedBean. this exceptions pops out when i invoke my webservice.
i tried this method already with a list of all clients (without parameters) and it worked but when i add a parameter to my transactions method the id could not be extracted from my request.
this is my webservice
#Stateless
#Path("/transactions")
public class TransactionWebService {
#EJB
private GestionAccountsLocal local1;
#EJB
private GestionTransactionsLocal local2;
#GET
#Path("/{id}")
#Produces(MediaType.APPLICATION_JSON)
public List<Transaction> getTransactionById(#PathParam(value="id") Integer id)
{
Account account=local1.findAccountByid(id);
return local2.showTransactionByAccount(account);
}
}
this is my restful client
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.json.JsonException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import org.json.JSONArray;
#ManagedBean
#SessionScoped
public class WebServiceTransaction {
private WebTarget webtarget;
private Client client;
private entities.Account account;
private Transaction transaction;
private List<Transaction> transactions;
private static final String base_url= "http://localhost:8383/ebankingWEB/rest/transactions" ;
public WebTarget getWebtarget() {
return webtarget;
}
public void setWebtarget(WebTarget webtarget) {
this.webtarget = webtarget;
}
public Transaction getTransaction() {
return transaction;
}
public void setTransaction(Transaction transaction) {
this.transaction = transaction;
}
public static String getBaseUrl() {
return base_url;
}
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
public WebServiceTransaction() {
client= ClientBuilder.newClient();
webtarget=client.target(base_url).path("id");
}
public List<Transaction> getTransactions() {
return transactions;
}
public void setTransactions(List<Transaction> transactions) {
this.transactions = transactions;
}
public List<Transaction> convertToList (String jsonListString) throws JsonException{
try{
JSONArray jsonList = new JSONArray(jsonListString);
transactions = new ArrayList<Transaction>();
for (int i=0 ; i < jsonList.length();i++){
Transaction transaction = new Transaction(jsonList.get(i).toString());
transactions.add(transaction);
}
return transactions;
}
catch (Exception e) {
throw new JsonException(e.getMessage());
}
}
public List<Transaction> getTransactionsByAccount (Integer id){
try{
WebTarget ressource = webtarget;
ressource.path(MessageFormat.format("{0}" , new Object[]{id}));
String jsonListString = ressource.request(MediaType.APPLICATION_JSON).get(String.class);
return convertToList(jsonListString);
}
catch (Exception e){
String message = "non existant transactions ";
FacesContext.getCurrentInstance()
.addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_INFO,
message, null));
e.printStackTrace();
return new ArrayList<Transaction>();
}
}
public entities.Account getAccount() {
return account;
}
public void setAccount(entities.Account account) {
this.account = account;
}
}
and this is my log
15:51:05,177 WARN [org.jboss.resteasy.core.ExceptionHandler] (default task-26) failed to execute: javax.ws.rs.NotFoundException: Unable to extract parameter from http request: javax.ws.rs.PathParam("id") value is 'id' for public java.util.List webServices.TransactionWebService.getTransactionById(java.lang.Integer)
at org.jboss.resteasy.core.PathParamInjector$1.throwProcessingException(PathParamInjector.java:54) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.StringParameterInjector.extractValue(StringParameterInjector.java:336) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.PathParamInjector.inject(PathParamInjector.java:131) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:89) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:112) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.8.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.8.Final.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]
Caused by: java.lang.NumberFormatException: For input string: "id"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) [rt.jar:1.7.0_75]
at java.lang.Integer.parseInt(Integer.java:492) [rt.jar:1.7.0_75]
at java.lang.Integer.<init>(Integer.java:677) [rt.jar:1.7.0_75]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_75]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_75]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_75]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_75]
at org.jboss.resteasy.core.StringParameterInjector.extractValue(StringParameterInjector.java:319) [resteasy-jaxrs-3.0.8.Final.jar:]
... 38 more
15:51:05,191 ERROR [stderr] (default task-25) javax.ws.rs.NotFoundException: HTTP 404 Not Found
15:51:05,191 ERROR [stderr] (default task-25) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:181)
15:51:05,191 ERROR [stderr] (default task-25) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:154)
15:51:05,191 ERROR [stderr] (default task-25) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:444)
15:51:05,192 ERROR [stderr] (default task-25) at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.get(ClientInvocationBuilder.java:165)
15:51:05,192 ERROR [stderr] (default task-25) at tn.esprit.webServiceData.WebServiceTransaction.getTransactionsByAccount(WebServiceTransaction.java:89)
15:51:05,192 ERROR [stderr] (default task-25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:51:05,192 ERROR [stderr] (default task-25) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
15:51:05,192 ERROR [stderr] (default task-25) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
15:51:05,192 ERROR [stderr] (default task-25) at java.lang.reflect.Method.invoke(Method.java:606)
15:51:05,193 ERROR [stderr] (default task-25) at javax.el.ELUtil.invokeMethod(ELUtil.java:308)
15:51:05,193 ERROR [stderr] (default task-25) at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
15:51:05,193 ERROR [stderr] (default task-25) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
15:51:05,193 ERROR [stderr] (default task-25) at com.sun.el.parser.AstValue.invoke(AstValue.java:269)
15:51:05,193 ERROR [stderr] (default task-25) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
15:51:05,193 ERROR [stderr] (default task-25) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
15:51:05,194 ERROR [stderr] (default task-25) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
15:51:05,194 ERROR [stderr] (default task-25) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
15:51:05,194 ERROR [stderr] (default task-25) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
15:51:05,194 ERROR [stderr] (default task-25) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
15:51:05,194 ERROR [stderr] (default task-25) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
15:51:05,194 ERROR [stderr] (default task-25) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
15:51:05,194 ERROR [stderr] (default task-25) at javax.faces.component.UICommand.broadcast(UICommand.java:315)
15:51:05,195 ERROR [stderr] (default task-25) at javax.faces.component.UIData.broadcast(UIData.java:1108)
15:51:05,195 ERROR [stderr] (default task-25) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
15:51:05,195 ERROR [stderr] (default task-25) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
15:51:05,195 ERROR [stderr] (default task-25) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
15:51:05,195 ERROR [stderr] (default task-25) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
15:51:05,195 ERROR [stderr] (default task-25) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
15:51:05,196 ERROR [stderr] (default task-25) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
15:51:05,196 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
15:51:05,196 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
15:51:05,196 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
15:51:05,196 ERROR [stderr] (default task-25) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
15:51:05,196 ERROR [stderr] (default task-25) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
15:51:05,197 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
15:51:05,197 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
15:51:05,197 ERROR [stderr] (default task-25) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
15:51:05,197 ERROR [stderr] (default task-25) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
15:51:05,197 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
15:51:05,197 ERROR [stderr] (default task-25) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
15:51:05,198 ERROR [stderr] (default task-25) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
15:51:05,198 ERROR [stderr] (default task-25) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
15:51:05,198 ERROR [stderr] (default task-25) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
15:51:05,198 ERROR [stderr] (default task-25) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
15:51:05,198 ERROR [stderr] (default task-25) at java.lang.Thread.run(Thread.java:745)
PS:
i think this line is the issue since it gets the base url but the id is not extracted correctly webtarget=client.target(base_url).path("id");
if you need anything else please let me know.
You configured your Service with
#Path("/{id}")
So you should not mention the path fragment "/id" in your webtaregt in the constructor :
webtarget=client.target(base_url).path("id"); // wrong
webtarget=client.target(base_url); // OK
Ex : considering transaction id=1 exists, check on your webbrowser :
../transactions/id/1 //wrong
../transactions/1 // OK
i corrected my rest client and it worked like a charm.
webtarget=client.target(base_url);
and
WebTarget ressource = webtarget;
ressource = ressource.path(MessageFormat.format("{0}" , new Object[]{id}));
before that , i didn't affect a ressource to my parameter.
I've got a Jax-RS server which is supposed to keep a list of files accessible via ssh that I can then download or stream via HTTP.
I've been trying to read the files with JSch's SFTP channel, but I keep receiving a NullPointerException.
Here's the MessageBodyWriter I wrote:
#Provider
#Produces("video/*")
public class MediaBodyWriter implements MessageBodyWriter<MediaFile> {
#Override
public long getSize(MediaFile mFile, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
return mFile.getFileSize();
}
#Override
public boolean isWriteable(Class<?> type, Type arg1, Annotation[] arg2, MediaType arg3) {
return type.equals(MediaFile.class);
}
#Override
public void writeTo(MediaFile mFile,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
mFile.streamFile(entityStream); //line 41
}
}
Here's MediaFile class minus the getters and setters:
#Entity
#XmlRootElement
public class MediaFile {
#Id
#GeneratedValue
Long id;
#JsonIgnore
#ManyToOne(cascade=CascadeType.ALL)
#PrimaryKeyJoinColumn
MediaRepo repo;
String filePath;
String fileName;
transient JSch jsch;
transient Session session;
transient ChannelSftp sftp;
public MediaFile(){}
public void prepForDownload(){
if(sftp != null)
return;
try{
jsch = new JSch();
session = jsch.getSession(repo.getUsername(), repo.getHost(), repo.getPort());
session.setPassword(repo.getPassword());
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
sftp = (ChannelSftp)session.openChannel("sftp");
}catch(Exception e){
e.printStackTrace();
}
}
public long getFileSize(){
prepForDownload();
try {
return sftp.lstat(getCompletePath()).getSize();
} catch (SftpException e) {
e.printStackTrace();
}
return 0;
}
private String getCompletePath(){
return repo.getBasePath()+filePath+fileName;
}
public void streamFile(OutputStream output){
prepForDownload();
try {
sftp.get(getCompletePath(), output);
} catch (SftpException e) {
e.printStackTrace();
}
}
}
And here's the error I'm receiving:
13:50:05,260 ERROR [stderr] (default task-5) 4:
13:50:05,260 ERROR [stderr] (default task-5) at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1011)
13:50:05,260 ERROR [stderr] (default task-5) at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:984)
13:50:05,261 ERROR [stderr] (default task-5) at model.MediaFile.streamFile(MediaFile.java:75)
13:50:05,261 ERROR [stderr] (default task-5) at MediaBodyWriter.writeTo(MediaBodyWriter.java:41)
13:50:05,261 ERROR [stderr] (default task-5) at MediaBodyWriter.writeTo(MediaBodyWriter.java:1)
13:50:05,261 ERROR [stderr] (default task-5) at MediaBodyWriter$Proxy$_$$_WeldClientProxy.writeTo(Unknown Source)
13:50:05,261 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:131)
13:50:05,261 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.interception.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:60)
13:50:05,262 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:120)
13:50:05,262 ERROR [stderr] (default task-5) at org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.aroundWriteTo(DigitalSigningInterceptor.java:145)
13:50:05,262 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:124)
13:50:05,262 ERROR [stderr] (default task-5) at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100)
13:50:05,262 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:124)
13:50:05,262 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:98)
13:50:05,262 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:466)
13:50:05,263 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:415)
13:50:05,263 ERROR [stderr] (default task-5) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
13:50:05,263 ERROR [stderr] (default task-5) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
13:50:05,263 ERROR [stderr] (default task-5) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
13:50:05,263 ERROR [stderr] (default task-5) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
13:50:05,263 ERROR [stderr] (default task-5) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
13:50:05,263 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
13:50:05,263 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
13:50:05,264 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
13:50:05,264 ERROR [stderr] (default task-5) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
13:50:05,264 ERROR [stderr] (default task-5) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
13:50:05,264 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
13:50:05,264 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
13:50:05,264 ERROR [stderr] (default task-5) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
13:50:05,265 ERROR [stderr] (default task-5) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
13:50:05,265 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
13:50:05,265 ERROR [stderr] (default task-5) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
13:50:05,265 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
13:50:05,265 ERROR [stderr] (default task-5) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
13:50:05,266 ERROR [stderr] (default task-5) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
13:50:05,266 ERROR [stderr] (default task-5) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
13:50:05,266 ERROR [stderr] (default task-5) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
13:50:05,266 ERROR [stderr] (default task-5) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
13:50:05,266 ERROR [stderr] (default task-5) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
13:50:05,266 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
13:50:05,267 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
13:50:05,267 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
13:50:05,267 ERROR [stderr] (default task-5) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
13:50:05,267 ERROR [stderr] (default task-5) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
13:50:05,267 ERROR [stderr] (default task-5) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
13:50:05,267 ERROR [stderr] (default task-5) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
13:50:05,268 ERROR [stderr] (default task-5) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
13:50:05,268 ERROR [stderr] (default task-5) at java.lang.Thread.run(Thread.java:745)
13:50:05,268 ERROR [stderr] (default task-5) Caused by: java.lang.NullPointerException
13:50:05,268 ERROR [stderr] (default task-5) at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:994)
13:50:05,269 ERROR [stderr] (default task-5) ... 47 more
You have to call the .connect() on the ChannelSftp, before you can use it, as all JSch SFTP examples show.
For example, see the official JSch SFTP example:
Channel channel=session.openChannel("sftp");
channel.connect();
ChannelSftp c=(ChannelSftp)channel;
I am trying to search items in a collection, but I end up in a NullPointerException, even though I know that the items are there. This is my code to search the collection:
Collection<Item> newnetSWLicense = CollectionUtils.select(sortedItems, new Predicate() {
public boolean evaluate(Object o) {
Item item = (Item)o;
return item.getVendor().equals("NewNet") && item.getItemType().equals("SW") && item.getDescription().contains("Connect7") ||
item.getVendor().equals("NewNet") && item.getItemType().equals("SW") && item.getDescription().contains("C7");
}
});
Everything works when the description of the item is like:
Connect7 Simplex SGC License
or
Connect7 Redundant SGC License
But when the description contains "C7 3.0 core TCAP 8K dialogs simplex", it returns a NullPointerException:
10:19:41,664 ERROR [STDERR] java.lang.NullPointerException
10:19:41,664 ERROR [STDERR] at org.apache.jsp.View.bom.ListBom_jsp$3.evaluate(ListBom_jsp.java:286)
10:19:41,664 ERROR [STDERR] at org.apache.commons.collections.CollectionUtils.select(CollectionUtils.java:517)
10:19:41,664 ERROR [STDERR] at org.apache.commons.collections.CollectionUtils.select(CollectionUtils.java:498)
10:19:41,664 ERROR [STDERR] at org.apache.jsp.View.bom.ListBom_jsp._jspService(ListBom_jsp.java:283)
10:19:41,664 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
10:19:41,664 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
10:19:41,664 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
10:19:41,664 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
10:19:41,664 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
10:19:41,664 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
10:19:41,664 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
10:19:41,664 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:19:41,664 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
10:19:41,664 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
10:19:41,664 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:19:41,664 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
10:19:41,664 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
10:19:41,665 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
10:19:41,665 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
10:19:41,665 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
10:19:41,665 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
10:19:41,665 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
10:19:41,665 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
10:19:41,665 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
10:19:41,665 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
10:19:41,665 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
10:19:41,665 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
10:19:41,665 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
10:19:41,665 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
10:19:41,665 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
10:19:41,665 ERROR [STDERR] at java.lang.Thread.run(Thread.java:722)
Any idea how to avoid this exception? Btw. vendor and item type are 100% correct.
The issue must be with your code:
return item.getVendor().equals("NewNet") && item.getItemType().equals("SW") &&
item.getDescription().contains("Connect7") ||
item.getVendor().equals("NewNet") && item.getItemType().equals("SW") &&
item.getDescription().contains("C7");
Don't put everything in a single return statement; extract the local vars first for vendor and description. Check the vars for null.
if (item == null) return false;
final String v = item.getVendor(), d = item.getDescription(),
t = item.getItemType();
return d != null && "NewNet".equals(v) && "SW".equals(t) &&
(d.contains("C7") || d.contains("Connect7"));
For some reason I'm getting a javax.mail.internet.ParseException when I call Transport.send() on a MimeMessage. This worked before when it was only a plain text email, but when I changed it to have both text and html it started blowing up. Any ideas what I'm doing wrong?
#Resource(mappedName = "java:/Mail")
private Session mailer;
public void sendMessage(String toEmailAddress, String subject, String content, String text) throws Exception {
try {
Message message = new MimeMessage(mailer);
MimeMultipart rootMixedMultipart = new MimeMultipart("mixed");
message.setContent(rootMixedMultipart);
MimeMultipart nestedRelatedMultipart = new MimeMultipart("related");
MimeBodyPart relatedBodyPart = new MimeBodyPart();
relatedBodyPart.setContent(nestedRelatedMultipart);
rootMixedMultipart.addBodyPart(relatedBodyPart);
MimeMultipart messageBody = new MimeMultipart("alternative");
MimeBodyPart bodyPart = null;
for (int i = 0; i < nestedRelatedMultipart.getCount(); i++) {
BodyPart bp = nestedRelatedMultipart.getBodyPart(i);
if (bp.getFileName() == null) {
bodyPart = (MimeBodyPart) bp;
}
}
if (bodyPart == null) {
MimeBodyPart mimeBodyPart = new MimeBodyPart();
nestedRelatedMultipart.addBodyPart(mimeBodyPart);
bodyPart = mimeBodyPart;
}
bodyPart.setContent(messageBody, "text/alternative");
// Create the plain text part of the message.
MimeBodyPart plainTextPart = new MimeBodyPart();
plainTextPart.setText(text, "UTF-8");
messageBody.addBodyPart(plainTextPart);
// Create the HTML text part of the message.
MimeBodyPart htmlTextPart = new MimeBodyPart();
htmlTextPart.setContent(content, "CONTENT_TYPE_HTML;charset=UTF-8");
messageBody.addBodyPart(htmlTextPart);
message.setFrom(new InternetAddress(NO_REPLY_EMAIL_ADDRESS, PERSONAL));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(toEmailAddress));
message.setSubject(subject);
message.setHeader("Precedence", "bulk");
Transport.send(message);
}
catch (Exception e) {
}
}
Here's the stack trace.
2011-03-03 00:20:05,896 ERROR [STDERR] javax.mail.internet.ParseException
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.ContentType.<init>(ContentType.java:89)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1249)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR] at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,897 ERROR [STDERR] at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,897 ERROR [STDERR] at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2012)
2011-03-03 00:20:05,897 ERROR [STDERR] at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1980)
2011-03-03 00:20:05,897 ERROR [STDERR] at javax.mail.Transport.send(Transport.java:97)
2011-03-03 00:20:05,897 ERROR [STDERR] at com.lawless.manager.NotificationManagerBean.sendMessage(NotificationManagerBean.java:69)
2011-03-03 00:20:05,897 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,897 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,897 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,897 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
2011-03-03 00:20:05,897 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
2011-03-03 00:20:05,898 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
2011-03-03 00:20:05,898 ERROR [STDERR] at $Proxy97.sendMessage(Unknown Source)
2011-03-03 00:20:05,898 ERROR [STDERR] at com.lawless.manager.CommentManagerBean.sendCommentNotification(CommentManagerBean.java:85)
2011-03-03 00:20:05,898 ERROR [STDERR] at com.lawless.manager.CommentManagerBean.addComment(CommentManagerBean.java:44)
2011-03-03 00:20:05,898 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,899 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,899 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,899 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
2011-03-03 00:20:05,900 ERROR [STDERR] at $Proxy100.addComment(Unknown Source)
2011-03-03 00:20:05,900 ERROR [STDERR] at com.lawless.web.ListingAction.addComment(ListingAction.java:97)
2011-03-03 00:20:05,900 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,900 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,900 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,900 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,900 ERROR [STDERR] at net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:442)
2011-03-03 00:20:05,900 ERROR [STDERR] at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.stripesstuff.plugin.security.SecurityInterceptor.interceptEventHandling(SecurityInterceptor.java:188)
2011-03-03 00:20:05,900 ERROR [STDERR] at org.stripesstuff.plugin.security.SecurityInterceptor.intercept(SecurityInterceptor.java:120)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.DispatcherHelper.invokeEventHandler(DispatcherHelper.java:440)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.DispatcherServlet.invokeEventHandler(DispatcherServlet.java:278)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:160)
2011-03-03 00:20:05,901 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.DynamicMappingFilter$2.doFilter(DynamicMappingFilter.java:364)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)
2011-03-03 00:20:05,901 ERROR [STDERR] at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:351)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
2011-03-03 00:20:05,901 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
2011-03-03 00:20:05,902 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
2011-03-03 00:20:05,902 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
Look at
htmlTextPart.setContent(content, "CONTENT_TYPE_HTML;charset=UTF-8");
where you want to reference to a CONTENT_TYPE_HTML, but put is a String into the contenttype parameter. CONTENT_TYPE_HTML is of course not a valid content-type declaration. CONTENT_TYPE_HTML is probably a static final String member of "SomeClass", which equals "text/html", I guess.
Instead use
htmlTextPart.setContent(content, SomeClass.CONTENT_TYPE_HTML+";charset=UTF-8");
to set the content-type to text/html;charset=utf-8. Of course replace SomeClass with the real class where the member CONTENT_TYPE_HTML was defined.
try using the following,
Email.setContent(Object o, String contentType)