[Installation, Configuration & DEPLOYMENT] - Re: problem with simple helloworld...PLZ HELP ME
by raffaele.letizia
Thank you John but now i have the same problem in other application. Can you hlep me?Now i upload the program.Thank you
FAQPortlet.java
package com.test;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.MatchMode;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import java.io.IOException;
import java.util.List;
public class FaqPortlet extends GenericPortlet
{
private SessionFactory sessionFactory;
public void init()
{
Configuration config = new Configuration();
config.configure("/WEB-INF/jsp/hibernate.cfg.xml");
this.sessionFactory = config.buildSessionFactory();
}
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
{
String op = request.getParameter("op");
if((op != null) && (op.trim().length() > 0))
{
String key = request.getParameter("key");
String domanda = request.getParameter("domanda");
String risposta = request.getParameter("risposta");
if(op.equalsIgnoreCase("Aggiungi FAQ"))
{
addNewContact(request.getUserPrincipal().getName(),domanda,risposta);
}
else if(op.equalsIgnoreCase("Aggiorna FAQ"))
{
saveContact(key,domanda,risposta);
}
else if(op.equalsIgnoreCase("Cancella FAQ"))
{
deleteContact(key);
}
}
}
public void doView(RenderRequest request, RenderResponse response)
{
try
{
if((request.getUserPrincipal() != null) && (request.getUserPrincipal().getName() != null))
{
String userName = request.getUserPrincipal().getName();
String jspName = null;
if((request.getParameter("op") != null) && (request.getParameter("op").equalsIgnoreCase("Ricerca")))
{
request.setAttribute("contacts", getUsersContacts(userName, request.getParameter("domanda")));
jspName ="/WEB-INF/jsp/list.jsp";
}
else if((request.getParameter("op") != null) && (request.getParameter("op").equalsIgnoreCase("shownew")))
{
jspName ="/WEB-INF/jsp/add.jsp";
}
else if((request.getParameter("op") != null) && (request.getParameter("op").equalsIgnoreCase("edit")))
{
request.setAttribute("contact", findContact(userName, request.getParameter("key")));
jspName ="/WEB-INF/jsp/edit.jsp";
}
else if((request.getParameter("op") != null) && (request.getParameter("op").equalsIgnoreCase("delete")))
{
request.setAttribute("contact", findContact(userName, request.getParameter("key")));
jspName ="/WEB-INF/jsp/delete.jsp";
}
else
{
request.setAttribute("contacts", getUsersContacts(userName));
jspName ="/WEB-INF/jsp/list.jsp";
}
response.setContentType("text/html");
PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(jspName);
prd.include(request, response);
}
else
{
response.setContentType("text/html");
PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/notloggedin.jsp");
prd.include(request, response);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
private List getUsersContacts(String userName)
{
Session session = this.sessionFactory.openSession();
Criteria criteria = session.createCriteria(Faq.class);
criteria.add(Expression.eq("userName", userName));
List contacts = criteria.list();
session.disconnect();
return contacts;
}
private List getUsersContacts(String userName, String name)
{
Session session = this.sessionFactory.openSession();
Criteria criteria = session.createCriteria(Faq.class);
criteria.add(Expression.eq("userName", userName));
criteria.add(Expression.like("domanda", name, MatchMode.ANYWHERE));
List contacts = criteria.list();
session.disconnect();
return contacts;
}
private void addNewContact(String userName, String domanda1, String risposta1)
{
Session session = this.sessionFactory.openSession();
Transaction t = session.beginTransaction();
try
{
Faq faq = new Faq(userName);
faq.setDomanda(domanda1);
faq.setRisposta(risposta1);
session.save(faq);
t.commit();
}
catch(Exception e)
{
t.rollback();
}
finally
{
if(session != null)
{
session.disconnect();
}
}
}
private Faq findContact(String userName, String id)
{
Session session = this.sessionFactory.openSession();
Criteria criteria = session.createCriteria(Faq.class);
criteria.add(Expression.eq("userName", userName));
criteria.add(Expression.eq("key", new Long(id)));
List contacts = criteria.list();
session.disconnect();
if(contacts.size() == 1)
{
return (Faq) contacts.get(0);
}
return null;
}
private void saveContact(String key, String domanda2, String risposta2)
{
Session session = this.sessionFactory.openSession();
Transaction t = session.beginTransaction();
try
{
Faq faq = (Faq) session.load(Faq.class, new Long(key));
faq.setDomanda(domanda2);
faq.setRisposta(risposta2);
session.update(faq);
t.commit();
}
catch(Exception e)
{
t.rollback();
}
finally
{
if(session != null)
{
session.disconnect();
}
}
}
private void deleteContact(String key)
{
Session session = this.sessionFactory.openSession();
Transaction t = session.beginTransaction();
try
{
Faq contact = (Faq) session.load(Faq.class, new Long(key));
session.delete(contact);
t.commit();
}
catch(Exception e)
{
t.rollback();
}
finally
{
if(session != null)
{
session.disconnect();
}
}
}
}
Faq.java
package com.test;
public class Faq
{
protected Long key;
protected String userName;
protected String domanda;
protected String risposta;
public Faq()
{
key = null;
userName= null;
domanda= null;
risposta= null;
}
public Faq(String userName)
{
key = null;
this.userName = userName;
domanda = null;
risposta = null;
}
public Long getKey()
{
return key;
}
public void setKey(Long key)
{
this.key = key;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public Long getId()
{
return key;
}
public String getUserName()
{
return userName;
}
public String getDomanda()
{
return domanda;
}
public void setDomanda(String domanda)
{
this.domanda = domanda;
}
public String getRisposta()
{
return risposta;
}
public void setRisposta(String risposta)
{
this.risposta = risposta;
}
}
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
jdbc:mysql://localhost:3306/faq
root
com.mysql.jdbc.Driver
org.hibernate.dialect.MySQLDialect
einstein
org.hibernate.transaction.JDBCTransactionFactory
<!-- thread is the short name for
org.hibernate.context.ThreadLocalSessionContext
and let Hibernate bind the session automatically to the thread
-->
thread
<!-- this will show us all sql statements -->
true
<!-- mapping files -->
</session-factory>
</hibernate-configuration>
domain.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
faq_seq
</hibernate-mapping>
the error generated is:
09:47:43,337 ERROR [LifeCycle] Cannot start object
org.jboss.portal.portlet.container.PortletInitializationException: The portlet FaqPortlet threw a runtime exception during init
at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:288)
at org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle.invokeStart(PortletContainerLifeCycle.java:76)
at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:92)
at org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:351)
at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:128)
at org.jboss.portal.portlet.mc.PortletApplicationDeployment.install(PortletApplicationDeployment.java:152)
at org.jboss.portal.portlet.mc.PortletApplicationDeployer.add(PortletApplicationDeployer.java:186)
at org.jboss.portal.portlet.mc.PortletApplicationDeployer.onEvent(PortletApplicationDeployer.java:155)
at org.jboss.portal.web.impl.DefaultServletContainer.safeFireEvent(DefaultServletContainer.java:146)
at org.jboss.portal.web.impl.DefaultServletContainer.fireEvent(DefaultServletContainer.java:158)
at org.jboss.portal.web.impl.DefaultServletContainer.access$400(DefaultServletContainer.java:53)
at org.jboss.portal.web.impl.DefaultServletContainer$RegistrationImpl.registerWebApp(DefaultServletContainer.java:242)
at org.jboss.portal.web.impl.tomcat.TC6ServletContainerContext.start(TC6ServletContainerContext.java:282)
at org.jboss.portal.web.impl.tomcat.TC6ServletContainerContext.registerContext(TC6ServletContainerContext.java:247)
at org.jboss.portal.web.impl.tomcat.TC6ServletContainerContext.containerEvent(TC6ServletContainerContext.java:122)
at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1361)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:803)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
at org.jboss.web.WebModule.startModule(WebModule.java:83)
at org.jboss.web.WebModule.startService(WebModule.java:61)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:417)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy44.start(Unknown Source)
at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy45.start(Unknown Source)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy9.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
Caused by: java.lang.ClassCastException: com.test.FaqPortlet
at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:254)
... 99 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4203523#4203523
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4203523
17 years, 3 months
[JBossMQ] - Job offer to debug
by b.eckenfels
Hello,
we are hit by the Problem that a MDB (30 parallel) stops processing a queue without any real log message. We use EJB2 CMP Beans in the onMessage() Transaction with a XA Datasource and Oracle.
After a random (not so easy reproduceable) time the Bean stops processing messaes. When I take a Thread dump I see no Threads in the onMessage() methode (i.e. the processing is not deadlocked) and the JMX Bean tells me all 30 Instances are used up.
There might be some regular Exceptions in the commit phase (like timeouts), but most often they do not happen directly at the point of problem.
Anyway, so this is an overview of the problem. In order to secure a quick fix (reading this forum it looks like it is not uncommon) we would like to pay a developer to look into this and try to fix it. Please contact me directly and provide me with credentials that you could work on this.
It happens with different JBoss 4.2 Versions Java 5 and 6 and JBossMQ. We are also looking into JBM in parallel but for various reasons it is not so easy for us to switch.
Greetings
Bernd
PS: bernd-jboss(a)eckenfels.net for the contact
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4203516#4203516
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4203516
17 years, 3 months
[Beginners Corner] - non-HTTP Request Exception on a simple request
by smanero.onjob@gmail.com
Hello,
I'm testing a simple request POST to a servlet in a well-deployed war (unless in the logs and console it's so told). I have tested these environments:
ENV1 : jdk1.6.11 | jboss-5.0.0.CR2 | run.bat -c default : Here everything is all right, i have got my "hello, newbie"
ENV2 : jdk1.6.11 | jboss-5.0.0.GA | JAVA_OPTS and tips in release notes | run.bat -c default : This has a bizarre behaviour because i get
javax.servlet.ServletException: non-HTTP request or response
at javax.servlet.http.HttpServlet.service(HttpServlet.java:800)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Maybe it's a question of some configuration options, but i don't find anything conclusive. Could you give me some hint? Thanks a lot.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4203513#4203513
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4203513
17 years, 3 months