aspose file tools*
The moose likes JBoss/WildFly and the fly likes Problem in deploying JPA -EJB in JBoss4.2.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Problem in deploying JPA -EJB in JBoss4.2.1" Watch "Problem in deploying JPA -EJB in JBoss4.2.1" New topic
Author

Problem in deploying JPA -EJB in JBoss4.2.1

Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
I have developed an EJB using the EJB3.0 spec i.e. with Entity classes derived from an oracle-10g database.

Iam using Jdeveloper IDE 10.1.3.3for this.

I introduced the oracle-ds.xml as shown in
<JBOSS_HOME>\docs\examples\jca\.In it i have put jndiname=DBConnection1DS.

My server console shows that my jar fie has been deployed but
the EJB service has not started .
It says:-
NOTYETINSTALLED
object:jboss.jca:name=jdbc/DBConnection1DS,service=DataSourceBinding .

Now I have copied Oracle's JDBC driver -classes12.jar(from Oracle 10.2.0)in server\default\lib.
The jta-datasource-name=jdbc/DBConnection1DS.

in the jmx console the only service=DataSourceBinding i am able to see
is jandi-named-DefaultDS.I think i need another service= DataSourceBinding
named =jdbc/DBConnection1DS.

I think i've put everything right yet there seems to be problem in starting the EJB.

PLEASE HELP....
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10096
    
164

Please post the entire stacktrace that you are seeing. Also, have you deployed your own datasource (in a file name *-ds.xml) which binds to jdbc/DBConnection1DS? If not, then you will have to deploy one. Have a look at ConfigDataSources to see how datasources can be configured.


[My Blog] [JavaRanch Journal]
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
oracle-ds.xml

<datasources>
<local-tx-datasource>
<!--I have cahnged the name of the datasource----->
<jndi-name>jdbc/qweDS</jndi-name>
<connection-url>jdbc racle:thin:@192.0.0.100:1521 rcl</connection-url>
<driver-class>oracle.jdbc.driver.OraclDriver</driver-class>

<user-name>scott</user-name>
<password>tiger</password>

<exception-sorter-class>
org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name>

<metadata>
<type-mapping>Oracle10g</type-mapping>
</metadata>

</local-tx-datasource>
</datasources>

The persistence.xml is as follows
<persistence>
<persistence-unit name="Model">
<jta-data-source>jdbc/qweDS</jta-data-source>
<persistence-unit>
</persistence>

The statck-trace of the server is as follows
----MBeans waiting for otheer MBeans-----
ObjectName ersistence.units:ear=FindStudent-ear.ear,jar=FindStudent-jar.jar,unitname=Model.

state=FAILED
Reason:javax.Naming.NameNotFoundException:jdbc not bound.
I depend on
jboss.jca:service=DataSourceBinding,name=jdbc/qweDS

Depends on me
jboss.j2ee:ear=FindStudent-ear.ear,jar=FindStudent-jar.jar,name=FindStudentEJB,service=EJB3.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10096
    
164

<persistence-unit name="Model">
<jta-data-source>jdbc/qweDS</jta-data-source>
<persistence-unit>


Change it to



By default, the datasource is bound to the java: namespace.
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Thanks man!!! it worked

But now I've got a new Problem

I have successfully acquired the instance of the SLSB in the
Backing Bean of a JSF page at the front end .
Its value is ==FindStudentBean.

Using this instance Iam trying to call a function ==
public ReplyDTO showme();

ReplyDTO is a class that contains a single variale "data" of the data type Object.

The Implementation is as follows
public ReplyDTO showMe()
{
ReplyDTO rObj=new ReplyDTO();
rObj.setData("======Welcome=====");
return rObj;
}

But now when I try to Execute the JSF application it returns the following Error :

java.lang.ClassCastException:<packagename>.ReplyDTO
at <some line no.in Backing bean> : $proxy149.showMe(unknown source)
.
.
.
.
.
I am just not able to figure out why is there a class cast Exception.
Please Help!!!


Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10096
    
164

Maybe a classloader issue. Have a look at ClassCastExceptions, specifically the jmx-console method mentioned over there.
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
Thanks for the suggestion.


I followed the link you provided .
Following is the Info I got at my jmxconsole for displayInfo().

<package-name>.FindStudentBean Information

Repository cache version
<package-name>.FindStudentBean(645c82)
ClassLoader=org.jboss.mx.loading.UnifiedlassLoader3@825459(url=file:<$JBOSS_HOME>/server/default/tmp/deploy/tmp33678FindStudent-ear.ear , addedOrder=46)

.
.
.
.
.
++++CodeSource=(file:<$JBOSS_HOME>/server/default/tmp/deploy/tmp33678FindStudent-ear.ear-contents/FindStudent-jar.jar)

Implemented Interface:
++interface <package-name>.FindStudentLocal
++++ClassLoader=org.jboss.mx.loading.UnifiedlassLoader3@825459(url=file:<$JBOSS_HOME>/server/default/tmp/deploy/tmp33678FindStudent-ear.ear)
++++CodeSource(file:<$JBOSS_HOME>/server/default/tmp/deploy/tmp33678FindStudent-ear.ear-contents/FindStudent-jar.jar)


###Instance0 found in UCL : org.jboss.mx.loading.UnifiedlassLoader3@825459(url=file:<$JBOSS_HOME>/server/default/tmp/deploy/tmp33678FindStudent-ear.ear)

---------------------------------------------------------------------------

Now as you can see that there is only one Instance occuring in this information so we have to assume that same class may not have been loaded into different deployments.

what do you say???
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
I just wanted to tell that I was finally able to get my application running.
Thanks,it would have been really difficult without your help!!!

But now please help me in finding a way of configuring Apache Myfaces Trinidad Components with JBoss 4.2.1.Since JSF itself has support for
JSF I at to know how can I configure any extended components with JBoss4.2.1.
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
I am unable to bring up the jmx-console with the following address
http://192.*.*.*/jmx-console/
i.e. I can't access it remotely.....

Where should I make changes to achieve this???
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
Thanks for the tip on remote access for JBoss4.2.1 . It was very helpful.

Now I have two problems :-
1)My FindStudent module, which had included the JPA which you helped me deploy,is facing same some problem.

When I deploy my .war file in /server/default/deploy I am able to execute my application propely. But when I close the browser and try to open a new browser to run the application again it does not show the results obtained from the JPA. I have to redeploy the .war every time I want to run the application correctly. As well as there are no exceptions i the server window.

2)I stil do not know how to Configure Apache trinidad components in
JBoss 4.2.1

Please Help!!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10096
    
164

Originally posted by Dushyant Agarwal:
1)My FindStudent module, which had included the JPA which you helped me deploy,is facing same some problem.

When I deploy my .war file in /server/default/deploy I am able to execute my application propely. But when I close the browser and try to open a new browser to run the application again it does not show the results obtained from the JPA. I have to redeploy the .war every time I want to run the application correctly. As well as there are no exceptions i the server window.


Do you see any errors in the server.log file? You will have to provide more details when you say "it does not show the results obtained from JPA".

Originally posted by Dushyant Agarwal:
2)I stil do not know how to Configure Apache trinidad components in
JBoss 4.2.1


I haven't used Apache Trinidad, so i might not be of much help. Are you seeing any exceptions while configuring this in JBoss? If yes, then post them here, maybe someone will be able to help.
Samba Siva Rao Kolusu
Greenhorn

Joined: Aug 25, 2006
Posts: 4
Hi! Dhushyanth,

The JBoss ,by default loks for the JSF libraries in its jsf-libs directory under deploy/JBoss-web.deployer in Jboss-4.2* or in deploy/jbosswebtomcat55.sar in earlier versions.

First remove those libraries and also, shutdown the server ,and remove the directories data log and tmp . Package Trinida-api.jar Trinidad-imlp.jar, JSF-api.jar ,and jsf-impl.jar in your WEB-INF folder.

That's it Trinidad Should work!

Hope you get it going smoothly!

Regards,
Samba
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
Thanks for the reply. I got it working smoothly.

But now I am facing a problem. My .war file seems to have a requirement of being undeployed+deployed in JBoss4.2.1 everytime I want to run the application afresh!

Is there any solution to this problem??
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,Jaikiran Pai

It was really very kind of you to help me so generously in in deploying my a JPA applcation. It would have been really hard to get along without your help.



But now I have some queries:

For looking up the deployed EJB "MyBeanLocal/MyBean/local"

1.) I had to get the InitialContext as follows

public void getInitialContext() throws NamingException

{

HashTable env= new HashTable();

env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

env.put(Context.PROVIDER_URL,"localhost");

env.put(Context,URL_PKG_PREFIXES,"org.jboss.naming rg.jnp.interfaces");

return new IntialContext(env);

}

Then wherever I have to lookup the bean I write :
Context ctx= getInitialContext();
MyBeanLocal obj=(MyBeanLocal)ctx.lookup("MyBeanLocal/MyBean/local"):



All this works absolutely fine!!

But when I try to use the following:
Context ctx=new InitialContext();

for looking up the bean
I get an exception that no InitialContext defined
How should I resolve this problem???

2.)Which resources of JBoss(apart from .war& .jar files)have
java:comp/env/ prepended to their JNDI names???


3.)Why do we have to undeploy+deploy the .war file every time I want to run my application afresh ??? Other wise thw web apllication would not execute as intended!!!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10096
    
164

All this works absolutely fine!!

But when I try to use the following:
Context ctx=new InitialContext();

for looking up the bean
I get an exception that no InitialContext defined
How should I resolve this problem???


You mean you get a javax.naming.NoInitialContextException while doing the lookup? Are you doing the lookup from a standalone java client? If so, then you have place a jndi.properties file in the classpath of the java client. Have a look at Why do i get NoInitialContextException for more details.

2.)Which resources of JBoss(apart from .war& .jar files)have
java:comp/env/ prepended to their JNDI names???


The java:comp/env/ prefix will be added to the JNDI names only when you have defined env-entry or ejb-ref or resource-ref in either ejb-jar.xml or web.xml of your application.

3.)Why do we have to undeploy+deploy the .war file every time I want to run my application afresh ??? Other wise thw web apllication would not execute as intended!!!


Not sure why. Might have to do with the way the application is implemented. What do you mean by "i want to run my application afresh" and "the web application would not execute as intended"? When you say afresh, are you doing any changes to the application?
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
Thanks for the reply...!

When I say " I want to run my application afresh" I mean --
1. I deploy my .war into server/default/deploy.
2. I start the browser and run my application perfectly.
3. I close the browser.
4. I open the browser again and try to run the application again. But this time it would not run correctly.That is to say that the communication between the Backing bean of the JSF and the SLSB does not take place.
Also No exceptions take place.

Then I have to undeploy+deploy the .war file. This makes my application to run properly. And this situation is not only with my application but a couple of other guys who are developing JSF+EJB applcatiions are also facing the same problem...

As far as ejb-ref etc. is concerned I don't seem to have used them any where in my web-application. Can you specifically point out where to look???
[ November 05, 2007: Message edited by: Dushyant Agarwal ]
[ November 05, 2007: Message edited by: Dushyant Agarwal ]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10096
    
164

Originally posted by Dushyant Agarwal:

When I say " I want to run my application afresh" I mean --
1. I deploy my .war into server/default/deploy.
2. I start the browser and run my application perfectly.
3. I close the browser.
4. I open the browser again and try to run the application again. But this time it would not run correctly.That is to say that the communication between the Backing bean of the JSF and the SLSB does not take place.
Also No exceptions take place.
Then I have to undeploy+deploy the .war file. This makes my application to run properly.



Dushyant,

It's hard to tell why you might be observing this behaviour.

Originally posted by Dushyant Agarwal:

As far as ejb-ref etc. is concerned I don't seem to have used them any where in my web-application. Can you specifically point out where to look???


Binding to java:/comp/env is optional. Your application might not be doing it and hence you may not find it in your deployment descriptors. If at all you are binding anything in the java:/comp/env then the files that i would check, would be web.xml/jboss-web.xml, ejb-jar.xml/jboss.xml
Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,Jaikiran .
Thanks for the reply.

Could you also take a look at the following link:
http://www.coderanch.com/t/274162/java/java/convert-Wnidows-dll-files-jar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in deploying JPA -EJB in JBoss4.2.1