[Datasource Configuration] - ClassCastException
by Pierre Guillemot
Pierre Guillemot [https://community.jboss.org/people/hnb] created the discussion
"ClassCastException"
To view the discussion, visit: https://community.jboss.org/message/715961#715961
--------------------------------------------------------------
Hello there,
i am new to JBoss AS, i am currently using JBoss AS6.0 final, MySQL and Netbeans 7.1.
I finally managed to configure the MySqlDS.xml and persistence.xml, i can see in the logs that the PU is read and all, the database is accessed, everything is working.
In order to try my datasource access in created a simple servlet :
@WebServlet(name = "Test", urlPatterns = {"/Test"})
public class Test extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
/*
* TODO output your page here. You may use following sample code.
*/
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Test</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet Test at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
Context context;
try {
context = new InitialContext();
DataSource data = (DataSource)context.lookup("java:/MySqlDs");
} catch (NamingException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
}
} finally {
out.close();
}
}
Except that in have this error :
23:01:32,412 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/YouFoodInc].[Test]] "Servlet.service()" pour la servlet Test a généré une exception: java.lang.ClassCastException: org.jboss.jpa.injection.InjectedEntityManagerFactory cannot be cast to javax.sql.DataSource
at Test.processRequest(Test.java:57) at Test.doGet(Test.java:80) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [:1.0.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]
at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]
at java.lang.Thread.run(Unknown Source) [:1.6.0_27]
I added the mysql-connector-java-5.1.13-bin.jar inside the serverd/default/lib. And I have not added anything else inside the lib folder.
I already did this kind of thing using GlassFish 3.0, and i never had any issues.
If you need any other informations, please tell me. Thank you for your attention,
Regards,
Pierre.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/715961#715961]
Start a new discussion in Datasource Configuration at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years, 1 month
[jBPM] - jBPM for web
by nt2005
nt2005 [https://community.jboss.org/people/nt2005] created the discussion
"jBPM for web"
To view the discussion, visit: https://community.jboss.org/message/717282#717282
--------------------------------------------------------------
Hey Guys,
English:
I am working on a web page where a user can start his own processes.
I use an stateful (ScopeType.Session) bean (Seam 2.2.2).
When the user open the site his ksession gets loaded:
@Create
public void initSession() {
EntityManagerFactory emf = entityManager.getEntityManagerFactory();
....
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
....
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(usersession.getSessionid(), kbase, null, env);
}
Than the user starts a process. When the process needs more time for calculation, my bean is not responding to my jsf-page. Because the thread is in the methode of startProcess().
My question is now: How I can run a process but also can interact with my jsf-page?
What seam components/types would be better or should I add? (ScopeType.Application maybe?) Anyone any idea?
I am not very firm in Seam.
I hope you understand my questions. If not, please ask! Thank you.
Deutsch:
Ich arbeite an einer Webseite, in der Benutzer eigene Prozesse starten können.
Wenn ein Benutzer die Seite das erste Mal öffnet, wird seine eigene ksession geladen.
@Create
public void initSession() {
EntityManagerFactory emf = entityManager.getEntityManagerFactory();
....
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
....
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(usersession.getSessionid(), kbase, null, env);
}
Wenn ein Benutzer einen Prozess startet, der mehr Berechnungszeit braucht, antwortet logischerweise auch mein Bean nicht auf die Jsf-Anfragen meiner Seite. Da ja mein Bean zurzeit im startProcess() hängt.
Meine Frage ist nun, wie ich einen Prozess starten kann und mit den Bean dennoch normal weiter arbeiten kann.
Ich kenn mich mit Seam nicht wirklich gut aus aber muss ich da eventuell noch andere Seam Bean Komponenten mit einfügen (ScopeType.Application)?
Habt ihr eine Idee? Wenn noch fragen sind, bitte fragen.
Danke!
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/717282#717282]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years, 1 month
[IronJacamar] - external activation not working for resource adapater
by Frank Langelage
Frank Langelage [https://community.jboss.org/people/lafr] created the discussion
"external activation not working for resource adapater"
To view the discussion, visit: https://community.jboss.org/message/716953#716953
--------------------------------------------------------------
using JBoss-AS 7.1.0-SNAPSHOT I put this into standalone-full.xml
{code:xml}
| | <resource-adapter> |
| | <archive>controller.rar</archive> |
| | <connection-definitions> |
| | <connection-definition jndi-name="java:/eis/maj2e-langfr-dev/Controller"> |
| | <config-property name="ClientService">JCAClient</config-property> |
| | <config-property name="ServerName">sb2000</config-property> |
| | <config-property name="PortNumber">6506</config-property> |
| | <config-property name="SocketTimeout">0</config-property> |
| | <config-property name="Encoding">ISO-8859-15</config-property> |
| | </connection-definition> |
| | </connection-definitions> |
| | </resource-adapter> |
{code}
this works perfect.
But in the past with the previous JBoss versions we used an external file to configure the resource adapater.
So I put the lines shown above into a file called maj2e-langfr-dev-ra.xml (see attached).
I validated the file against the schema definition succesfully.
Then copied it into $JBOSS_HOME/standalone/deployments/. JBoss says, the file got deployed.
But the resource adapter is not activated.
Can't see it on jboss-console web-app and do not see the "Bound JCA ConnectionFactory to [java:/eis/maj2e-langfr-dev/Controller]" message.
What am I missing?
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/716953#716953]
Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years, 1 month