File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Help With Rest EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Help With Rest EJB " Watch "Help With Rest EJB " New topic

Help With Rest EJB

Bob Nedwor
Ranch Hand

Joined: Aug 17, 2005
Posts: 215

I think I might be doing something wrong.
I am trying to get the NameService example from to work on Glassfishv3 and I am not sure I am deploying correctly.
I cannot seem to find the code for the NameBean class, so I made up my own.
When I deploy, the server log seems to indicate that everything is going OK, but I am not sure what URLs to try with my curl command.
(I run Glassfish on 8081).

curl http://localhost:8081/restejb
just gives me my prompt back.
Pretty much everything else gives me: HTTP Status 404 The requested resource () is not available.

Thanks to anyone who can help me with this. Here is what I am doing:

$ cat src/

$ cat src/

$ mkdir WEB-INF
$ mkdir WEB-INF/classes
$ export GL4=/bapps/glassfish3/glassfish/modules
$ javac -cp WEB-INF/classes:$GL4/javax.ejb.jar:$GL4/jersey-core.jar -d WEB-INF/classes src/*.java
$ jar cvf restejb.war WEB-INF
added manifest
adding: WEB-INF/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/NameBean.class(in = 394) (out= 249)(deflated 36%)
adding: WEB-INF/classes/NameService.class(in = 894) (out= 527)(deflated 41%)
$ cp restejb.war /bapps/glassfish3/glassfish/domains/domain1/autodeploy/restejb.war

Server log then says:

[#|2011-04-18T09:50:27.606-0700|INFO|glassfish3.1||_ThreadID=63;_ThreadName=Thread-1;|[AutoDeploy] Selecting file /bapps/glassfish3/glassfish/domains/domain1/autodeploy/restejb.war for autodeployment.|#]

[#|2011-04-18T09:50:27.937-0700|INFO|glassfish3.1||_ThreadID=63;_ThreadName=Thread-1;|Portable JNDI names for EJB NameService : [java:global/restejb/NameService, java:global/restejb/NameService!NameService]|#]

[#|2011-04-18T09:50:28.048-0700|INFO|glassfish3.1||_ThreadID=63;_ThreadName=Thread-1;|WEB0671: Loading application [restejb] at [/restejb]|#]

[#|2011-04-18T09:50:28.090-0700|INFO|glassfish3.1||_ThreadID=63;_ThreadName=Thread-1;|restejb was successfully deployed in 434 milliseconds.|#]

[#|2011-04-18T09:50:28.097-0700|INFO|glassfish3.1||_ThreadID=63;_ThreadName=Thread-1;|[AutoDeploy] Successfully autodeployed : /bapps/glassfish3/glassfish/domains/domain1/autodeploy/restejb.war.|#]

Bob N
SCJP - 1.4
SCJD - (B&S) Used 1.5 And It Runs On Solaris10
SCWCD - Thanks to HFSJ!!
Bob Nedwor
Ranch Hand

Joined: Aug 17, 2005
Posts: 215

It seems that at least part of the answer is here .

My NameBean needs @Singleton and some other things.

More on this later.

Thanks if anyone has any other answers.
Bob Nedwor
Ranch Hand

Joined: Aug 17, 2005
Posts: 215

Thanks to Milan Kuchtiak for the example previously referenced. I also changed my package from the default (none) to "name" like he did and I also added the ApplicationConfig class like he did (to demonstrate that not even a web.xml is necessary here). I rejarred and re-deployed.

What Milan does not show you is how to call these using curl (in case you do not want to go to the trouble of setting up NetBeans 6.8, etc). Here they are:

curl http://localhost:8081/restejb/resources/application.wadl
curl http://localhost:8081/restejb/resources/name
echo "New Name" > data
curl -T data http://localhost:8081/restejb/resources/name
curl http://localhost:8081/restejb/resources/name
I agree. Here's the link:
subject: Help With Rest EJB
jQuery in Action, 3rd edition