I wrote a jsp application, and if I generate a war file with eclipse in windows XP, language: tradition Chinese. and deploy to weblogic,
it will have such problem:
inputAdministrator.jsp:251:11: This type name is ambiguous because it matches more than one '*'-import, including 'java.io.*' and 'admin.iguard.businessObject.*'.
DataInput d = (DataInput) dataInput;
^-------^
inputAdministrator.jsp:252:29: Type java.io.DataInput contains no methods named getDept1.
String dept1 = d.getDept1();
^------^
inputAdministrator.jsp:253:26: No match was found for method trim() in type <error>.
String emp2 = d.getEmp2().trim();
^----------------^
inputAdministrator.jsp:253:28: Type java.io.DataInput contains no methods named getEmp2.
String emp2 = d.getEmp2().trim();
^-----^
inputAdministrator.jsp:254:29: Type java.io.DataInput contains no methods named getDept2.
String dept2 = d.getDept2();
^------^
inputAdministrator.jsp:255:33: Type java.io.DataInput contains no methods named getDept_code.
String dept_code = d.getDept_code();
^----------^
inputAdministrator.jsp:256:32: Type java.io.DataInput contains no methods named getStaff_no.
String staff_no = d.getStaff_no();
^---------^
inputAdministrator.jsp:257:32: Type java.io.DataInput contains no methods named getEmp2_por.
String emp2_por = d.getEmp2_por();
^---------^
if I generate the war file in windows xp, simplize Chinese, and deploy to weblogic, everything will be OK.
I don't know how the "text file encoding" setting will affect the generated war file,
how can i make sure that all this things are in sync.
Any one have better solution?
Any suggestions will be appreciated.
Thanks in advance!
did you check it? does text encoding changes in both the j2ee exports as a WAR file?
windows-->preferences-->General-->workspace-->textfileencoding?
it defaults to cp1532
what is the value of textfileencoding variable set in simplize Chinese as compared to tradition Chinese ??
May be the "text file encoding" triggers some kind of recompilation which makes that issue visible.
In any case, could you try first to disambiguate the DataInput usage, by:
adding for example "java.io."(in front of DataInput) everywhere in that source where it is actually a java.io case (leaving a simple DataInput for businessObject usages)
not using import java.io.* (but using CTRL+SHIFT+O for reorganizing the imports)
would that solve the problem, whatever the "text file encoding" is?
Related
Like the title says, is it possible the tutorial at https://www.arangodb.com/tutorials/spring-data/ is outdated? I'm having several problems, but don't know how to workaround the last one:
Part 2, "Save and read an entity"
I get an error: method getId() is undefined.
Workaround: I added a getter in class Character.
Also in "Save and read an entity"
final Character foundNed = repository.findOne(nedStark.getId());
The method findOne(Example) in the type QueryByExampleExecutor is not applicable for the arguments (String)
Workaround: I used find by example:
final Optional<Person> foundNed = repository.findOne(Example.of(nedStark));
Part 1, "Create a Configuration class"
public class DemoConfiguration extends AbstractArangoConfiguration {
Gives me an error:
"No constructor with 1 argument defined in class 'com.arangodb.springframework.repository.ArangoRepositoryFactoryBean'"
Workaround: ?
Can anyone point me in the right direction?
I found the demo project on github: https://github.com/arangodb/spring-data-demo
Number 1: They use a getter too.
Number 2: Was my fault, I did try ArangoRepository (of Character, Integer) but forgot that Id is a string.
Number 3: They don't seem use any Configuration (AbstractArangoConfiguration) class in the source at all although it is still mentioned in that tutorial. I think now the config and connection is handled by spring autoconfigure. Though I would like to know how the Arango driver is set, all I could find that may point further is ArangoOperations.
Anyway it works now, maybe this helps somebody else who is having the same problems.
I am trying the example of uima ruta:
here.
I want to create ruta script and apply it to my text (from plain java without any workbench).
1.how do i get the type system descriptor from plain java (without workbench)?
2. when do i get it with workbench? (if i "run" the ruta script, no description were made.)
The main question is whether the script declares new types.
If no new types are declared, the linked examples in the documentation should be sufficient.
If new types are declared in the script, then a type system description needs to be created and included in the creation process of the CAS before the script can be applied on the CAS.
The type system description of a script containing the type descriptions of the types declared within the script can be created the following ways:
The Ruta Workbench creates the type system description automatically for each script within a simple Ruta Project when the script is saved. If no description is created, the script is most likely not parseable and contains syntax errors.
In maven-built projects, the ruta-maven-plugin can be utilized to create the type system descriptions of Ruta scripts.
In plain Java, the RutaDescriptorFactory can be utilized to create the type system description programmatically. Here's a code example.
There are several ways to create and execute a ruta-based analysis engine in plain java code. Here's an example without using additional files:
String rutaScript = "DECLARE MyType; CW{-> MyType};";
RutaDescriptorFactory descriptorFactory = new RutaDescriptorFactory();
RutaBuildOptions options = new RutaBuildOptions();
options.setResolveImports(true);
options.setImportByName(true);
RutaDescriptorInformation descriptorInformation = descriptorFactory
.parseDescriptorInformation(rutaScript, options);
// replace null values for build environment if necessary (e.g., location in classpath)
Pair<AnalysisEngineDescription, TypeSystemDescription> descriptions = descriptorFactory
.createDescriptions(null, null, descriptorInformation, options, null, null, null);
AnalysisEngineDescription rutaAnalysisEngineDescription = descriptions.getKey();
rutaAnalysisEngineDescription.getAnalysisEngineMetaData().getConfigurationParameterSettings().setParameterValue(RutaEngine.PARAM_RULES, rutaScript);
TypeSystemDescription rutaTypeSystemDescription = descriptions.getValue();
// directly set type system description since no file will be created
rutaAnalysisEngineDescription.getAnalysisEngineMetaData().setTypeSystem(rutaTypeSystemDescription);
ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(rutaAnalysisEngineDescription);
List<TypeSystemDescription> typeSystemDescriptions = new ArrayList<>();
TypeSystemDescription scannedTypeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription();
typeSystemDescriptions.add(scannedTypeSystemDescription);
typeSystemDescriptions.add(rutaTypeSystemDescription);
TypeSystemDescription mergeTypeSystemDescription = CasCreationUtils.mergeTypeSystems(typeSystemDescriptions, resourceManager);
JCas jCas = JCasFactory.createJCas(mergeTypeSystemDescription);
CAS cas = jCas.getCas();
jCas.setDocumentText("This is my document.");
ae.process(jCas);
Collection<AnnotationFS> select = CasUtil.select(cas, cas.getTypeSystem().getType("Anonymous.MyType"));
for (AnnotationFS each : select) {
System.out.println(each.getCoveredText());
}
DISCLAIMER: I am a developer of UIMA Ruta
I am using xerces in Java to build a DOM. For one of the fields that becomes a text node in the DOM, the data is being delivered from a source that has already turned any non ASCII and/or XML special characters into their entity names or numbers, e.g. "Banana®"
I know the design of the system is wrong in terms the data source shouldn't be doing this but that is out of my control, but what I am wondering is if there is a way to somehow prevent this from being escaped and turned into "Banana®" without decoding first? (I know it will implicitly convert any chars it needs to so I could enter the raw char after decoding).
Example code:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.newDocument();
Element root = dom.createElement("Companies");
dom.appendChild(root);
Element company = dom.createElement("Company");
Text t = dom.createTextNode("Banana®");
company.appendChild(t);
root.appendChild(company);
DOMImplementationRegistry dir = DOMImplementationRegistry.newInstance();
DOMImplementationLS impl =
(DOMImplementationLS)dir.getDOMImplementation("LS");
LSSerializer writer = impl.createLSSerializer();
LSOutput output = impl.createLSOutput();
output.setByteStream(System.out);
writer.write(dom, output);
Example Output:
<?xml version="1.0" encoding="UTF-8"?>
<Companies><Company>Banana®</Company></Companies>
If you could somehow declare it in a CDATA section, it should be passed through as is.
In my RCP app, I would like to point a property (osgi.java.profile) to a file, and would prefer using paths relative to my installation and config dir.
Is there a definitive spec on what kind of variables are supported in config.ini?
#config.dir seems to be supported, there are references in the builtin, and it's always mentioned as typical example (e.g this SO answer )
However, looking at docs like Eclipse help/Runtime Options, it mentions a few "symbolic locations" like #user.home; however that seems fairly limited and doesn't include #config.dir.
Have even dug into org.eclipse.osgi sources as well, and found no references to this (I did find LocationManager and its hard coded variable substitutions for #user.dir & co).
Can I refer to arbitrary system properties there in some way?
Is this #config.dir a special case, only handled by P2? UPDATE: this seems to be the case.. looking at Eclipse SDK, About .. Configuration dialog shows #config.dir unresolved, probably taken literally by the Equinox..
Thanks for any hints.
I'm late to the party, but hopefully this will help others in the future.
Starting with Eclipse 3.8/4.2 (June 2012), you can substitute Java properties and environment variables into your config.ini file (Eclipse Bug 241192). The Equinox launcher does not support substitution in the eclipse.ini launcher file. The syntax uses dollar signs ($VARIABLE$) to indicate variable substitution:
osgi.configuration.area=$APPDATA$/MyCompany/MyProgram/configuration
osgi.user.area=$APPDATA$/MyCompany/MyProgram/user
osgi.instance.area=$APPDATA$/MyCompany/MyProgram/instance
I imagine you could use something like this for your purposes:
osgi.java.profile=$osgi.install.area$/path/to/profile.txt
You can use a platform URL (Platform URI scheme) to achieve this, i.e.
osgi.java.profile = platform:/config/java_profile.txt
in config.ini, would point to the file java_profile.txt in the current configuration directory.
You might also use existing system properties in config.ini:
osgi.java.profile = ${osgi.configuration.area}/java_profile.txt
From org.eclipse.core.runtime.adaptor.LocationManager, here are the special tokens:
// Data mode constants for user, configuration and data locations.
private static final String NONE = "#none"; //$NON-NLS-1$
private static final String NO_DEFAULT = "#noDefault"; //$NON-NLS-1$
private static final String USER_HOME = "#user.home"; //$NON-NLS-1$
private static final String USER_DIR = "#user.dir"; //$NON-NLS-1$
Why not use two system property variables?
One is named -Dmy.relativepath=filename, which is processed by your code of relative path of eclipse installation folder(workspace or anywhere), another is called -Dmy.path=absolutepath.
The system property is passed to the jvm, you need some tricky(translate the variable in runtime) in the native launcher(like eclipse.exe) if you wants to use variable in its value.
Look how osgi.java.profile is resolved in org.eclipse.osgi.framework.internal.core.Framework:
// check for the java profile property for a url
String propJavaProfile = FrameworkProperties.getProperty(Constants.OSGI_JAVA_PROFILE);
if (propJavaProfile != null)
try {
// we assume a URL
url = new URL(propJavaProfile);
} catch (MalformedURLException e1) {
// try using a relative path in the system bundle
url = findInSystemBundle(propJavaProfile);
}
That means osgi.java.profile must point either to a fully qualified URL, or to a relative path in system bundle (org.eclipse.osgi). This makes impossible usage of installation directory relative path without patching Eclipse.
Given the name ch/mollusca/sample/snippet.xml, is there an easy way to get a hold of this file in JDT code, when it is located in the projects classpath either as a source file or inside a JAR?
The file may also be inside another project, that is referenced by the one, where I'm trying to get a hold of the actual file behind the name.
This is specific to Java projects, so it's possible to get a hold of the IJavaProject if that helps.
This is probably not the answer you want, but it's the best I can do (and since your question already has 2 days, I might has well throw you this):
Eclipse Corner Articles: Abstract Syntax Tree
Eclipse JDT - Abstract Syntax Tree (AST) and the Java Model - Tutorial
These two great articles will point you to the right direction.
How about this:
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if ( activeEditor != null ) {
IResource activeEditorResource = (IResource)activeEditor.getEditorInput().getAdapter( IResource.class );
if ( activeEditorResource != null && activeEditorResource.getFullPath() != null ) {
String activeFileName = activeEditorResource.getFullPath().toOSString();
//...do something with the active file
}
}