java

Possible ways to abstract away hard-coded path-names for properties file in java app

I'm trying to bind in a third party app to our project but have discovered that the unix paths of their property files have been hard-coded into several classes. It is probably possible to make minimal changes to their setup, so my question is: what are the possible (and quickest) ways to achieve this? The third party app uses neither an...

Using the same service & DAO from two threads

Hi guys, I've made a very simple REST controller method with Spring 3.0.0.RC1 that uses hibernate to perform a query. The query takes about ten seconds to complete. I've made this with intent so that I can fire up two requests to my controller. Then I fire up the two requests, and query in MySQL (my DB backend) "show full processlist",...

OC4J problem with ssl (secure-web-site.xml)

I'm working on eclipse and after making some changes in application and redeploying EAR file on OC4J server (i've added ssl support) my application binding in secure-web-site.xml ( i mean: tag) disappears or rather is not adding. What do i have to do to get this done automatically ? ...

Output a JTextPane's content to an HTML file

I am working on a bug in this program where it should be able to save the contents of a JTextPane to a formatted HTML file. The code that is currently there save a file containing just the tags but no content. The page appears blank but all the correct <p> and <font> tags are there with the correct colour set etc. HTMLDocument htmlDoc =...

Can apache FileUtils.writeLines() be made to append to a file if it exists.

The commons FileUtils look pretty cool, and I can't believe that they cannot be made to append to a file. File file = new File(path); FileUtils.writeLines(file, printStats(new DateTime(), headerRequired)); The above just replaces the contents of the file each time, and I would just like to keep tagging this stuff to end just as this c...

How to Configure Hibernate with Eclipse Galileo

Can someone tell me how to configure hibernate (Annotations) with Eclipse? ...

How to JMockIt System.getenv(String)?

What I have right now I have a 3rd party singleton instance that my class under test relies on and that singleton is using System.getenv(String) in its constructor. Is it possible to mock this call? I tried this JMockIt Example new Expectations() { System mockedSystem; { System.getenv( "FISSK_CONF...

Is there any Spring-Security-based production-ready security package for Java?

I'm designing the security subsystem for a new product. The system requires the following: Complex user/group/permission model, both service-level and domain-level (ACL) Administration UI for the above Rules performed upon user actions (account disable on failed login, password complexity requirements, etc). Before going ahead and im...

How to limit a JTextArea to only accept a legal set of characters?

Anybody know if there is an easy way to limit the allowed characters for a JTextArea. I.e. similar to JTextField using MaskFormatter. Specifically I want to limit the allowed characters for a JTextArea to only uppercase characters and only a very limited set characters like !"#¤%&/()= ...

java.lang.NoClassDefFoundError: javax/mail/Authenticator, whats wrong?

Send to Email.java package helper; //Mail.java - smtp sending starttls (ssl) authentication enabled //1.Open a new Java class in netbeans (default package of the project) and name it as "Mail.java" //2.Copy paste the entire code below and save it. //3.Right click on the file name in the left side panel and click "compile" then click "R...

JDO Transaction in Google App Engine

I am reading the following tutorial Take the following code example. import javax.jdo.Transaction; import ClubMembers; // not shown // ... // PersistenceManager pm = ...; Transaction tx = pm.currentTransaction(); try { tx.begin(); ClubMembers members = pm.getObjectById(ClubMembers....

trouble with writing hibernate query

Hiya, I'm sort a newbie when it comes to hibernate so I'm going to try to ask my question as clearly as possible. I wanna execute following query as hibernate query . <sql-query name="updateINFO"> update info set status_id = 2 where pid = :i </sql-query> Now i is a dyn...

token parsing in java

i have created a file with printStream object as shown below. PrintStream outPutOffice = new PrintStream( new BufferedOutputStream(new FileOutputStream(inDir+"/Office.txt"))); outPutOffice.print(fValue + (findx < agtOffColCount ? "|" : "")); now i have to read it content and sepeate it tokens with "|" as i have written token with "...

jetty: put index.html into webroot

when started, jetty per default loads all directories and war-files in its webapps directory, that i can access via context path (e.g. http:// hostname/app/ to access the project in webapps/app.war). Now when i open http:// hostname/ i get an 404 error and a list of the available contexts. To avoid that, i placed an index.html in the w...

is there another way of solving this problem ?

i have a list 1 column and 100 rows each with a number the number on each row may not be unique i need to output the unique list of numbers sorted according to their rank , which is less if the number of its repetitions is more. least ranked number i.e 1 is on the top now here is how i am planning to solve this problem first i want to...

Android: Problem/bug with ThreadSafeClientConnManager downloading images

For my current application I collect images from different "event providers" in Spain. Bitmap bmp=null; HttpGet httpRequest = new HttpGet(strURL); long t = System.currentTimeMillis(); HttpResponse response = (HttpResponse) httpclient.execute(httpRequest); Log.i(TAG, "Image ["+ strURL + "] fetched in [" + (System.currentTimeMi...

How to identify when my session variable is changed?

I am having a session variable whose value can be changed from java and from Jsp as well. Is it possible to detect when this variable's value is changed? ...

How to validate a xml file against a given xsd file while parsing it with a sax parser?

I want to parse a xml file using a SAXParser or XMLReader and verify that the file conforms to a specific xsd file (new File( "example.xsd" )). It's easy to do the validation against a xsd file in an extra step using a Validator like in this SO answer. to validate while parsing by specifying the name of the xsd as "http://apache.org/...

Are all final class immutable?

Are all final classes in Java immutable. String and Integer both are final classes and both are immutable i beleive. ...

Java calendar engine

Does anybody know any engines for calendar implementation? For example, which accepts event definition object (it can be iCalendar-style) and current date as input and outputs whether this date matches event definition? ...