Mullin Yu

Greenhorn
+ Follow
since Feb 24, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mullin Yu

1. If using the following:

<webResources> <resource> <excludes> <exclude>**/log4j.xml</exclude> </excludes> </resource> <resource> <directory>${basedir}/src/main/webapp</directory> <targetPath>.</targetPath> <excludes> <exclude>**/osirisws-servlet.xml</exclude> </excludes> </resource> </webResources> <warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes>

got exception: [INFO] Trace java.lang.NullPointerException at org.apache.maven.plugin.war.AbstractWarMojo.copyResources(AbstractWarMojo.java:395) at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:325) at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:167) at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:133) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483) at – user509392 4 mins ago edit
got exception: [INFO] Trace java.lang.NullPointerException at org.apache.maven.plugin.war.AbstractWarMojo.copyResources(AbstractWarMojo.java:395) at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:325) at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:167) at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:133) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483) at

2. If using the following
<webResources> <resource><directory>${basedir}/src/main/resources</directory><targetPath>WEB-INF/classes</targetPath> <excludes> <exclude>**/log4j.xml</exclude> </excludes> </resource> <resource> <directory>${basedir}/src/main/webapp</directory> <targetPath>.</targetPath> <excludes> <exclude>**/osirisws-servlet.xml</exclude> </excludes> </resource> </webResources> <warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes> – user509392 35 secs ago edit
2. If using the following <webResources> <resource><directory>${basedir}/src/main/resources</directory><targetPath>WEB-INF/classes</targetPath> <excludes> <exclude>**/log4j.xml</exclude> </excludes> </resource> <resource> <directory>${basedir}/src/main/webapp</directory> <targetPath>.</targetPath> <excludes> <exclude>**/osirisws-servlet.xml</exclude> </excludes> </resource> </webResources> <warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes>

log4.xml still existing in WEB-INF\classes so, can't be excluded while osirisws-servlet can be excluded.
13 years ago


Currently, I want to exclude some files from the default src/main/resources folder into my WAR when packaging

I tried using maven-war-plugin with the following configuration but failed.

src/main/resources WEB-INF/classes *.xml

...WEB-INF/classes will still contain the XML files.

How to do so?
13 years ago
what's the advantage of using Spring's BeanFactory?

e.g.
public class SimpleFactoryBean implements FactoryBean {

public Class getObjectType() {
return TestBean.class;
}

public boolean isSingleton() {
return false;
}

public Object getObject() {
return new TestBean("Alef [factory]");
}
}
� and a small piece of XML:
Is there any method to get the user locale?

I found that there's a method getDefault(), but it seems get the system locale, but not the user locale.

Any ideas? Thanks!
18 years ago
hi,

after searching a bit on the net, i found some resources but out-dated. therefore, may i know that

1. which software/implementation are commonly used and adopted?
2. i want to create midi sounds (different instruments) by application and then play back
3. it would be good to have books/links recommended.

thanks!

cheers,
mullin
18 years ago
hi,

i have a simple question:

1. receive a string in the format, yyyymmdd
2. add ONE day to it, i.e. yyyymmdd+1 =>20050411+1 => 20050412
3. change it to java.sql.Date and then pass to PreparedStatement's setDate

PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setDate(1, newSQLDate);

how to do it?
18 years ago
hi, i have write a separate class to store the configuration at config.properties.

but, how i can tell the java vm to use it?

e.g. java testdemo

import java.util.ResourceBundle;

public class Resource {
private static final String BUNDLE_NAME = "config";//$NON-NLS-1$

private static ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
...
...
}
18 years ago
I need to generate a unique no. in the format like
yyyymmddxxxxxx (xxxxxx 6-digitl running number)

I think of create a table with two columns

date value
20050405 120
20050406 99

Everytime, the application will increase the value+1 based on the same date. If not date found, create one record and value = 1

The problem is that since there's no transaction at mysql 4.1.x that even the application
1. insert value
2. max() to get
max() may not get the value just insert BECAUSE there may be MULTI-threads/users

How can implement so with Java and mysql?
hi,

user views a file by browsing to a servlet at tomcat wap/login?path=2005/4/6/63213473/1748291/&filename=cDkwMHNhbXBsZS1leGNlbC54bHMuMDAwMQ%3D%3D&msisdn=63213473

the servlet code:
...
...
response.setContentType("image/jpeg");
response.setHeader("Content-Disposition", "inline; filename=" + saveFileName.substring(saveFileName.lastIndexOf("/")+1));
...
...

but, after user views the file on the mobile and try to SAVE it. the filename is not the one set on the Header => filename, but instead mobile phone uses &filename=cDkwMHNhbXBsZS1leGNlbC54bHMuMDAwMQ%3D%3D&msisdn=63213473 as the filename

any ideas on this?

thanks!
18 years ago
hi,

i use the following code, but the DateTime field at mysql is
2005-04-08 00:00:00

i want to have the time too. where should i change

..
..
// Get the system date and time.
java.util.Date utilDate = new Date();
// Convert it to java.sql.Date
java.sql.Date date = new java.sql.Date(utilDate.getTime());
..
..
..
PreparedStatement stmt = connection.prepareStatement(sql); stmt.setDate(1, date);
i got compilation error:
[javac] C:\opt\SVGT\Development\src\java\hk\com\smartone\svgtx\converter\Con
verter.java:104: local variable jpegConverted is accessed from within inner clas
s; needs to be declared final
[javac] jpegConverted = objConvertService.convert(_objAttachment.getData(),sExtension,"JPEG",((docconv.service.ImageProfile) (objObj
ect)));

as jpegConverted, _objAttachment, sExtension, objObject are outer class variables and some functions of outer class may need to get and set their values and can't assign those variables to final.

any methods to solve this?

try {
/* original code
objLog.info("before convert");
jpegConverted = objConvertService.convert(_objAttachment.getData(),sExtension,"JPEG",((docconv.service.ImageProfile) (objObject)));
objLog.info("after convert");
*/
//
Thread th = new Thread()
{
public void run()
{
objLog.info("before convert");
jpegConverted = objConvertService.convert(_objAttachment.getData(),sExtension,"JPEG",((docconv.service.ImageProfile) (objObject)));
objLog.info("after convert");
}
};
th.start();
th.join(100 * 1000);
if(th.isAlive())
{
th.interrupt();
throw new Exception("Timeout");
}
//
} catch(Exception _objException) {
objLog.err(sContentName + ": Others Exception returned by transcoder.",_objException);
convertSuccess = false;
}
18 years ago
inside my program, it will call a function of 3rd party java class, but sometimes it may hang and no error/exception thrown. then, my application doesn't work properly.

i want to know how to make the following thrown an exception after a period of time to my main program, some timeout exception? then, my application can continue processing.

try {
objLog.info("before convert");
jpegConverted = objConvertService.convert(_objAttachment.getData(),sExtension,"JPEG",((docconv.service.ImageProfile) (objObject)));
objLog.info("after convert");
} catch(IllegalFileTypeException _objIlegalfiletypeexception) {
objLog.err(sContentName + ": Illegal File Type Exception returned by transcoder.",_objIlegalfiletypeexception);
convertSuccess = false;
} catch(ConvertException _objConvertexception) {
objLog.err(sContentName + ": Convert Exception returned by transcoder.",_objConvertexception);
convertSuccess = false;
} catch(Exception _objException) {
objLog.err(sContentName + ": Others Exception returned by transcoder.",_objException);
convertSuccess = false;
}
18 years ago
import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.xpath.*;


public class DataMapper {

public static List getFieldList(int viewType) throws IOException, JDOMException {

SAXBuilder builder = new SAXBuilder();
Document doc = builder.build("http://localhost/xml/mapping.xml");

XPath fieldPath = XPath.newInstance("//field[ui-display=\"Value1\" or ui-display=\"Value2\"]");
List fields = fieldPath.selectNodes(doc);

return fields;

}
}
19 years ago