java ee - Jboss, Eclipse, JavaEE, JPA -
i trying develope java ee application in eclipse ide. using jboss 7.0 app server.
my project contains 3 containers:
ear:
-ejb (ejb 3.0 - business logic)
-jpa (jpa 2.0 - eclipselink 2.3.x, entities database, info access object layer)
-war (jsf 2.0 - managed beans , .xhtml pages)
app logic:
my jpa container manipulates database , perform basic crud operations.
ejb container using jpa's methods in order communicate war (managed beans).
war perform user requests , communicate ejb container in order required result database specific user.
problem costs me much time , still no solution:
i've configured 3 containers work test methods (only containing strings) facing issue when trying inject @ejb sessionbean war (managed bean) after setting real methods returns db.
http status 400: requested resources unavailable.
this jpa's dao class not pretty sure wheather i've instantiated entitymanager , entity manager mill correctly (should utilize @persistancecontext(unitname="testing-jpa") instead?):
public class testdaoimpl implements itestdao { entitymanagerfactory emf = persistence.createentitymanagerfactory("testing-jpa"); entitymanager manager = emf.createentitymanager(); list<user> users = new arraylist<user>(); @override public list<user> getlist() { users = manager.createnamedquery("user.findall", user.class).getresultlist(); homecoming users; } }
ok. method getlist() performs query user entity. method called in ejb container. ejb's teststateless class implements remote interface:
@stateless(mappedname = "teststateless") public class teststateless implements teststatelesslocal { public teststateless() { // todo auto-generated constructor stub } @override public string gettext() { homecoming "hello ejb3"; } @override public list<user> getusers() { itestdao testdao = new testdaoimpl(); homecoming testdao.getlist(); } }
now, after i've defined ejb's teststateless.getusers() method got 404 status.
this how war's managedbean class looks like:
public class managebean { @ejb teststatelessremote testbean; public managebean() { } public string getsometext() { homecoming "" + 123; } public list<user> getusers() { homecoming testbean.getusers(); } }
after point, should utilize managedbean's getusers() method on .xhtml page , loop through datatable in order list each user on page.
this persistence.xml
<?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="testing-jpa" transaction-type="resource_local"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <non-jta-data-source>java:jboss/datasources/exampleds</non-jta-data-source> <class>com.model.user</class> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/cs450_pr"/> <property name="javax.persistence.jdbc.user" value="root"/> <property name="javax.persistence.jdbc.password" value=""/> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver"/> </properties> </persistence-unit> </persistence>
update:
web.xml:
<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>testing-war</display-name> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <context-param> <description>state saving method: 'client' or 'server' (=default). see jsf specification 2.5.2</description> <param-name>javax.faces.state_saving_method</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationcontext</param-name> <param-value>resources.application</param-value> </context-param> <listener> <listener-class>com.sun.faces.config.configurelistener</listener-class> </listener> <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> </web-app>
console log:
16:44:04,699 info [org.jboss.modules] jboss modules version 1.0.1.ga 16:44:05,027 info [org.jboss.msc] jboss msc version 1.0.0.ga 16:44:05,105 info [org.jboss.as] jboss 7.0.1.final "zap" starting 16:44:06,125 warn [org.jboss.as] no security realm defined native management service, access unrestricted. 16:44:06,137 info [org.jboss.as] creating http management service using network interface (management) port (9990) 16:44:06,140 warn [org.jboss.as] no security realm defined http management service, access unrestricted. 16:44:06,155 info [org.jboss.as.logging] removing bootstrap log handlers 16:44:06,191 info [org.jboss.as.connector.subsystems.datasources] (controller boot thread) deploying non-jdbc-compliant driver class com.mysql.jdbc.driver (version 5.1) 16:44:06,212 info [org.jboss.as.clustering.infinispan.subsystem] (controller boot thread) activating infinispan subsystem. 16:44:06,486 info [org.jboss.as.naming] (controller boot thread) activating naming subsystem 16:44:06,508 info [org.jboss.as.naming] (msc service thread 1-3) starting naming service 16:44:06,512 info [org.jboss.as.osgi] (controller boot thread) activating osgi subsystem 16:44:06,592 info [org.jboss.as.security] (controller boot thread) activating security subsystem 16:44:06,604 info [org.jboss.remoting] (msc service thread 1-7) jboss remoting version 3.2.0.beta2 16:44:06,627 info [org.xnio] (msc service thread 1-7) xnio version 3.0.0.beta3 16:44:06,671 info [org.xnio.nio] (msc service thread 1-7) xnio nio implementation version 3.0.0.beta3 16:44:07,123 info [org.apache.catalina.core.aprlifecyclelistener] (msc service thread 1-3) apache tomcat native library allows optimal performance in production environments not found on java.library.path: c:\program files\java\jdk1.8.0\bin;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;native;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\mingw\bin;c:\msys\1.0\bin;c:\program files (x86)\windows kits\8.1\windows performance toolkit\;c:\program files\microsoft sql server\110\tools\binn\;. 16:44:07,140 info [org.jboss.as.ee] (controller boot thread) activating ee subsystem 16:44:07,709 info [org.jboss.as.jmx.jmxconnectorservice] (msc service thread 1-3) starting remote jmx connector 16:44:07,801 info [org.apache.coyote.http11.http11protocol] (msc service thread 1-7) starting coyote http/1.1 on http--127.0.0.1-8080 16:44:07,929 info [org.jboss.as.connector] (msc service thread 1-3) starting jca subsystem (jboss ironjacamar 1.0.3.final) 16:44:08,035 info [org.jboss.as.connector.subsystems.datasources] (msc service thread 1-3) bound info source [java:/miksijevjndi] 16:44:08,074 info [org.jboss.as.remoting] (msc service thread 1-1) listening on /127.0.0.1:9999 16:44:08,204 info [org.jboss.as.deployment] (msc service thread 1-2) started filesystemdeploymentservice directory c:\users\milan\jboss-as-7.0.1.final\standalone\deployments 16:44:08,251 info [org.jboss.as.deployment] (deploymentscanner-threads - 1) found testing-ear.ear in deployment directory. trigger deployment create file called testing-ear.ear.dodeploy 16:44:08,286 info [org.jboss.as] (controller boot thread) jboss 7.0.1.final "zap" started in 4056ms - started 93 of 148 services (55 services passive or on-demand)
java-ee jpa ejb jboss7.x war
No comments:
Post a Comment