Dave Elwood

Ranch Hand
+ Follow
since Dec 27, 2002
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dave Elwood

I've got a desktop application with a JFrame holding a JPanel depicting all sorts of lines and circles.

I can click on the JPanel and call forth all kinds of functionality with my own MyMouseListener,
however instead of just leftClick and rightClick,
I'd like to do Ctrl + LeftClick or 'A' + RightClick to expand functionality.

MyMouseListener works just fine. However MyKeyListener takes no notice of when I use the keyboard.
JPanel is a JComponent, so why doesnt it react to keyboard usage?
Am I on the wrong track?

8 years ago
Thank you Sameer, now it works like a charm.
It compiles and runs, but there are three records, and the last record has room_id = 3 but this returns a value of 0
when I use

then I get a value of 2147483647

How do I get it to show me the value of 3??
I'm writing a JavaEE6 app using NetBeans and persisting the entities on Glassfish
I've got a table of rooms with the Entity Room class to access the data.
The primary key is room_id and I need to find the last value used in order to bump up
the value and then insert a new room record.

So...in order to find the last value used I have a named query which calls the aggregate function MAX

In the session bean I fetch the value this way

Is there a member function of the Query object which returns the value MAX(r.roomId) ??
Something like :

this is what the whole Entity class looks like
Found it, this is how to find the instance of Company....

9 years ago
I've got JavaServer Faces to work now with the following :

in the class Company I have :

The list has objects :

in MyConverter :

What happens in System.out :

The index.xhtml is loaded and this happens
INFO: ctor
INFO: getAsString() Person lastName value : Adams
INFO: getAsString() Person lastName value : Bumstead
INFO: getAsString() Person lastName value : Chester

I select the second on the list and nothing is added here

Then I press commandButton and the following happens

INFO: MyConverter.getAsObject() value : Bumstead

INFO: ctor // just kills the selection I made !!!

INFO: doSomething selectedPerson = null
INFO: getAsString() Person lastName value : Adams
INFO: getAsString() Person lastName value : Bumstead
INFO: getAsString() Person lastName value : Chester

Now, when the command button is pressed,

the routine getAsObject(...) in MyConverter is called.

I presume that there I'm supposed to come up with a Person object as a return value of getAsObject

which corresponds to the "Bumstead" string I selected in the list.

I need a handle to the Company instance but these two arguments,

javax.faces.context.FacesContext context and

javax.faces.component.UIComponent component are vague and don't help at all.

In getAsObject() how can I access the Company instance so that I can access the persons list so that I can

access the Person object the label and value are pointing to?
9 years ago
I've been going nuts with the same kind of stuff.

Take away the Local and Stateless tags. Does it work then?
I've found that strange things must be done to make this work.

In Netbeans under the Services tab, you right click on JavaDB and define where the databases are to be sought.

I put in D:\Glassfish3\glassfish\databases -

Before Netbeans does anything with any database, glassfish and then the database server must be turned on and when you turn them on the current directory must be somewhere other than D:\Glassfish3\glassfish\bin where asadmin.bat lies. To turn on glassfish and then the database server I made a batch file with the path to asadmin.bat written out fully :

putting the current directory far away from D:\Glassfish3\glassfish\bin is necessary otherwise the databases will originate in that directory.
putting the current directory on E:\ causes the database creation directory to be D:\Glassfish3\glassfish\databases - don't ask me why.

possibly during previous muck-ups the databases were created in the D:\Glassfish3\glassfish\bin folder and along
with that, a derby.log file and a derby.properties file. And then in the future, some process was looking for a neat place to
create the database files and since D:\Glassfish3\glassfish\bin is on PATH it looked there, saw derby.log and derby.properties
and said "this is the place".

So I wipe away ALL derby.log and derby.properties files.

With both servers up and running I go to the admin console

A. in Resources / JDBC / JDBC connection pools / SamplePool
Under the third tab is 'further properties'
here : URL = jdbc:derby://localhost:1527/newDBName
Save should bring up a green ok

B. then in Resources / JDBC / JDBC Resources
add a new resource jdbc/newDBName
OK should not bring up any message

At this moment a new database folder newDBName appears under the databases folder, if not then
you were in the wrong seat when the plane crashed. Turn off both servers and turn then on again
and make sure that when turning on the database server the current dir is not where the glassfish\bin directory is.

So the new directory in glassfish\databases\newDBName is there.

So now turn both servers off.

Run Netbeans and write the Entity Bean app or modify an existing Entity Bean app (javaee6).
In persistence.xml is the name of the database. change the value to jdbc/newDBName and compile it.
Run it and Netbeans will turn on glassfish and the database server for you and do its job.

Then turn off Netbeans and turn glassfish and the database server on again for normal mortal use.
then localhost:8080/entitybeanapp. should do the job too.

Hope this helps somebody.
9 years ago
A few days ago when trying to get a glassfish database to run It told me to run :

java -Dij.something.something=somesuch

before starting ij.bat

okay, that worked.

Now I wish to set the system property derby.system.home, so in a batch file I write

java -Dderby.system.home=C:\derby

and java spills out the help screen contents

-- Sorry, that command needs to be followed by a class to execute
9 years ago

maybe this will help, maybe not.

I have windows xp and have netbeans 7.1 with glassfish 3.1.1 installed.

under netbeans I ran a web app MyWebApp with javaee (entity beans) and placed info in a database "sample". It appears to be
created at C:\Documents and Settings\David\.netbeans-derby\ in the form of a folder named "sample".
Whenever I use netbeans, the glassfish server and the database are started and when I stop netbeans the glassfish server and the database turn off.

I then must copy the folder to %DERBY_HOME%\bin !! when the database is OFF !!
Then with asadmin.bat start-domain and asadmin.bat start-database get the show running again.
Then with the browser and http://localhost:8080/MyWebApp I can look at the database.

But !! don't forget, netbeans puts the database in C:\Documents and Settings\David\.netbeans-derby\ [for some strange reason]
and when using glassfish server like a normal human, without netbeans, the database must be in %DERBY_HOME%\bin [for yet another strange reason]

hope that helps
how are you writing the web app?

are you using the javaee libraries and glassfish server?

You've got to do some mapping.

I am writing stuff like that now and I found that after Tomcat 4 you need to add some extra stuff to the web.xml file when writing the app.

look at this one.

if you call localhost:8080/Servlet1, this calls a goodie by the name of test and the goodie by the name of test is actually a servlet class called Servlet1
if you call localhost:8080/dogfood, this calls a goodie by the name of test and the goodie by the name of test is actually a servlet class called Servlet1

url-patterns leads to servlet-name which leads to servlet-class.

hope it helps

9 years ago
I've installed Netbeans 7.1 IDE with the option to install Glassfish 3.1.1 as well.

So under netbeans I've written a JavaEE web app which writes to database jdbc/sample...and it does....under C:\Documents and Settings\David\.netbeans-derby\ is a folder 'sample'

However it is necessary to copy this folder to D:\Glassfish3\javadb\bin\ in order for glassfish running completely indepent of netbeans to use the sample db.

in short : Netbeans creates, reads and writes a db and it shows up in C:\Documents and Settings\David\.netbeans-derby\
Glassfish reads and writes a db and sees it only in D:\Glassfish3\javadb\bin\

How can I get these two guys to agree on a common place to park the sample database folder??
9 years ago
sorry, my comments are off-base
For a week I have been trying to make javaee6 work

I can't get a session bean to show itself in an enterprise application using the netbeans 7.1 IDE

I have the web-application "entmodel7-war"

I have the ejb-application "entmodel7-ejb",

an interface

and an implementation

the entmodel7-ejb.jar is automatically added to the library of the entmodel7-war web app

with entmodel7, the enterprise application project as main project, I say clean and build and :

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197: An error occurred at line: 1 in the jsp file: /index.jsp

PWC6199: Generated servlet error:
cannot find symbol
symbol: class Sushi
location: package ejb

PWC6197: An error occurred at line: 1 in the jsp file: /index.jsp

PWC6199: Generated servlet error:
cannot find symbol
symbol: class Sushi
location: package ejb

PWC6197: An error occurred at line: 1 in the jsp file: /index.jsp

PWC6199: Generated servlet error:
cannot find symbol
symbol: class Sushi
location: package ejb
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:129)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:299)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:392)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)

what am I doing wrong??
Very good Maneesh.

It didn't find the answer directly--it doesn't include netbeans 7 jars -- but from the appearance of the jars it did find, I was able to seek out a similar sounding jar (*javaee-api*.jar) and found the little so-and-so in the netbeans area under javaee-api-6.0.jar

Many Thanks !