[JCA/JBoss] - Can't get JCA datasource using JNDI
by omar_azrat
Actually I'm deploying a website for JBoss. Mi commitment is make this site to work with this databases:
ORACLE
MYSQL
SQL SERVER
My fellow and me wrote the access to the database in a simple class (this project has no entity-beans). Servlets and a java application need access to database. Our current database is mysql.
Finding out a way to configure access to database, I found that using JCA its possible to bind connections to databases using files with the name in the format *ds.xml.
What I did is to work with a file I called DB-ds.xml (according JCA standard) and wrote an initial mysql configuration. Below is the content of this file:
| <?xml version="1.0" encoding="UTF-8"?>
| <!-- WEBCOMJAFL. Archivo de conexión a la base de datos. -->
| <datasources>
| <!-- Datasource config for MySQL using 3.0.9 available from:
| http://www.mysql.com/downloads/api-jdbc-stable.html-->
| <no-tx-datasource>
| <jndi-name>comp/env/jdbc/WCJFDB</jndi-name>
| <use-java-context>true</use-java-context>
| <connection-url>jdbc:mysql://localhost/webcomjafl</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>webcomjafl</user-name>
| <password></password>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
| </no-tx-datasource>
| </datasources>
Data in this file is fine (user=webcomjafl, no password)
After copying this file into server\default\deploy directory of JBoss, I got this message:
15:59:25,727 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca
| :service=DataSourceBinding,name=comp/env/jdbc/WCJFDB' to JNDI name 'java:comp/env/jdbc/WCJFDB'
What means that binding was successful.
I've tried calling this resource (comp/env/jdbc/WCJFDB) from a java-test application, but I had an error message:
before
| javax.naming.NameNotFoundException: comp not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
| at javax.naming.InitialContext.lookup(InitialContext.java:392)
| at devenet.com.workflow.DBConnectionTest.main(DBConnectionTest.java:38)
This is my source code:
public static void main(String[] args) {
| try {
|
| InitialContext ctx = new InitialContext();
| System.out.println("before");
| Object connection = ctx.lookup("java:comp/env/jdbc/WCJFDB");
| System.out.println("after");
|
| } catch (Exception e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
|
| }
Notes:
This is my jndi.properties file:
### JBossNS properties
| java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
| java.naming.provider.url=jnp://localhost:1099
| java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
I've installed JBoss version 4.0.5, with all components (full), with jmx interfaces no secured (jmx-console.war, web-console.war, jmx-invoker-service, http invoker).
I'll be thankful for any help.
Néstor Arias
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3998407#3998407
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3998407
19 years, 3 months
[JBossWS] - javax.xml.bind.annotation annotations all being ignored
by hitman_in_wis
Hi, my name is Brett, and my company is pretty new to java web services, but we need to use them to communicate between PowerBuilder and EJB3.
As far as I can tell, it looks like the annotations from the javax.xml.bind.annotation are being completely ignored in our deployed web services. Below is an example:
The web service class...
| package com.nsighttel.ejb.services.validation.creditcard;
|
| import java.io.Serializable;
|
| import javax.ejb.Stateless;
| import javax.jws.WebMethod;
| import javax.jws.WebParam;
| import javax.jws.WebService;
| import javax.jws.soap.SOAPBinding;
|
| import com.nsighttel.domain.MonthYearWS;
|
| @Stateless
| @WebService
| @SOAPBinding(style = SOAPBinding.Style.RPC, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
| public class CreditCardVerificationServiceWS implements Serializable {
| private static final long serialVersionUID = 1L;
|
| @WebMethod
| public int isValid(
| @WebParam(name = "cardExp")MonthYearWS cardExpWS
| ){
| return 1;
| }
|
| }
|
And the class for the WebParam...
| package com.nsighttel.domain;
|
| import java.io.Serializable;
| import javax.xml.bind.annotation.XmlAccessorType;
| import javax.xml.bind.annotation.XmlTransient;
| import javax.xml.bind.annotation.XmlAccessType;
|
| @XmlAccessorType(XmlAccessType.FIELD)
| public class MonthYearWS implements Serializable {
| private static final long serialVersionUID = 1L;
| private Boolean isNull;
| private Integer month;
| private Integer year;
| @XmlTransient private MonthYear obj;
|
|
| public MonthYearWS(Boolean isNull, Integer month, Integer year) {
| this.isNull = isNull;
| this.month = month;
| this.year = year;
| if (isNull == null || !isNull){
| obj = new MonthYear(month,year);
| }
| }
|
| public Boolean getIsNull() {
| return isNull;
| }
|
| public void setIsNull(Boolean isNull) {
| this.isNull = isNull;
| }
|
| public Integer getMonth() {
| return month;
| }
|
| public void setMonth(Integer month) {
| this.month = month;
| }
|
| public Integer getYear() {
| return year;
| }
|
| public void setYear(Integer year) {
| this.year = year;
| }
|
| @XmlTransient
| public MonthYear getObj(){
| return obj;
| }
|
| public void setObj(MonthYear obj){
| this.obj = obj;
| }
| }
|
No matter what annotations I use, I get isNull, month, year, and obj all in my WSDL file for the above web service. The @XmlTransient annotation on the getObj() function is not being honored, as I am still getting obj in the WSDL file. Furthermore, if I take away all of the public getter functions, then I get no elements in my WSDL file. Therefore, the @XmlAccessorType(XmlAccessType.FIELD) is not being honored either.
I have tried a few other annotations from the javax.xml.bind.annotation package, but none of them appear to be working either.
Could someone please clue me in to what I may be doing wrong? Does Jboss not support these annotations? Or maybe the annotations do not apply to web services?
Any help is greatly appreciated.
Thanks!
-Brett Birschbach
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3998406#3998406
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3998406
19 years, 3 months
[JBoss Seam] - Lazy mans guide to developing SEAM!
by tony.herstell@gmail.com
The examples in other posts are ant-build-deploy based... including how to connect to a running server "somewhere ourside the IDE" - e.g. a Live/Pre Production Server.
For developement you probably don't want to do that! If you have a Good IDE why not use it?
I generally work alone on projects so time is king!
So, call me very sad but I could not stand the time taked to ant build/redeploy each time I made a tiny change !!! so I bothered to set up a J2EE project in MYEclipse comprising of three parts:
xxxx.ear
xxxx.jar
xxxx.war
I then ripped apart a war created for the booking example (from Ant) and kept fiddling until I finally got the right Jars/Code in the right areas (ear, jar and war) that matched the WAR. (I can supply this!)
I then told MyEclipse to "deploy as exploded" to my JBoss server; which creates a directory in the JBoss Deploy area called xxx.ear and puts your "real" code in there... unarchived! NEAT!
I then just run the JBoss server from INSIDE MyEclipse with one button click and generally when I change code/xhtml I don't even have to redeploy/restart the server; it just works... and I can also set breakpoints etc. (might have to close the browser to clear the browsers cache of .css and .xhtml though!)
All your output from the server, including your logging statements, is in the MyEclipse console and you just set breakpoints in your code and it works! none of this fiddling with Jboss config etc.
Set your log statements to info to see them in the console (the easy option as JBoss logs by default to info I guess) or else do some fiddling in the Jboss Logger Config XML file (cant remember the name) to either:
1. change the default outputter to log at the level of debug (you get a lot of debug info from everywhere including the JBoss server itself! some of it quite interesting and amusing!)
OR (the geek solution)
2. add a outputter for your project that outputs your applications packages logging (xxx.xxxx.xxxx.xxx) at the debug level. - See a Geek for how to do this or RTFM from JBoss as it should be in there!
Now, if you change the code too much (i.e. change an interface) then you get MyEclipse reporting (on behalf of JBoss) that it can't manage the change and you are offered the option to terminate the server; which I generally do; and then re-start it (again one-click from inside MyEclipse).
Finally, when I have to, I write an ant script for other people ! (Not actually done one yet and been working this project for weeks!!!)
NOTE: MyEclipse is SUPPOSED to deploy as an WAR archive as well as exploded but I never get a valid war !!! as the application.xml gets munged...(e.g. <web-uri>risingstars.war.war</web-uri>). This is a shame as then I would only have to writer an Ant script at the VERY VERY end to get rid of some Jars I dont need deployed (the test ones) but I think I may be able to fiddle around more and have "dependent" projects in MyEclipse to get round this e.g. xxxx._testing.ear. (NOte to self - RTFM in MyEclipse as I can't 'NOT' deploy a jar file from my project to the exploded or archived project).
Not bad for a tool that really doesn't even support SEAM/EJB3.
If you go this route make sure you do this:
Under xxxx.ear go into properties
Under EAR check the option for
"Do No Modify 'application.xml' (I will manually manage it)"
as it gets it wrong!
SEAM + IceFaces Related stuff:
I seem to have ended up with the same jars in some/all parts of the project! seems to still work ok though.
You seem to have to add your icefaces jars to the application.xml
| <application>
| <display-name>risingstars</display-name>
|
| <module>
| <web>
| <web-uri>risingstars.war</web-uri>
| <context-root>/risingstars</context-root>
| </web>
| </module>
| <module>
| <ejb>risingstars.jar</ejb>
| </module>
| <module>
| <java>jboss-seam.jar</java>
| </module>
| <module>
| <java>icefaces.jar</java>
| </module>
| <module>
| <java>icefaces-comps.jar</java>
| </module>
| </application>
|
And if you have to use IceFaces table etc. then dont forget to open this file:
C:\Program Files\jboss-4.0.5.GA\server\default\deploy\jbossweb-tomcat55.sar\META-INF\jboss-service.xml and alter this line:
true
and no, I don't know why.
MyEclipse are looking to add in EJB3 support and possibly Seam support but that depends on the support from JBoss Seam Team I guess and they may not want to take this "inside the IDE approach". I can only hope the MyEclipse Devs talk to Gavin or Michael.
Hope this helps.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3998405#3998405
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3998405
19 years, 3 months
[JBoss Seam] - Re: Seam design
by monkeyden
When I say "non-persistent method" I'm referring to entity methods which don't have persistable attributes associated with them (i.e. logic only). There is surely a better way of describing it. These methods are actually related to the current state of a PERSISTED entity, so an empty pojo is of little use to them. It's really semantic state-sensitive logic. To explain, consider my other (slightly confusing) post, to which you graciously responded.
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=98505
I have an entity, which I have loaded from the EntityManager. It has an Integer attribute named status. Status can be 0 or 1. On the client I want to display "OK" for 0 and "BAD" for 1.
I'm still developing the POC for the solution but it's much simpler than I thought. I just put the "non-persistent methods" in the base class of the entity. Here is a contrived example:
public abstract class StatusBase {
| public abstract Integer getStatus();
|
| public String getStatusText(){
| if(getStatus().intValue() == 0){
| return "OK";
| }else{
| return "BAD";
| }
| }
| }
|
@Entity
| @Name("statusExample")
| @Table(name = "MY_TABLE")
| public class Status extends StatusBase implements Serializable {
| public Integer status = null;
|
| @Column(name = "STATUS", length = 1, nullable = false)
| public abstract Integer getStatus(){
| return this.status;
| }
| }
|
This way I can still interact with the entity to get the non-persistent value for the view.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3998403#3998403
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3998403
19 years, 3 months