[JBoss Eclipse IDE (users)] - Tutorial XDoclet Configurations
by skavanag
I am new to Eclipse and JBoss, so I may be missing something obvious. However after spending the day doing to Fibonacci tutorial four times and getting to the same roadblock I thought I'd ask for some help....
I am on a Mac running OSX 10.4 (Tiger).
I am getting thru to Chapter 5 of the Tutorial. When I get to the "Generation of the EJB related files", I cannot seem to get a proper XDoclet Configuration screen up.
The screen I get by "right" clicking on the Tutorial Project in the Package Exploration pane comes up OK, but when I click on Properties and try to select the XDoclet Configuration wizard, I get "The currently displayed page contains invalid values". If I select another wizard and then go back to the XDoclet Configuration wizard, I can enable/disable XDoclet, but there are no menus on the right-hand side of the wizard window, so I cannot do any of the following steps in the tutorial.
What am I missing???
thanks,
Stephen
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969081#3969081
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969081
19 years, 7 months
[JBoss Seam] - Re: Can't inject entityManager into application component?
by raja05
I modified the registration app not to work with EJBs but as Simple beans. The other changes are to make the REgisterAction bean as a Application scope bean and be available at Startup. I did those modifications just to make sure that your original problem description was happening for me too.
Here is a diff of what was changed ("registration" is the seam-example folder and "test" is my folder)
| diff -r ../registration/src/org/jboss/seam/example/registration/RegisterAction.java src/org/jboss/seam/example/registration/RegisterAction.java
| 11a12,13
| > import org.jboss.seam.annotations.Startup;
| > import org.jboss.seam.ScopeType;
| 12a15
| > import org.jboss.seam.annotations.Scope;
| 17d19
| < @Stateless
| 18a21,22
| > @Startup
| > @Scope(ScopeType.APPLICATION)
| 25c29
| < @PersistenceContext
| ---
| > @In(create=true)
| 32a37
| > log.warn("EM: " + em);
| diff -r ../registration/src/org/jboss/seam/example/registration/Register.java src/org/jboss/seam/example/registration/Register.java
| 6d5
| < @Local
| 10c9
| < }
| \ No newline at end of file
| ---
| > }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969079#3969079
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969079
19 years, 7 months
[J2EE Design Patterns] - EJB3.0-Relations one-to-many
by dasariprasad
Dear colleague,
I had developed one one to many relation(bi-directional) as a part of learning having two entity beans and one Stateful session facade for them. i could able to create entity beans and add a mny bean to the collection of one-side bean.but later when i search for individual beans ,it is showing errors and returning a null.In the server log file ,it is getting the information but not able to return to the client.The code is
one side Entity
package cmp3rels;
import javax.persistence.*;
import javax.ejb.*;
import java.util.Set;
import java.util.HashSet;
@Entity()
@Table(name="AREA")
@NamedQuery(name="plain.areas ", query="select a from Area a ")
public class Area implements java.io.Serializable
{
Integer id;
String areaName;
int population;
Set bazars = new HashSet();
@Id
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
@Column(name="AREA_NAME" ,nullable=false)
public String getAreaName()
{
return areaName;
}
public void setAreaName(String newAreaName)
{
areaName = newAreaName;
}
@Column
public int getPopulation()
{
return population;
}
public void setPopulation(int newPopulation)
{
population = newPopulation;
}
@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="area")
@JoinColumn(name = "AREA_ID")
public Set getBazars()
{
return bazars;
}
public void setBazars(Set newBazars)
{
bazars = newBazars;
}
public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append("Id:"+id);
sb.append("\nArea-Name:"+areaName);
sb.append("\nPopulation:"+population);
sb.append("\nbazars:"+bazars+"\n");
return sb.toString();
}
}
............................................................................................................
many-side entity
package cmp3rels;
import javax.persistence.*;
import javax.ejb.*;
@Entity()
@Table(name="BAZAR")
@NamedQuery(name="plain.bazars", query="select b from Bazar b ")
public class Bazar implements java.io.Serializable
{
Integer id;
String bazarName;
double turnover;
Area area;
@Id
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
@Column(name="BAZAR_NAME" ,nullable=false)
public String getBazarName()
{
return bazarName;
}
public void setBazarName(String newBazarName)
{
bazarName = newBazarName;
}
@Column
public double getTurnover()
{
return turnover;
}
public void setTurnover(double newTurnover)
{
turnover = newTurnover;
}
@ManyToOne(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
@JoinColumn(name="AREA_ID" )
public Area getArea()
{
return area;
}
public void setArea(Area newArea)
{
area = newArea;
}
public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append("Id: "+id);
sb.append("\nArea-Name: "+bazarName);
sb.append("\nTurnover: "+turnover);
sb.append("\nArea: "+area+"\n");
return sb.toString();
}
}
........................................................................................................
stateful facade is
interface
package cmp3rels;
import java.util.*;
import javax.ejb.Remote;
@Remote
public interface AreaSess
{
public boolean createArea(int id, String areaName, int population);
public boolean addBazarToArea(int areaCode, int bazarCode);
public boolean assignBazars(int areaCode , Set bazars);
public String getAreaInfo(Integer areaCode);
public boolean createBazar(int id, String bazarName, double turnover);
public Bazar getCodeBazar(Integer bazarCode);
public Area getCodeArea(Integer areaCode);
public Area getBazarArea(Bazar bazar);
public Area newArea(int id, String areaName, int population);
public Bazar newBazar(int id, String bazarName, double tover);
}
package cmp3rels;
import javax.ejb.Stateful;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Query;
import org.jboss.ejb3.entity.*;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
@Stateful
public class AreaSessBean implements AreaSess,java.io.Serializable
{
@PersistenceContext(unitName="mydb", type=PersistenceContextType.EXTENDED)
private EntityManager em;
EntityTransaction trans;
private Area area;
private Bazar bazar;
public boolean createArea(int id, String areaName, int population)
{
boolean ret = false;
try
{
Area area = new Area();
area.setId(new Integer(id));
area.setAreaName(areaName);
area.setPopulation(population);
em.persist(area);
ret = true;
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return ret;
}
public boolean addBazarToArea(int areaCode, int bazarCode)
{
boolean ret = false;
Area area = null;
Bazar bazar = null;
Set bazars = null ;
try
{
area =(Area)em.find(Area.class,new Integer(areaCode));
System.out.println(area);
bazar =(Bazar)em.find(Bazar.class,new Integer(bazarCode));
if(area != null )
{
bazar.setArea(area);
bazars = area.getBazars();
bazars.add(bazar);
em.merge(area);
em.merge(bazar);
ret = true;
}
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return ret;
}
public Area getCodeArea(Integer areaCode)
{
Area ret = null;
try
{
System.out.println("param is:"+areaCode);
ret = (Area)em.getReference(Area.class, areaCode);
em.flush();
}
catch(Exception e)
{
StackTraceElement[] stck = e.getStackTrace();
System.out.println("1....:"+stck.length);
for(StackTraceElement elem : stck)
{
System.out.println(elem);
}
}
System.out.println("area is:"+ret);
return ret;
}
public Bazar getCodeBazar(Integer bazarCode)
{
Bazar ret = null;
try
{
System.out.println("param is :"+bazarCode);
ret = (Bazar)em.getReference(Bazar.class,bazarCode);
}
catch(Exception e)
{
StackTraceElement[] stck = e.getStackTrace();
System.out.println("1....:"+stck.length);
for(StackTraceElement elem : stck)
{
System.out.println(elem);
}
}
System.out.println("1....:"+ret);
return ret;
}
public boolean assignBazars(int areaCode , Set bazs)
{
boolean ret = false;
Area area = null;
Set bazars = null ;
try
{
area = (Area)em.find(cmp3rels.Area.class,new Integer(areaCode));
if(area != null )
{
bazars = area.getBazars();
bazars.clear();
bazars.addAll(bazs);
for(Bazar bz : bazs)
{
bz.setArea(area);
}
ret = true;
}
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return ret;
}
/* public String getAreaInfo(Integer areaCode)
{
String ret = "Not Available";
Area area = null;
String qryStr = "select Object(ar) from Area ar where ar.id=:d";
System.out.println("...."+areaCode);
try
{
Query qry = em.createQuery(qryStr);
qry.setParameter("d",areaCode);
System.out.println(qry);
List li = qry.getResultList();
if(li.size()>0 )
{
area = (Area)li.get(0);
ret = area.toString();
}
}
catch(Exception e)
{
StackTraceElement[] stck = e.getStackTrace();
System.out.println("1....:"+stck.length);
for(StackTraceElement elem : stck)
{
System.out.println(elem);
}
}
return ret;
}*/
public String getAreaInfo(Integer areaCode)
{
String ret = "Not Available";
Area area = null;
try
{
area =(Area)em.getReference(Area.class,areaCode);
if(area != null )
{
ret = area.toString();
}
}
catch(Exception e)
{
StackTraceElement[] stck = e.getStackTrace();
System.out.println("1....:"+stck.length);
for(StackTraceElement elem : stck)
{
System.out.println(elem);
}
}
return ret;
}
public boolean createBazar(int id, String bazarName, double turnover)
{
boolean ret = false;
try
{
Bazar bazar = new Bazar();
bazar.setId(new Integer(id));
bazar.setBazarName(bazarName);
bazar.setTurnover(turnover);
em.persist(bazar);
ret = true;
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return ret;
}
public Area getBazarArea(Bazar bazar1)
{
System.out.println("...."+em.isOpen());
String qryStr = " select ar from Area ar ,in (ar.bazars) brs " +
" where :b1 member of brs ";
Area area = null;
Bazar bazar = null;
try
{
Query qry = em.createQuery(qryStr);
qry.setParameter("b1",bazar1);
List li = qry.getResultList();
area = (Area)li.get(0);
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return area;
}
public Area newArea(int id, String areaName, int population)
{
Area ret = null;
try
{
Area area = new Area();
area.setId(new Integer(id));
area.setAreaName(areaName);
area.setPopulation(population);
em.persist(area);
ret = area;
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return ret;
}
public Bazar newBazar(int id, String bazarName, double tover)
{
Bazar ret = null;
try
{
Bazar bazar = new Bazar();
bazar.setId(new Integer(id));
bazar.setBazarName(bazarName);
bazar.setTurnover(tover);
em.persist(bazar);
ret = bazar;
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return ret;
}
}
...................................................................................................
working client class is
package cmp3rels;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
import java.util.*;
import org.apache.log4j.*;
public class NewRel3Client
{
static Logger logger;
public static InitialContext getInitialContext()
{
Properties props=new Properties();
InitialContext jndiCtx=null;
try
{
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"jnp://localhost");
props.put(Context.STATE_FACTORIES,"org.jboss.naming:org.jnp.interfaces");
jndiCtx=new InitialContext(props);
}
catch(Exception ex)
{}
return jndiCtx;
}
public static void main(String args[])throws java.io.IOException
{
int[] areaIds = {1000,1005,1010};
String[] areas = {"Guindy","Tambaram","Mudichur"};
int[] pops = {490000,260000,95000};
int[] bazarIds = {100,105,110};
String bazars[] = {"Super-Special","Variety-Mart","Needs-Market"};
double tovers[] = {239879.30,199234.30,61439.30};
boolean created = false;
logger = Logger.getRootLogger();
logger.addAppender(new FileAppender(new HTMLLayout(),
"mylog1.log",true));
System.out.println("\nBegin New-EJB3-Rels-Client...\n");
try
{
InitialContext ctx=getInitialContext();
AreaSess sess =
(AreaSess)ctx.lookup("AreaSessBean/remote");
System.out.println("\nGot jndi named object..\n");
for(int i=0;i<3;i++)
{
created = sess.createArea(areaIds,areas,pops);
System.out.println("\nStatement Area Created is...:"+created);
created = sess.createBazar(bazarIds,bazars,tovers);
System.out.println("\nStatement Bazar Created is...:"+created);
}
Area area = null;
Bazar bazar = null;
for(int i=0;i<15;i+=5)
{
created = sess.addBazarToArea(1000+i,100+i);
System.out.println("bazar is added "+created);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
............................................................................................................
not working class is
package cmp3rels;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
import java.util.*;
import org.apache.log4j.*;
public class Rel3Client
{
static Logger logger;
public static InitialContext getInitialContext()
{
Properties props=new Properties();
InitialContext jndiCtx=null;
try
{
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"jnp://localhost:1099");
props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
jndiCtx=new InitialContext(props);
}
catch(Exception ex)
{}
return jndiCtx;
}
public static void main(String args[])throws java.io.IOException
{
boolean created = false;
logger = Logger.getRootLogger();
logger.addAppender(new FileAppender(new HTMLLayout(),
"mylog1.log",true));
System.out.println("\nBegin Rels3-Client...\n");
try
{
InitialContext ctx=getInitialContext();
Object obj = ctx.lookup("AreaSessBean/remote");
AreaSess sess = (AreaSess)PortableRemoteObject.narrow(obj,AreaSess.class);
System.out.println("\nGot jndi named object..\n");
Area area2 = sess.getCodeArea(new Integer(1000));
System.out.println("area...."+area2);
System.out.println("......::"+sess.getAreaInfo(new Integer(1000)));
Bazar bazar = sess.getCodeBazar(new Integer(105));
System.out.println("....:"+bazar);
Area area = sess.getBazarArea(bazar);
System.out.println("Area for bazar id-105 is: "+area);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
i made one ant build file as
<?xml version="1.0" ?>
the oracle sql is
drop table bazar;
drop table area;
drop sequence area_seq;
drop sequence bazar_seq;
create sequence bazar_seq;
create sequence area_seq;
create table area(id number Constraint area_PK primary key,
area_name varchar2(20) not null,
population number);
create table bazar(id number Constraint bazar_PK primary key,
bazar_name varchar2(20) not null,
turnover number,
AREA_ID number references area(id));
please look into this and help me to fish out the problem
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969078#3969078
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969078
19 years, 7 months
[Persistence, JBoss/CMP, Hibernate, Database] - java.lang.RuntimeException: javax.management.InstanceAlready
by Rockym
Hi
I have a little problem, because I have made the persistence and made the conecction to MySQL, but the console marks the next.
java.lang.RuntimeException: javax.management.InstanceAlreadyExistsException: persistence.units:jar=tutorialEstudiante.jar,unitName=Estudiante already registered.
20:36:58,211 INFO [EJB3Deployer] Deployed: file:/Applications/jboss/server/default/deploy/tutorialEstudiante.jar
20:36:58,228 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: persistence.units:jar=tutorialEstudiante.jar,unitName=Estudiante
State: NOTYETINSTALLED
I Depend On:
jboss.jca:name=MySQLDS,service=ManagedConnectionFactory
ObjectName: jboss.j2ee:service=EJB3,module=tutorialEstudiante.jar
State: FAILED
Reason: java.lang.RuntimeException: javax.management.InstanceAlreadyExistsException: persistence.units:jar=tutorialEstudiante.jar,unitName=Estudiante already registered.
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.jca:name=MySQLDS,service=ManagedConnectionFactory
State: NOTYETINSTALLED
Depends On Me:
persistence.units:jar=tutorialEstudiante.jar,unitName=Estudiante
ObjectName: jboss.j2ee:service=EJB3,module=tutorialEstudiante.jar
State: FAILED
Reason: java.lang.RuntimeException: javax.management.InstanceAlreadyExistsException: persistence.units:jar=tutorialEstudiante.jar,unitName=Estudiante already registered.
The curious is that the Beans are stored in memory by the stateful, but when I try to the the database the table and the Beans doesn't appear.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969075#3969075
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969075
19 years, 7 months
[Tomcat, HTTPD, Servlets & JSP] - FileNotFound Exception ClassLoader fail read spring xml file
by eagelinhills
I have a weird problem with the classloader. I am trying to load a Spring bean applicationReports_Context.xml file located in WEB-INF/classes folder through a classloader. This file is different from the main applicationContext.xml.
The URL Generate at run time is fine. But the ClassLoader throws the Exception unable to load the XML File. Any ideas
See the Logs
2006-09-02 18:51:54,136 INFO [com.evergreen.brokervoting.util.ReportServiceReloader] The file to be loaded is applicationContext_Reports.xml
2006-09-02 18:51:54,139 INFO [STDOUT] About to launch Spring with file with refresh:
/export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml
2006-09-02 18:51:54,140 DEBUG [org.jboss.web.tomcat.filters.ReplyHeaderFilter] Adding header name: X-Powered-By='Servlet 2.4; JBoss-4.0.4.CR2 (build: CVSTag=JBoss_4_0_4_CR2 date=200603311500)/Tomcat-5.5'
2006-09-02 18:51:54,150 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loading XML bean definitions from file [/export/home/weblogic/jboss-4.0.4.CR2-reference/bin/export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml]
2006-09-02 18:51:54,153 INFO [STDOUT] org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [/export/home/weblogic/jboss-4.0.4.CR2-reference/bin/export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml]; nested exception is java.io.FileNotFoundException: export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml (No such file or directory)
2006-09-02 18:51:54,153 ERROR [com.evergreen.brokervoting.util.ReportServiceReloader] org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [/export/home/weblogic/jboss-4.0.4.CR2-reference/bin/export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml]; nested exception is java.io.FileNotFoundException: export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml (No such file or directory)
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [/export/home/weblogic/jboss-4.0.4.CR2-reference/bin/export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml]; nested exception is java.io.FileNotFoundException: export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml (No such file or directory)
java.io.FileNotFoundException: export/home/weblogic/jboss-4.0.4.CR2-reference/server/reference/tmp/deploy/tmp54012brokervoting-v3_0-exp.war/WEB-INF/classes/applicationContext_Reports.xml (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at org.springframework.core.io.FileSystemResource.getInputStream(FileSystemResource.java:85)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:167)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:81)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:269)
at org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:89)
at org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:74)
at com.evergreen.brokervoting.util.ReportServiceReloader.runReports(ReportServiceReloader.java:60)
at com.evergreen.brokervoting.util.ReportServiceReloader.main(ReportServiceReloader.java:30)
at com.evergreen.brokervoting.reports.ReportsRunner.run(ReportsRunner.java:66)
at java.lang.Thread.run(Thread.java:595)
2006-09-02 18:51:54,155 ERROR [com.evergreen.brokervoting.util.ReportServiceReloader] Failed to reload the service
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969072#3969072
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969072
19 years, 7 months