Two Laptop Bag*
The moose likes EJB and other Java EE Technologies and the fly likes EAR Files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EAR Files?" Watch "EAR Files?" New topic
Author

EAR Files?

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
hi all, Please tel me how to create EAR files combining jar and war files...i have got errors in using that.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3855

Abubacker Siddik wrote:hi all, Please tel me how to create EAR files combining jar and war files...i have got errors in using that.

Which method/tool you used ?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

... and what are the errors?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
actually i explain my package structure first.

D:\abu\webapp\index.jsp
D:\abu\webapp\WEB-INF\web.xml, weblogic.xml
D:\abu\webapp\WEB-INF\classes

D:\abu\createjar\*.class
D:\abu\createjar\META-INF\ejb-jar.xml, weblogic-ejb-jar.xml

This is my folder structure..then i created war and jar files in the respective folders. Then i created another folder called myapplication. The folder structure is like this.

D:\abu\myapplication\myejb.jar, myjsp.war
D:\abu\myapplication\META-INF\application.xml, weblogic-application.xml

Then i created app.ear file and deployed it in weblogic8.1 server. What i get is, jsp compilation error saying that


_________________________________________________________________________________

Compilation of 'C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java' failed: C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:145: cannot resolve symbol
probably occurred due to an error in /index.jsp line 17:
StatefulSessionHome home = (StatefulSessionHome)ctx.lookup("ejbjsp");

C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:145: cannot resolve symbol
probably occurred due to an error in /index.jsp line 17:
StatefulSessionHome home = (StatefulSessionHome)ctx.lookup("ejbjsp");

C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:147: cannot resolve symbol
probably occurred due to an error in /index.jsp line 19:
StatefulSession rem = home.create();

Full compiler error(s):

C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:145: cannot resolve symbol
symbol : class StatefulSessionHome
location: class jsp_servlet.__index
StatefulSessionHome home = (StatefulSessionHome)ctx.lookup("ejbjsp"); //[ /index.jsp; Line: 17]
^
C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:145: cannot resolve symbol
symbol : class StatefulSessionHome
location: class jsp_servlet.__index
StatefulSessionHome home = (StatefulSessionHome)ctx.lookup("ejbjsp"); //[ /index.jsp; Line: 17]
^
C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:147: cannot resolve symbol
symbol : class StatefulSession
location: class jsp_servlet.__index
StatefulSession rem = home.create(); //[ /index.jsp; Line: 19]
^
3 errors

Mon Sep 07 16:52:24 IST 2009

______________________________________________________________________________________________

please help me..thanks
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3855

Abubacker Siddik wrote:Full compiler error(s):
C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:145: cannot resolve symbol
symbol : class StatefulSessionHome
location: class jsp_servlet.__index
StatefulSessionHome home = (StatefulSessionHome)ctx.lookup("ejbjsp"); //[ /index.jsp; Line: 17]
^
C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:145: cannot resolve symbol
symbol : class StatefulSessionHome
location: class jsp_servlet.__index
StatefulSessionHome home = (StatefulSessionHome)ctx.lookup("ejbjsp"); //[ /index.jsp; Line: 17]
^
C:\DOCUME~1\Admin\LOCALS~1\Temp\jsp_servlet\__index.java:147: cannot resolve symbol
symbol : class StatefulSession
location: class jsp_servlet.__index
StatefulSession rem = home.create(); //[ /index.jsp; Line: 19]
^
3 errors

Container is unable to find the class files required, so it may be due to classes are not properly packaged ? What are the EAR contents (structure) ?
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90

Thats what i mentioned in the myapplication folder. It contains war file and jar file and META-INF folder.

I am really confused with this thing.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

Abubacker,
myejb.jar -this is an EJB jar? What does it contain? Is it in the manifest of the war file? There's a file in the war's manifest.mf telling it where to look for things.

Also, you might try looking at the startup logs to see if the ejb has started. This will narrow down whether the problem is on the ejb or jsp side.

I hope this is just a toy project. Having Java code (especially EJBs) in a JSP is bad practice.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
hi Jeanne,

I am using weblogic8.1 server. i dont have manifest.mf files there. Only ejb-jar.xml and weblogic-ejb-jar.xml. And ya i know this is naive approach to build applications writing ejb code in jsp file. My problem is that i want to deploy an EAR file which successfully runs.

Another doubt persists in my mind is...

EJB gives service components residing on the server side. So once *.jar files are deployed and your service components will reside in server. Any client can go and look for the service component using JNDI Look up name of the component. If this is the case, i write stateless session bean which gives the name of the server if client looked up.. Ok. Now my client writes the lookup code in jsp file (Let it be.. the client is naive).

If my understanding is correct, I should not get the errors mentioned in my earlier replies. Because the errors pose as it depends on the class files that the server runs. Thats puzzling.. Please correct me and give any other way of writing EAR application..

Thanks in advance.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

I don't see the answers to my questions in your reply. You'll need to give more information to get an answer.

1) myejb.jar -this is an EJB jar?

2) Also, you might try looking at the startup logs to see if the ejb has started. This will narrow down whether the problem is on the ejb or jsp side.

And WebLogic does support a manifest.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
To your questions, Jeane,
1) myejb.jar -this is an EJB jar. K

2) yes weblogic supports manifest file. I think its ejb-jar.xml and weblogic-ejb-jar.xml.

I will give more information now so that you can help me out.

I wrote stateless session bean which just sets and gets name if you pass a string. Then i created jar file. Thats myejb.jar.

myejb.jar contains META-INF\ ejb-jar.xml and weblogic-ejb-jar.xml.
*.class

I have one jsp file. which has JNDI lookup code. This is a naive approach for EAR. (Let it be)
Then i created WEB-INF folder and classes folder in it.

Now the important point is, I placed the class files EJBHome, EJBObject, and Session Bean of myejb.jar in the WEB-INF\Classes folder.. (I thought this would solve my problem).

Now i created myjsp.war file which contains WEB-INF\Classes\*.class(myejb.jar)
WEB-INF\web.xml and weblogic.xml
index.jsp(JNDI look up)


Now coming to EAR file, I created another folder called abu. K
abu folder contains myejb.jar, myjsp.war and META-INF\application.xml and weblogic-application.xml

now i created myapplication.ear file and deployed it. The problem is that index.jsp is throwing compile time error which you can see in the my post reply above.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

Abubacker Siddik wrote:I have one jsp file. which has JNDI lookup code. This is a naive approach for EAR. (Let it be)

Ok. Noting that you may encounter problems that are hard to get help with because people don't have experience doing that.

Abubacker Siddik wrote:Now the important point is, I placed the class files EJBHome, EJBObject, and Session Bean of myejb.jar in the WEB-INF\Classes folder.. (I thought this would solve my problem).

That would "solve" a compiler error but introduce a new error - not being able to call the EJB because it is just Java code. It does hint at the problem though. My guess is the JSP imports are incorrect. Can you show what imports you have in the JSP along with the package name of the EJB?
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90


This is the .jsp file showing the import files. I still dont get the solution.

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Thanks Jeane, I found the error i did and solved the problem. My EAR is running now. I didnt import package where my *.class files are.. Now i imported the package in the jsp file. Now it runs.. Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EAR Files?