Wednesday, January 31, 2007

Developing the JEE application, how tears appeared in my eyes... [an update]

Hi,

Last night I blogged about my misfortunes with NB's JEE support and promised to keep on updating while I thought I was making progress. And there's something more to tell.

And some progress was made since my previous blog. I found out that I can actually run the application and test the WS from the IDE (right-click on the WS and test it), but I can't debug the application. That results in errors.
When I start debugging the application, I get the following output in NB's output window for ANT:

pre-init:
init-private:
init-userdir:
init-user:
init-project:
do-init:
post-init:
init-check:
init:
deps-jar:
deps-j2ee-archive:
pre-pre-compile:
pre-compile:
do-compile:
post-compile:
compile:
pre-dist:
do-dist-without-manifest:
do-dist-with-manifest:
post-dist:
dist:
run-debug:
Distributing
C:\Iwan\SticktailGames\projects\FriendOrFoe\backend\IFFServer\dist\IFFServer
.ear to [localhost:4848_server]
Start registering the project's server resources
Finished registering server resources
deployment started : 0%
deployment finished : 100%
Deploying application in domain completed successfully
Trying to create reference for application in target server completed
successfully
Trying to start application in target server completed successfully
WARNING:
JDO76614: Deployment encountered SQL Exceptions:
JDO76609: Got SQLException executing statement "CREATE TABLE
SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL, PRIMARY KEY
(SEQ_NAME))": org.apache.derby.client.am.SqlException: Table/View 'SEQUENCE'
already exists in Schema 'IWAN'.
JDO76614: Deployment encountered SQL Exceptions:
JDO76609: Got SQLException executing statement "CREATE TABLE
IFFPLAYER_IFFALLIANCE (alliances_ID BIGINT NOT NULL, members_ID BIGINT NOT
NULL, PRIMARY KEY (alliances_ID, members_ID))":
org.apache.derby.client.am.SqlException: Table/View 'IFFPLAYER_IFFALLIANCE'
already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "CREATE TABLE
IFFALLIANCE (ID BIGINT NOT NULL, ALLIANCE_NAME VARCHAR(255), PRIMARY KEY
(ID))": org.apache.derby.client.am.SqlException: Table/View 'IFFALLIANCE'
already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "CREATE TABLE
IFFGAMEFIELD (ID BIGINT NOT NULL, INITED SMALLINT DEFAULT 0, FIELDTYPE
INTEGER, ARMY INTEGER, SOUTHEAST_ID BIGINT, NORTH_ID BIGINT, PLAYER_ID
BIGINT, NORTHEAST_ID BIGINT, PRIMARY KEY (ID))":
org.apache.derby.client.am.SqlException: Table/View 'IFFGAMEFIELD' already
exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "CREATE TABLE
IFFPLAYER (ID BIGINT NOT NULL, TAG VARCHAR(255), PLAYER_NAME VARCHAR(255),
LANG VARCHAR(255), PRIMARY KEY (ID))":
org.apache.derby.client.am.SqlException: Table/View 'IFFPLAYER' already
exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "ALTER TABLE
IFFPLAYER_IFFALLIANCE ADD CONSTRAINT FFPLYRFFLLNCllncsD FOREIGN KEY
(alliances_ID) REFERENCES IFFALLIANCE (ID)":
org.apache.derby.client.am.SqlException: Constraint 'FFPLYRFFLLNCLLNCSD'
already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "ALTER TABLE
IFFPLAYER_IFFALLIANCE ADD CONSTRAINT FFPLYRFFLLNCmmbrsD FOREIGN KEY
(members_ID) REFERENCES IFFPLAYER (ID)":
org.apache.derby.client.am.SqlException: Constraint 'FFPLYRFFLLNCMMBRSD'
already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "ALTER TABLE
IFFGAMEFIELD ADD CONSTRAINT FFGMEFIELDSTHASTID FOREIGN KEY (SOUTHEAST_ID)
REFERENCES IFFGAMEFIELD (ID)": org.apache.derby.client.am.SqlException:
Constraint 'FFGMEFIELDSTHASTID' already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "ALTER TABLE
IFFGAMEFIELD ADD CONSTRAINT FFGAMEFIELDNORTHID FOREIGN KEY (NORTH_ID)
REFERENCES IFFGAMEFIELD (ID)": org.apache.derby.client.am.SqlException:
Constraint 'FFGAMEFIELDNORTHID' already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "ALTER TABLE
IFFGAMEFIELD ADD CONSTRAINT FFGAMEFIELDPLYERID FOREIGN KEY (PLAYER_ID)
REFERENCES IFFPLAYER (ID)": org.apache.derby.client.am.SqlException:
Constraint 'FFGAMEFIELDPLYERID' already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "ALTER TABLE
IFFGAMEFIELD ADD CONSTRAINT FFGMFIELDNRTHASTID FOREIGN KEY (NORTHEAST_ID)
REFERENCES IFFGAMEFIELD (ID)": org.apache.derby.client.am.SqlException:
Constraint 'FFGMFIELDNRTHASTID' already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "CREATE TABLE
SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL, PRIMARY KEY
(SEQ_NAME))": org.apache.derby.client.am.SqlException: Table/View 'SEQUENCE'
already exists in Schema 'IWAN'.
JDO76609: Got SQLException executing statement "INSERT INTO
SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)":
org.apache.derby.client.am.SqlException: The statement was aborted because
it would have caused a duplicate key value in a unique or primary key
constraint or unique index identified by 'SQL061208085840450' defined on
'SEQUENCE'.
Enable of IFFServer in target server completed successfully
Enable of application in all targets completed successfully
All operations completed successfully
Duplicated project name in import. Project IFFServer-impl defined first in
C:\Iwan\SticktailGames\projects\FriendOrFoe\backend\IFFServer\nbproject\ant-
deploy.xml and again in
C:\Iwan\SticktailGames\projects\FriendOrFoe\backend\IFFServer\nbproject\buil
d-impl.xml
connect-debugger:
Non-existing path
"C:\Iwan\SticktailGames\projects\FriendOrFoe\backend\IFFServer\${javac.class
path}" provided.
Attached JPDA debugger to localhost:9009
pre-run-deploy:
Redeploying
C:\Iwan\SticktailGames\projects\FriendOrFoe\backend\IFFServer\dist\IFFServer
.ear
Start registering the project's server resources
Finished registering server resources
While redeploying, trying to stop the application in target server
completed successfully
While redeploying, trying to remove reference for application in target
server completed successfully
deployment started : 0%
Deploying application in domain failed; Could not rename
C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFSe
rver to
C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFSe
rver_old
At least one operation failed
C:\Iwan\SticktailGames\projects\FriendOrFoe\backend\IFFServer\nbproject\buil
d-impl.xml:174: Deployment error:
The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 34 seconds)


Appearantly, mentioned in a reply on a post from me on the NBUSERS mailing list, I have to add DROP statements in my DDL, which should fix things. Something I'll try tonight, it would be great to be able to debug the application using a debugger instead of System.out.println(...) statements all over the place.

Iwan

Tuesday, January 30, 2007

Developing the JEE application, how tears appeared in my eyes...

Update: I fixed the first exception mentioned in this blog. I had two methods in the WS with the same name but different params. And yesterday I probably didn't compile the -war project, which I did today. Really annoying NB doesn't take care of this.

As promised in yesterday's blog, I would keep you all posted on my proceedings... Unfortunately there's a lot of misery going on.

So I moved towards a JEE application and that was easy as can be. I created a new Enterprise project and two additional modules were created, one for the ejb's and one for the web part. Excellent. And as intended the newly created project was also the main project.

I then created some entities and had NB create as much as possible, which went like a breeze. Same goes for some stateless session-facades that would actually take care of my transaction problems. NB generated everything nicely and did so for remote and local interfaces as well. How it worked? Like a charm.

Next was a webservice, again NB generated all code and I was on a roll. Added some functionality and hit F11... nothing happened but an error message. As it turned out, the two additional projects weren't compiled as a result of a build of the JEE project.
There's no way to set anywhere in the project's properties to build dependent projects as well, so my guess is that NB should've done this all by itself. Yet it didn't.
So I build both projects myself, and did some experimentation... and as it turned out, when compiling the war project it had the same problem. Since the WS is using the SessionFacade it requires the -ejb project to be build and use its resulting JAR. Since that project is not build as a result of building the -war project, the build of the -war project fails. Hmmm, so I need to build dependencies by hand? First tears started to emerge. This is not what I am use to with NB.
After building everything by hand in the right order I run my project and what do you know... it all worked. Yippie... time to shutdown my laptop and go to sleep.

Tonight I wanted to continue where I left my proceedings last night. And this is where the real misery started and I'm getting the feeling that JEE support in NB is not as good as Roman's demo's show.
So what is happening? Well, nothing to be honest. Nothing has changed. Really nothing, honestly. But now when I run my project, it can't find the WS' WSDL file. Here's the output I get.

Problem encountered during annotation processing;
see stacktrace below for more information.
modeler error: Request wrapper bean names must be unique and must not clash with other generated classes. Class: com.sticktailgames.iff.backend.ws.WSPlayerServiceImpl method register(java.lang.String,java.lang.String,java.lang.String)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.onError(WebServiceAP.java:204)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.onError(WebServiceAP.java:193)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.onError(WebServiceAP.java:189)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceWrapperGenerator.generateWrappers(WebServiceWrapperGenerator.java:220)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceWrapperGenerator.processMethod(WebServiceWrapperGenerator.java:146)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitMethodDeclaration(WebServiceVisitor.java:470)
at com.sun.tools.apt.mirror.declaration.MethodDeclarationImpl.accept(MethodDeclarationImpl.java:41)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.processMethods(WebServiceVisitor.java:408)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.postProcessWebService(WebServiceVisitor.java:363)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceWrapperGenerator.postProcessWebService(WebServiceWrapperGenerator.java:121)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitClassDeclaration(WebServiceVisitor.java:169)
at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(ClassDeclarationImpl.java:95)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.buildModel(WebServiceAP.java:347)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.process(WebServiceAP.java:232)
at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258)
at com.sun.tools.apt.main.Main.compile(Main.java:1102)
at com.sun.tools.apt.main.Main.compile(Main.java:964)
at com.sun.tools.apt.Main.processing(Main.java:95)
at com.sun.tools.apt.Main.process(Main.java:85)
at com.sun.tools.apt.Main.process(Main.java:67)
at com.sun.tools.ws.wscompile.CompileTool.buildModel(CompileTool.java:605)
at com.sun.tools.ws.wscompile.CompileTool.run(CompileTool.java:538)
at com.sun.tools.ws.util.ToolBase.run(ToolBase.java:56)
at com.sun.tools.ws.util.WSToolsObjectFactoryImpl.wsgen(WSToolsObjectFactoryImpl.java:44)
at com.sun.enterprise.webservice.WsUtil.runWsGen(WsUtil.java:1820)
at com.sun.enterprise.webservice.WsUtil.genWSInfo(WsUtil.java:2089)
at com.sun.enterprise.deployment.backend.AppDeployerBase.loadDescriptors(AppDeployerBase.java:328)
at com.sun.enterprise.deployment.backend.AppDeployer.explodeArchive(AppDeployer.java:332)
at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:182)
at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:129)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)
error: compilation failed, errors should have been reported
wsgen successful
Error parsing WSDLC:\Programs\Sun\AppServer\9.UR1\domains\domain1\generated\xml\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\wsdl\WSPlayerServiceImplService.wsdl (The system cannot find the file specified)


So I'm a bit mystified when it comes to this since everything worked fine yesterday. Messing around with this kind of stuff like this takes too much time. I should just work, or it should hint better at how to solve my problems.
Worse yet, when I re-run the project, I get an error that it can't deploy the application, because Sun AS is not allowing the deletion of the the ear-file.

ADM1006:Uploading the file to:[C:\Documents and Settings\Iwan\Local Settings\Temp\s1astempdomain1server1400139303\IFFServer.ear]
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFServer-ejb.jar
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFServer-ejb.jar failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFServer-ejb.jar failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFSharedLib.jar
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFSharedLib.jar failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFSharedLib.jar failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFServer-ejb.jar
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFServer-ejb.jar failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFServer-ejb.jar failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFSharedLib.jar
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFSharedLib.jar failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib\IFFSharedLib.jar failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF\lib failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war\WEB-INF failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer\IFFServer-war_war failed; now marked for delete-on-exit
UTIL6040: Error attempting to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer
UTIL6041: Performing gc to try to force file closures
UTIL6043: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer failed after 4 retries
UTIL6048: Attempt to delete C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer failed; now marked for delete-on-exit
Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: Cannot delete existing directory C:\Programs\Sun\AppServer\9.UR1\domains\domain1\applications\j2ee-apps\IFFServer, possibly due to one or more open files or streams; these may interfere with later deployment attempts so you may need to manually delete this directory and/or restart the server to release the open files
at com.sun.enterprise.deployment.backend.AppDeployer.cleanAndCheck(AppDeployer.java:313)
at com.sun.enterprise.deployment.backend.AppDeployer.liquidateAppDirAndStubsDirIfTheyHappenToExist(AppDeployer.java:285)
at com.sun.enterprise.deployment.backend.AppDeployer.predeploy(AppDeployer.java:167)
at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:128)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)

Why is this happening? Why can't the interoperability between Sun AS 9 and NB55 both bundled, not be better, smoother? It only works after stopping Sun AS 9. That is just too time consuming, time I want to spend on developing not on waiting for an app server to start.

And while I'm at it, why can clear the app servers output window, but when I run my project the whole log is displayed, not the log from that point on? What's the use of that?

Well... I'm going ahead and try to figure out what's going on and try to fix things. I'll be posting my proceedings through this.

Iwan

Monday, January 29, 2007

And now I'm moving towards full fledged JEE development

Yesterday I moved my project into the realm of JEE with EJB and all. Coming from a web only application I stumbled in too many problems I didn't want to think about too much. Most of them had to do with transaction management, lousy design (on my part), and getting used to developing serverside code in NB55 (I only used MobPack for the last 12 months or so) didn't help either.
I downloaded Spring this weekend and thought it would solve all of my problems, just like a friend of mine promised, but the lack of a tutorial that would fit my needs and the lack of NB supporting it the way I'm used to NB supporting something made it a road I should have traveled.

So let me tell you something about what I am developing that is so different from all that I've seen. And probably it isn't.
I'm working on a server that is accessible by J2ME clients, they are nothing more than thin clients it turns out. It's all for a game we're developing and the world the game takes place in is ever expanding. So I have a server that serves the requests from the clients through NB's generated servlet interface. I blogged about that a while ago, a feature that is really helpful, but there are some improvements thinkable. So I went the servlet way.
The ever expanding universe I thought of doing using a thread started in a servlet. Something I shouldn't do, but still can get away with in Sun AS9 and the thread is running nicely doing its job the way I intended… almost. That is where the problems started. Every time I tried to do something with the database, I got an exception upon the commit of the transaction. I tried everything I could think of this weekend. Instantiating new EntityManagers, UserTransactions, additional PersistenceUnits etc, but I couldn't get rid of the exception. Everything I was doing with the database from the servlet code itself worked like a charm. Ergo I thought about the thread opening an URL and have the servlet behind that URL do the work the thread was supposed to do, but I dismissed that idea straight away. I knew I was sinking in the swamp enterprise development can be, but I didn't want to sink that deep. I knew also that I had a Scheduler in stock that would periodically poll the database to see if there were any jobs scheduled and than execute those jobs. Another thread in the system, that I saw doomed to fail, just like my UniverseExpander. I know I shouldn't use threads in a server application anyway.
So Spring to the rescue, but as it turns out, a quick google on "Spring, tutorial, JPA" got me with either tutorials that assumed extensive knowledge of Spring (which I don't posses), or with tutorials that incorporated Spring MVC. Problem here is that I don't have a problem with the database handling from the web end of the application, it is with the 'JSE' part (the threads) of the application. And the JSE type of database handling didn't work for me.

After a weekend of strugling with the code, the problems etc I decided to spend Sunday night on a proper design. Forget about technologies and just make a proper design, the way I do when working on a client's project. I realized that EJB would help me with the transaction management and EJB3 allows me to work with POJOs all the way, which means that I can keep it fairly lightweight, something I need. Although the in-memory model will be huge… relatively, everything happening in the system will be based on single transactions, something that EJBs can handle nicely. For now that is.

I was a bit intimidated with the JEE stuff NB throws at you. You get 3 projects, not a lot of explanation of what is going on in what project and on top of that, it generates about everything I want to do. So I right- and left-click my way around NB and generate SessionBeans, Entities, WebServices and all without really having to do something. So this is what everybody is raving about when talking about NB and JEE… just as cool as J2ME support.

While designing I found that I need some kind of event system in the server as well, pointing me into the direction of JMS.

While googling I stumbled upon Quartz and decided to use it for my job scheduling instead of developing it by myself. It provides exactly what I want and more.

I will post my proceedings in this blog and hope it will be of help to people. This blog entry is more about what I was facing than about how I was solving… so maybe Spring and JPA and just web tier are coming back… for now it is all about full fledged JEE.

Iwan

Tuesday, December 19, 2006

Sun AS 9, its really fast, it beats NetBeans.

Okay, let me start of with stating that I am probably doing something wrong here, but yesterday I was amazed by the speed of Sun AS 9.

I'm working on a backend system that uses JPA, and connects with a MIDlet, or rather, at the moment the MIDlet is connecting with the backend. But that's not the issue today. The backend has a daemon running (a thread in the web tier) started by a servlet that generates a data-structure and expands it over time. Because I wanted this to be started at server startup, the thread was started in the servlet's overridden init() method. Because I wasn't sure whether or not my code was working, I set a breakpoint in the init() and started debugging. Guess what, nothing happened, the breakpoint was never hit! Adding some System.outs in the init() showed that it was called, NB's debugger was just never ready to stop on the breakpoint. It seems to be too slow, or the interaction between Sun AS and NB is not synched correctly.
So now I moved the code to the doGet and I kick off the thread in there. It all works nicely and my code works like a charm. And I can debug the code.

So what is going on? I tried several scenario's each time ensuring that I did a clean-build prior to my trial.

Scenario 1: Start my web app from NetBeans by hitting the debug button. Breakpoint in init() didn't pause the app.

Scenario 2: Start Sun AS in NetBeans in debug mode. Breakpoint in init() didn't pause the app.

Scenario 3: Start Sun AS in debug mode and start my web app from NetBeans by hitting the debug button. Breakpoint in init() didn't pause the app.

In all three scenario's the breakpoint in doGet() worked perfectly. Really weird, but at least after a lot of trial and restart of NB it worked, some way.

Iwan

Wednesday, December 13, 2006

J2ME connectivity with a server app... Ooops I did it again

Recently I was looking at connecting my MIDlet with a backend application running in Sun AS 9, of course developed in NetBeans as well and since I am not really sure whether or not WS are supported by the phones the MIDlet will run on, I generated, well I had NB generate the web connectivity. Really cool stuff.
Then I wanted it all to work, ie send data from the phone to the backend and have the data stored in a database, Java DB included by NB. To get some grips on the whole Java EE 5 thing, I had NB generate a CRUD frontend for the entity classes and I looked at the generated code. This is actually rather clean code and very comprehensive indeed. But from the NB generated servlet unusable. It took me some digging in the Java EE 5 tutorial to find out how to get it all up an running with PersistenceUnits, Resources, annotations and transactions, but I got it all running in the end. I added the annotation of the Persistence Unit to the generated servlet and changed the EndToEndSupport class (I'm not really sure that it is called exactly that way, but it was generated by NB during the generation of the backend connectivity). The change included providing the EntityManager obtained in the servlet to the actual code that is to do the persistency. This was about 2 minutes of work and I was thrilled to see it all working.

Now the "Ooops I did it again" comes into play. I changed the backend functionality a bit, or rather I moved some classes and added some features which wasn't a problem until I had NB generate the code again so I could use the new backend functionality from the MIDlet. All code I had changed to get the persistence working was gone. Fortunately I remembered what I had done, and it all was still in SVN, so not too much harm done.

And this is when I started wondering about where that checkbox is that asks me whether or not I want to use the JPA in the backend I am connecting to from my MIDlet and when checked it will generate all the code for actually persist data send across.... or maybe I am not looking in the right direction to read all about it. Anyway, the tutorial on mobility assumes a working webapp, the web tutorial assumes JSF to be used and it doesn't all come together in one tutorial... maybe I'll document my efforts more detailed, until then: Drop me an email if you get stuck on this.

E-One

Thursday, November 16, 2006

Collaborative AWE

Yesterday I was working with my good friend Marcel on our massive multi player mobile internet strategy game (mmpmis?). He had written an API that I recently incorporated in the game and he'd changed it on a conceptual level, so I had to redo a lot of work... not funny. But due to the collaboration support NB provides we could share the various sources and show in the actual code what we thought the other understood, how we wanted it all to work and after about 5 minutes we knew exactly what had to be done.
The chatting feature in NB was replaced by Skype, talking is soooo much faster than typing. The only thing we were missing was some 'free drawing' feature in the collaboration features, where you could circle something you want to focus on, draw lines and arrows to show where you want stuff to go etc. We needed a whiteboard in NB.

Marcel used to be an Eclipse guy, but more and more often he tells me "NB is really cool" or "This feature in NB is really cool". Collaboration in one of those features.

Iwan

Wednesday, November 15, 2006

NetBeans Mobility Pack for CDC final?

I've played with the final release of NB55 and it really is great. I have some gripes still (Can't get the UML projects into SVN, this just doesn't seem possible). I'll file an issue sometime soon.
The UML projects are great though. Especially for Java ME stuff, a good design is really important when you have to put good programming practices aside because that just isn't efficient enough. Sofar I've used the State Diagram and some Class diagramming. But it really is great. Works pretty much like a charm, although there are some little nuisances. All will be files as an issue once I know it's not me.

Another little issue is the fact that the CDC version of MobPack isn't available for the final release. Integration of emulators from Sony Ericsson and Nokia still seems less than excellent. But the lack of a final version is a shame.

Any ideas on its release NB MobPack guys?

Iwan

Monday, October 30, 2006

NB 55 is out... and it is NB 55

Hi,

Yesterday I blogged that after installing NB55 and all additional packs, I got an 5.5RC2 userdir. Today I uninstalled everything again, deleted all files, restarted my laptop and installed everything again. Now it works as expected and I get the 5.5 userdir.

Only thing that's left at the moment is enjoying working with it and starting anticipation on the 6.0 release :)

Iwan

Sunday, October 29, 2006

NB 5.5 is out... Ooops, minor mistake... it seems RC2 again

Hi,

I just downloaded all the downloads of the NB5.5 distribution, so that would be NB55 and all additional packs.
I then uninstalled all previous versions of NB, which were NB55 dev, RC1 and RC2 and the M3 release of NB6. Then all userdirs were removed from my system as well. So you can see I've got a clean NB environment. And on with the installation...
Everything worked fine and everything installed fine. Then it was time to start NB55. Finally it's been released. But surprise surprise, the /.netbeans doesn't show the 5.5 subdir, but the 5.5RC2 subdir. So is this the RC2 release all over again? I'm sure it's not, but it looks that way nonetheless.

Iwan

Wednesday, October 18, 2006

NetBeans 5.5 RC2 is out... just a few more nights.

It's been blogged about before, but they've released the second release candidate of NetBeans 5.5. For me it means that I can work with an even more stable version of NB55. I've got to say that it is very stable since a very long time. The only problems I now and then have is regarding SubVersion, but I'm not sure whether that is because of NetBeans, SubVersion or me. I can't reproduce the problems, and don't get a stacktrace. It's just that sometimes I have to move back to TortoiseSVN and fix things. Don't get me wrong, there is no harm done, I just have to leave my beloved IDE sometimes.

As you might know, I'm currenly working on J2ME stuff, and NetBeans is just the best in that area. NetBeans 5.5 has some major improvements in this area, most notably SVG support. The game we're currently working on uses TinySVG for our menu handling. Doing all the work ourselves using TinySVG and that looks great. But what I've seen sofar of the SVG support in NetBeans is excellent and promising. Now 55 just has be released and my fellow developers will switch as well. I'll keep you posted on how things progress.

Iwan

Friday, October 13, 2006

NLJUG J-Fall 2006

Hi,

Another developer's blog. Lasy Wednesday I went to J-Fall, the annual fall Java conference of the NLJUG (Dutch Java User Group).

It was an interesting day. A lot of interesting sessions, but unfortunately I was only able to attend the sessions in the afternoon. To start of with some negative remarks: It was way too hot during the sessions, which made me sleepy. Having said that, the sessions I attended were of a more than decent quality.
The afternoon keynote was all about Spring AOP or rather about AOP and how you can use AOP to have a better representation of your design in your code. Interesting stuff. In fact this was an eye opener for me, sofar I thought AOP was pretty much for adding log statements to your code automatically. Great stuff, although I think AOP won't be used on most of the projects I'll be involved in. I wonder when it will really catch on.
Another interesting session was about Seam, JBoss's glueware to tie a JSF frontend to an EJB backend. Apart from the session's topic, I learned about a great feature of NetBeans, namely to create a complete CRUD frontend based on an Entity in your backend. Now that is some great stuff I should have had on a project a few years ago. Well at that time I created something similar based on XDoclet.
I also attended a session about applying JSF when the frontend should run on a mobile devices, PDAs in this case. Although it was sort of a recap of last years J-Spring keynote on ADF faces, it was still interesting to hear about a real world project utilizing one of the promising features of JSF. Fairly well presented session also.
The last session I went to see was about Facelets and JSF. A relavant comment was given by the audience that hardly ever web-designers are working with their tools on the results of developers. XHTML containing Facelets in this case, although it was presented as one of the strong points of facelets. I think the audience was right and I wouldn't want web-designers to mess with my JSPs or XHTML. Have them either design a prototype of the GUI and let me reproduce it, or have them design it using CSS, which in fact I prefer. Interesting topic and Facelets is definitely something I would like to use soon. Hope NetBeans' Visual Web Pack will provide WYSIWYG Facelet support soon.

That's it for today, have a great day and enjoy what you're doing.
Iwan

Wednesday, October 04, 2006

Joy after reading the good news...

Today I read the good news, NetBeans 5.5 is in its Release Candidate phase. And MobPack is included. Great news. Even better news is that the Visual Web Pack will be released with 5.5 although not in its final state.
But the best news is that we're getting into a phase where 5.5 is rather stable and I can start convincing people to move to the next version. Why this is such good news? Well I've been playing with the new SVG stuff and now my MIDlets are unusable by the guys I work with. And I have to admit that they're right in that I shouldn't use pre GA versions of tools when developing games that we're supposed to release soon.

Anyway, great to read about the progress in NB.

Iwan