[JBoss JIRA] (JBTM-1605) Integrate STM with vert.x
by Mark Little (JIRA)
[ https://issues.jboss.org/browse/JBTM-1605?page=com.atlassian.jira.plugin.... ]
Mark Little commented on JBTM-1605:
-----------------------------------
https://github.com/nmcl/TransactionalVert.x
> Integrate STM with vert.x
> -------------------------
>
> Key: JBTM-1605
> URL: https://issues.jboss.org/browse/JBTM-1605
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: STM
> Affects Versions: 5.0.0.M2
> Reporter: Mark Little
> Assignee: Mark Little
>
> Finish the work started last year. Actor+transaction model.
> Due to the typical way vert.x works (one thread per task, unique classloader instance etc.), shared state is typically not a concern even between threads. STM still useful to ensure atomic updates in the presence of failures, or sharing via message passing. However, with our STM implementation, persistent instances can be shared between threads or processes in different address spaces if needed.
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months
[JBoss JIRA] (JBTM-2189) Bootstrapping from Complex Classloader (OneJar)
by Chris Pheby (JIRA)
[ https://issues.jboss.org/browse/JBTM-2189?page=com.atlassian.jira.plugin.... ]
Chris Pheby edited comment on JBTM-2189 at 6/10/14 2:30 PM:
------------------------------------------------------------
The initial exception is:
java.io.FileNotFoundException: \naintegration-1.0-SNAPSHOT.one-jar.jar (The syst
em cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Sour
ce)
at java.net.URL.openStream(Unknown Source)
at com.arjuna.common.util.ConfigurationInfo.getBuildTimeProperties(Confi
gurationInfo.java:113)
at com.arjuna.common.util.ConfigurationInfo.getPropertiesFile(Configurat
ionInfo.java:60)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.init
DefaultProperties(AbstractPropertiesFactory.java:212)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.getD
efaultProperties(AbstractPropertiesFactory.java:63)
at com.arjuna.common.util.propertyservice.PropertiesFactory.getDefaultPr
operties(PropertiesFactory.java:37)
at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getName
dInstance(BeanPopulator.java:77)
at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getDefa
ultInstance(BeanPopulator.java:49)
at com.arjuna.ats.jta.common.jtaPropertyManager.getJTAEnvironmentBean(jt
aPropertyManager.java:42)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.<c
linit>(BaseTransaction.java:305)
was (Author: chrisph):
The initial exception is:
java.io.FileNotFoundException: \naintegration-1.0-SNAPSHOT.one-jar.jar
(The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Sour
e)
at java.net.URL.openStream(Unknown Source)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.load
romFile(AbstractPropertiesFactory.java:142)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.getP
opertiesFromFile(AbstractPropertiesFactory.java:100)
... 33 more
> Bootstrapping from Complex Classloader (OneJar)
> -----------------------------------------------
>
> Key: JBTM-2189
> URL: https://issues.jboss.org/browse/JBTM-2189
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Common
> Affects Versions: 5.0.1
> Environment: JDK 8, OneJar 0.97
> Reporter: Chris Pheby
> Assignee: Tom Jenkinson
>
> I am using Narayana within a JavaSE application. The application is compiled into a single Jar. When executing, Narayana fails to bootstrap properly.
> The first problem is within com.arjuna.common.util.ConfigurationInfo.
> Lines 111-115 aim to load the MANIFEST file from the classpath:
> String pathToManifest = basePath+"/META-INF/MANIFEST.MF";
> InputStream is = null;
> try {
> is = new URL(pathToManifest).openStream();
> I replaced this with:
> InputStream is = null;
> // BEGIN - WORKAROUND FOR ONE-JAR
> try {
> String targetPrefix = pathToThisClass.substring(0, pathToThisClass.length() - "/com/arjuna/common/util/ConfigurationInfo.class".length());
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
> if (next.toString().startsWith(targetPrefix)) {
> is = next.openStream();
> break;
> }
> }
> // END - WORKAROUND FOR ONE-JAR
> This should work for all environments.
> Changes are also required in com.arjuna.common.util.propertyservice.AbstractPropertiesFactory to attempt loading from classpath as well as file system:
> The last line of initDefaultProperties (195) needed changing to:
> defaultProperties = getPropertiesFromClasspath(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> if (defaultProperties == null) {
> defaultProperties = getPropertiesFromFile(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> }
> }
> and the following methods added / replaced:
> /**
> * Returns the config properties read from a specified relative location on the classpath.
> *
> * @param propertyFileName the file name relative to the classpath root.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromClasspath(String propertyFileName, ClassLoader classLoader) {
> Properties properties = null;
>
> try {
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources(propertyFileName);
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
>
> properties = loadFromStream(next.openStream());
> return properties;
> }
> } catch(Exception e) {
> return null;
> }
> return properties;
> }
>
> /**
> * Returns the config properties read from a specified location.
> *
> * @param propertyFileName the file name. If relative, this is located using the FileLocator algorithm.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) {
> String propertiesSourceUri = null;
> try
> {
> // This is the point where the search path is applied - user.dir (pwd), user.home, java.home, classpath
> propertiesSourceUri = com.arjuna.common.util.propertyservice.FileLocator.locateFile(propertyFileName, classLoader);
> }
> catch(FileNotFoundException fileNotFoundException)
> {
> // try falling back to a default file built into the .jar
> // Note the default- prefix on the name, to avoid finding it from the .jar at the previous stage
> // in cases where the .jar comes before the etc dir on the classpath.
> URL url = AbstractPropertiesFactory.class.getResource("/default-"+propertyFileName);
> if(url == null) {
> throw new RuntimeException("missing property file "+propertyFileName);
> } else {
> propertiesSourceUri = url.toString();
> }
> }
> catch (IOException e)
> {
> throw new RuntimeException("invalid property file "+propertiesSourceUri, e);
> }
> Properties properties = null;
> try {
> properties = loadFromFile(propertiesSourceUri);
> properties = applySystemProperties(properties);
> } catch(Exception e) {
> throw new RuntimeException("unable to load properties from "+propertiesSourceUri, e);
> }
> return properties;
> }
> private Properties loadFromStream(InputStream inputStream) throws IOException {
> Properties inputProperties = new Properties();
> Properties outputProperties = new Properties();
> try {
> loadFromXML(inputProperties,inputStream);
> } finally {
> inputStream.close();
> }
> Enumeration namesEnumeration = inputProperties.propertyNames();
> while(namesEnumeration.hasMoreElements()) {
> String propertyName = (String)namesEnumeration.nextElement();
> String propertyValue = inputProperties.getProperty(propertyName);
> propertyValue = propertyValue.trim();
> // perform JBossAS style property substitutions. JBTM-369
> propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
> outputProperties.setProperty(propertyName, propertyValue);
> }
> return outputProperties;
> }
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months
[JBoss JIRA] (JBTM-2189) Bootstrapping from Complex Classloader (OneJar)
by Chris Pheby (JIRA)
[ https://issues.jboss.org/browse/JBTM-2189?page=com.atlassian.jira.plugin.... ]
Chris Pheby commented on JBTM-2189:
-----------------------------------
Both exceptions occur during the initialisation of Narayana / JBossTS
> Bootstrapping from Complex Classloader (OneJar)
> -----------------------------------------------
>
> Key: JBTM-2189
> URL: https://issues.jboss.org/browse/JBTM-2189
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Common
> Affects Versions: 5.0.1
> Environment: JDK 8, OneJar 0.97
> Reporter: Chris Pheby
> Assignee: Tom Jenkinson
>
> I am using Narayana within a JavaSE application. The application is compiled into a single Jar. When executing, Narayana fails to bootstrap properly.
> The first problem is within com.arjuna.common.util.ConfigurationInfo.
> Lines 111-115 aim to load the MANIFEST file from the classpath:
> String pathToManifest = basePath+"/META-INF/MANIFEST.MF";
> InputStream is = null;
> try {
> is = new URL(pathToManifest).openStream();
> I replaced this with:
> InputStream is = null;
> // BEGIN - WORKAROUND FOR ONE-JAR
> try {
> String targetPrefix = pathToThisClass.substring(0, pathToThisClass.length() - "/com/arjuna/common/util/ConfigurationInfo.class".length());
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
> if (next.toString().startsWith(targetPrefix)) {
> is = next.openStream();
> break;
> }
> }
> // END - WORKAROUND FOR ONE-JAR
> This should work for all environments.
> Changes are also required in com.arjuna.common.util.propertyservice.AbstractPropertiesFactory to attempt loading from classpath as well as file system:
> The last line of initDefaultProperties (195) needed changing to:
> defaultProperties = getPropertiesFromClasspath(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> if (defaultProperties == null) {
> defaultProperties = getPropertiesFromFile(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> }
> }
> and the following methods added / replaced:
> /**
> * Returns the config properties read from a specified relative location on the classpath.
> *
> * @param propertyFileName the file name relative to the classpath root.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromClasspath(String propertyFileName, ClassLoader classLoader) {
> Properties properties = null;
>
> try {
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources(propertyFileName);
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
>
> properties = loadFromStream(next.openStream());
> return properties;
> }
> } catch(Exception e) {
> return null;
> }
> return properties;
> }
>
> /**
> * Returns the config properties read from a specified location.
> *
> * @param propertyFileName the file name. If relative, this is located using the FileLocator algorithm.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) {
> String propertiesSourceUri = null;
> try
> {
> // This is the point where the search path is applied - user.dir (pwd), user.home, java.home, classpath
> propertiesSourceUri = com.arjuna.common.util.propertyservice.FileLocator.locateFile(propertyFileName, classLoader);
> }
> catch(FileNotFoundException fileNotFoundException)
> {
> // try falling back to a default file built into the .jar
> // Note the default- prefix on the name, to avoid finding it from the .jar at the previous stage
> // in cases where the .jar comes before the etc dir on the classpath.
> URL url = AbstractPropertiesFactory.class.getResource("/default-"+propertyFileName);
> if(url == null) {
> throw new RuntimeException("missing property file "+propertyFileName);
> } else {
> propertiesSourceUri = url.toString();
> }
> }
> catch (IOException e)
> {
> throw new RuntimeException("invalid property file "+propertiesSourceUri, e);
> }
> Properties properties = null;
> try {
> properties = loadFromFile(propertiesSourceUri);
> properties = applySystemProperties(properties);
> } catch(Exception e) {
> throw new RuntimeException("unable to load properties from "+propertiesSourceUri, e);
> }
> return properties;
> }
> private Properties loadFromStream(InputStream inputStream) throws IOException {
> Properties inputProperties = new Properties();
> Properties outputProperties = new Properties();
> try {
> loadFromXML(inputProperties,inputStream);
> } finally {
> inputStream.close();
> }
> Enumeration namesEnumeration = inputProperties.propertyNames();
> while(namesEnumeration.hasMoreElements()) {
> String propertyName = (String)namesEnumeration.nextElement();
> String propertyValue = inputProperties.getProperty(propertyName);
> propertyValue = propertyValue.trim();
> // perform JBossAS style property substitutions. JBTM-369
> propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
> outputProperties.setProperty(propertyName, propertyValue);
> }
> return outputProperties;
> }
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months
[JBoss JIRA] (JBTM-2189) Bootstrapping from Complex Classloader (OneJar)
by Chris Pheby (JIRA)
[ https://issues.jboss.org/browse/JBTM-2189?page=com.atlassian.jira.plugin.... ]
Chris Pheby commented on JBTM-2189:
-----------------------------------
After applying the change proposed to ConfigurationInfo, the following exception (which is addressed by the proposed change in AbstractPropertiesFactory) occurs:
java.io.FileNotFoundException: \naintegration-1.0-SNAPSHOT.one-jar.jar (The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Sour
ce)
at java.net.URL.openStream(Unknown Source)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.load
FromFile(AbstractPropertiesFactory.java:142)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.getP
ropertiesFromFile(AbstractPropertiesFactory.java:100)
... 33 more
> Bootstrapping from Complex Classloader (OneJar)
> -----------------------------------------------
>
> Key: JBTM-2189
> URL: https://issues.jboss.org/browse/JBTM-2189
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Common
> Affects Versions: 5.0.1
> Environment: JDK 8, OneJar 0.97
> Reporter: Chris Pheby
> Assignee: Tom Jenkinson
>
> I am using Narayana within a JavaSE application. The application is compiled into a single Jar. When executing, Narayana fails to bootstrap properly.
> The first problem is within com.arjuna.common.util.ConfigurationInfo.
> Lines 111-115 aim to load the MANIFEST file from the classpath:
> String pathToManifest = basePath+"/META-INF/MANIFEST.MF";
> InputStream is = null;
> try {
> is = new URL(pathToManifest).openStream();
> I replaced this with:
> InputStream is = null;
> // BEGIN - WORKAROUND FOR ONE-JAR
> try {
> String targetPrefix = pathToThisClass.substring(0, pathToThisClass.length() - "/com/arjuna/common/util/ConfigurationInfo.class".length());
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
> if (next.toString().startsWith(targetPrefix)) {
> is = next.openStream();
> break;
> }
> }
> // END - WORKAROUND FOR ONE-JAR
> This should work for all environments.
> Changes are also required in com.arjuna.common.util.propertyservice.AbstractPropertiesFactory to attempt loading from classpath as well as file system:
> The last line of initDefaultProperties (195) needed changing to:
> defaultProperties = getPropertiesFromClasspath(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> if (defaultProperties == null) {
> defaultProperties = getPropertiesFromFile(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> }
> }
> and the following methods added / replaced:
> /**
> * Returns the config properties read from a specified relative location on the classpath.
> *
> * @param propertyFileName the file name relative to the classpath root.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromClasspath(String propertyFileName, ClassLoader classLoader) {
> Properties properties = null;
>
> try {
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources(propertyFileName);
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
>
> properties = loadFromStream(next.openStream());
> return properties;
> }
> } catch(Exception e) {
> return null;
> }
> return properties;
> }
>
> /**
> * Returns the config properties read from a specified location.
> *
> * @param propertyFileName the file name. If relative, this is located using the FileLocator algorithm.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) {
> String propertiesSourceUri = null;
> try
> {
> // This is the point where the search path is applied - user.dir (pwd), user.home, java.home, classpath
> propertiesSourceUri = com.arjuna.common.util.propertyservice.FileLocator.locateFile(propertyFileName, classLoader);
> }
> catch(FileNotFoundException fileNotFoundException)
> {
> // try falling back to a default file built into the .jar
> // Note the default- prefix on the name, to avoid finding it from the .jar at the previous stage
> // in cases where the .jar comes before the etc dir on the classpath.
> URL url = AbstractPropertiesFactory.class.getResource("/default-"+propertyFileName);
> if(url == null) {
> throw new RuntimeException("missing property file "+propertyFileName);
> } else {
> propertiesSourceUri = url.toString();
> }
> }
> catch (IOException e)
> {
> throw new RuntimeException("invalid property file "+propertiesSourceUri, e);
> }
> Properties properties = null;
> try {
> properties = loadFromFile(propertiesSourceUri);
> properties = applySystemProperties(properties);
> } catch(Exception e) {
> throw new RuntimeException("unable to load properties from "+propertiesSourceUri, e);
> }
> return properties;
> }
> private Properties loadFromStream(InputStream inputStream) throws IOException {
> Properties inputProperties = new Properties();
> Properties outputProperties = new Properties();
> try {
> loadFromXML(inputProperties,inputStream);
> } finally {
> inputStream.close();
> }
> Enumeration namesEnumeration = inputProperties.propertyNames();
> while(namesEnumeration.hasMoreElements()) {
> String propertyName = (String)namesEnumeration.nextElement();
> String propertyValue = inputProperties.getProperty(propertyName);
> propertyValue = propertyValue.trim();
> // perform JBossAS style property substitutions. JBTM-369
> propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
> outputProperties.setProperty(propertyName, propertyValue);
> }
> return outputProperties;
> }
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months
[JBoss JIRA] (JBTM-2189) Bootstrapping from Complex Classloader (OneJar)
by Chris Pheby (JIRA)
[ https://issues.jboss.org/browse/JBTM-2189?page=com.atlassian.jira.plugin.... ]
Chris Pheby edited comment on JBTM-2189 at 6/10/14 2:21 PM:
------------------------------------------------------------
The initial exception is:
java.io.FileNotFoundException: \naintegration-1.0-SNAPSHOT.one-jar.jar
(The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Sour
e)
at java.net.URL.openStream(Unknown Source)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.load
romFile(AbstractPropertiesFactory.java:142)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.getP
opertiesFromFile(AbstractPropertiesFactory.java:100)
... 33 more
was (Author: chrisph):
The initial exception is:
aused by: java.io.FileNotFoundException: \naintegration-1.0-SNAPSHOT.one-jar.ja
(The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Sour
e)
at java.net.URL.openStream(Unknown Source)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.load
romFile(AbstractPropertiesFactory.java:142)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.getP
opertiesFromFile(AbstractPropertiesFactory.java:100)
... 33 more
> Bootstrapping from Complex Classloader (OneJar)
> -----------------------------------------------
>
> Key: JBTM-2189
> URL: https://issues.jboss.org/browse/JBTM-2189
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Common
> Affects Versions: 5.0.1
> Environment: JDK 8, OneJar 0.97
> Reporter: Chris Pheby
> Assignee: Tom Jenkinson
>
> I am using Narayana within a JavaSE application. The application is compiled into a single Jar. When executing, Narayana fails to bootstrap properly.
> The first problem is within com.arjuna.common.util.ConfigurationInfo.
> Lines 111-115 aim to load the MANIFEST file from the classpath:
> String pathToManifest = basePath+"/META-INF/MANIFEST.MF";
> InputStream is = null;
> try {
> is = new URL(pathToManifest).openStream();
> I replaced this with:
> InputStream is = null;
> // BEGIN - WORKAROUND FOR ONE-JAR
> try {
> String targetPrefix = pathToThisClass.substring(0, pathToThisClass.length() - "/com/arjuna/common/util/ConfigurationInfo.class".length());
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
> if (next.toString().startsWith(targetPrefix)) {
> is = next.openStream();
> break;
> }
> }
> // END - WORKAROUND FOR ONE-JAR
> This should work for all environments.
> Changes are also required in com.arjuna.common.util.propertyservice.AbstractPropertiesFactory to attempt loading from classpath as well as file system:
> The last line of initDefaultProperties (195) needed changing to:
> defaultProperties = getPropertiesFromClasspath(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> if (defaultProperties == null) {
> defaultProperties = getPropertiesFromFile(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> }
> }
> and the following methods added / replaced:
> /**
> * Returns the config properties read from a specified relative location on the classpath.
> *
> * @param propertyFileName the file name relative to the classpath root.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromClasspath(String propertyFileName, ClassLoader classLoader) {
> Properties properties = null;
>
> try {
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources(propertyFileName);
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
>
> properties = loadFromStream(next.openStream());
> return properties;
> }
> } catch(Exception e) {
> return null;
> }
> return properties;
> }
>
> /**
> * Returns the config properties read from a specified location.
> *
> * @param propertyFileName the file name. If relative, this is located using the FileLocator algorithm.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) {
> String propertiesSourceUri = null;
> try
> {
> // This is the point where the search path is applied - user.dir (pwd), user.home, java.home, classpath
> propertiesSourceUri = com.arjuna.common.util.propertyservice.FileLocator.locateFile(propertyFileName, classLoader);
> }
> catch(FileNotFoundException fileNotFoundException)
> {
> // try falling back to a default file built into the .jar
> // Note the default- prefix on the name, to avoid finding it from the .jar at the previous stage
> // in cases where the .jar comes before the etc dir on the classpath.
> URL url = AbstractPropertiesFactory.class.getResource("/default-"+propertyFileName);
> if(url == null) {
> throw new RuntimeException("missing property file "+propertyFileName);
> } else {
> propertiesSourceUri = url.toString();
> }
> }
> catch (IOException e)
> {
> throw new RuntimeException("invalid property file "+propertiesSourceUri, e);
> }
> Properties properties = null;
> try {
> properties = loadFromFile(propertiesSourceUri);
> properties = applySystemProperties(properties);
> } catch(Exception e) {
> throw new RuntimeException("unable to load properties from "+propertiesSourceUri, e);
> }
> return properties;
> }
> private Properties loadFromStream(InputStream inputStream) throws IOException {
> Properties inputProperties = new Properties();
> Properties outputProperties = new Properties();
> try {
> loadFromXML(inputProperties,inputStream);
> } finally {
> inputStream.close();
> }
> Enumeration namesEnumeration = inputProperties.propertyNames();
> while(namesEnumeration.hasMoreElements()) {
> String propertyName = (String)namesEnumeration.nextElement();
> String propertyValue = inputProperties.getProperty(propertyName);
> propertyValue = propertyValue.trim();
> // perform JBossAS style property substitutions. JBTM-369
> propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
> outputProperties.setProperty(propertyName, propertyValue);
> }
> return outputProperties;
> }
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months
[JBoss JIRA] (JBTM-2189) Bootstrapping from Complex Classloader (OneJar)
by Chris Pheby (JIRA)
[ https://issues.jboss.org/browse/JBTM-2189?page=com.atlassian.jira.plugin.... ]
Chris Pheby commented on JBTM-2189:
-----------------------------------
The initial exception is:
aused by: java.io.FileNotFoundException: \naintegration-1.0-SNAPSHOT.one-jar.ja
(The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Sour
e)
at java.net.URL.openStream(Unknown Source)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.load
romFile(AbstractPropertiesFactory.java:142)
at com.arjuna.common.util.propertyservice.AbstractPropertiesFactory.getP
opertiesFromFile(AbstractPropertiesFactory.java:100)
... 33 more
> Bootstrapping from Complex Classloader (OneJar)
> -----------------------------------------------
>
> Key: JBTM-2189
> URL: https://issues.jboss.org/browse/JBTM-2189
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Common
> Affects Versions: 5.0.1
> Environment: JDK 8, OneJar 0.97
> Reporter: Chris Pheby
> Assignee: Tom Jenkinson
>
> I am using Narayana within a JavaSE application. The application is compiled into a single Jar. When executing, Narayana fails to bootstrap properly.
> The first problem is within com.arjuna.common.util.ConfigurationInfo.
> Lines 111-115 aim to load the MANIFEST file from the classpath:
> String pathToManifest = basePath+"/META-INF/MANIFEST.MF";
> InputStream is = null;
> try {
> is = new URL(pathToManifest).openStream();
> I replaced this with:
> InputStream is = null;
> // BEGIN - WORKAROUND FOR ONE-JAR
> try {
> String targetPrefix = pathToThisClass.substring(0, pathToThisClass.length() - "/com/arjuna/common/util/ConfigurationInfo.class".length());
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
> if (next.toString().startsWith(targetPrefix)) {
> is = next.openStream();
> break;
> }
> }
> // END - WORKAROUND FOR ONE-JAR
> This should work for all environments.
> Changes are also required in com.arjuna.common.util.propertyservice.AbstractPropertiesFactory to attempt loading from classpath as well as file system:
> The last line of initDefaultProperties (195) needed changing to:
> defaultProperties = getPropertiesFromClasspath(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> if (defaultProperties == null) {
> defaultProperties = getPropertiesFromFile(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> }
> }
> and the following methods added / replaced:
> /**
> * Returns the config properties read from a specified relative location on the classpath.
> *
> * @param propertyFileName the file name relative to the classpath root.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromClasspath(String propertyFileName, ClassLoader classLoader) {
> Properties properties = null;
>
> try {
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources(propertyFileName);
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
>
> properties = loadFromStream(next.openStream());
> return properties;
> }
> } catch(Exception e) {
> return null;
> }
> return properties;
> }
>
> /**
> * Returns the config properties read from a specified location.
> *
> * @param propertyFileName the file name. If relative, this is located using the FileLocator algorithm.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) {
> String propertiesSourceUri = null;
> try
> {
> // This is the point where the search path is applied - user.dir (pwd), user.home, java.home, classpath
> propertiesSourceUri = com.arjuna.common.util.propertyservice.FileLocator.locateFile(propertyFileName, classLoader);
> }
> catch(FileNotFoundException fileNotFoundException)
> {
> // try falling back to a default file built into the .jar
> // Note the default- prefix on the name, to avoid finding it from the .jar at the previous stage
> // in cases where the .jar comes before the etc dir on the classpath.
> URL url = AbstractPropertiesFactory.class.getResource("/default-"+propertyFileName);
> if(url == null) {
> throw new RuntimeException("missing property file "+propertyFileName);
> } else {
> propertiesSourceUri = url.toString();
> }
> }
> catch (IOException e)
> {
> throw new RuntimeException("invalid property file "+propertiesSourceUri, e);
> }
> Properties properties = null;
> try {
> properties = loadFromFile(propertiesSourceUri);
> properties = applySystemProperties(properties);
> } catch(Exception e) {
> throw new RuntimeException("unable to load properties from "+propertiesSourceUri, e);
> }
> return properties;
> }
> private Properties loadFromStream(InputStream inputStream) throws IOException {
> Properties inputProperties = new Properties();
> Properties outputProperties = new Properties();
> try {
> loadFromXML(inputProperties,inputStream);
> } finally {
> inputStream.close();
> }
> Enumeration namesEnumeration = inputProperties.propertyNames();
> while(namesEnumeration.hasMoreElements()) {
> String propertyName = (String)namesEnumeration.nextElement();
> String propertyValue = inputProperties.getProperty(propertyName);
> propertyValue = propertyValue.trim();
> // perform JBossAS style property substitutions. JBTM-369
> propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
> outputProperties.setProperty(propertyName, propertyValue);
> }
> return outputProperties;
> }
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months
[JBoss JIRA] (JBTM-2189) Bootstrapping from Complex Classloader (OneJar)
by Mark Little (JIRA)
[ https://issues.jboss.org/browse/JBTM-2189?page=com.atlassian.jira.plugin.... ]
Mark Little edited comment on JBTM-2189 at 6/10/14 1:02 PM:
------------------------------------------------------------
For clarity in future if others come to this issue, can you please describe what problem you've seen and hence why you've submitted a patch. "fails to bootstrap properly" isn't sufficient. Thanks.
was (Author: marklittle):
For clarity in future if others come to this issue, can you please describe what problem you've seen and hence why you've submitted a patch. Thanks.
> Bootstrapping from Complex Classloader (OneJar)
> -----------------------------------------------
>
> Key: JBTM-2189
> URL: https://issues.jboss.org/browse/JBTM-2189
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Common
> Affects Versions: 5.0.1
> Environment: JDK 8, OneJar 0.97
> Reporter: Chris Pheby
> Assignee: Tom Jenkinson
>
> I am using Narayana within a JavaSE application. The application is compiled into a single Jar. When executing, Narayana fails to bootstrap properly.
> The first problem is within com.arjuna.common.util.ConfigurationInfo.
> Lines 111-115 aim to load the MANIFEST file from the classpath:
> String pathToManifest = basePath+"/META-INF/MANIFEST.MF";
> InputStream is = null;
> try {
> is = new URL(pathToManifest).openStream();
> I replaced this with:
> InputStream is = null;
> // BEGIN - WORKAROUND FOR ONE-JAR
> try {
> String targetPrefix = pathToThisClass.substring(0, pathToThisClass.length() - "/com/arjuna/common/util/ConfigurationInfo.class".length());
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
> if (next.toString().startsWith(targetPrefix)) {
> is = next.openStream();
> break;
> }
> }
> // END - WORKAROUND FOR ONE-JAR
> This should work for all environments.
> Changes are also required in com.arjuna.common.util.propertyservice.AbstractPropertiesFactory to attempt loading from classpath as well as file system:
> The last line of initDefaultProperties (195) needed changing to:
> defaultProperties = getPropertiesFromClasspath(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> if (defaultProperties == null) {
> defaultProperties = getPropertiesFromFile(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> }
> }
> and the following methods added / replaced:
> /**
> * Returns the config properties read from a specified relative location on the classpath.
> *
> * @param propertyFileName the file name relative to the classpath root.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromClasspath(String propertyFileName, ClassLoader classLoader) {
> Properties properties = null;
>
> try {
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources(propertyFileName);
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
>
> properties = loadFromStream(next.openStream());
> return properties;
> }
> } catch(Exception e) {
> return null;
> }
> return properties;
> }
>
> /**
> * Returns the config properties read from a specified location.
> *
> * @param propertyFileName the file name. If relative, this is located using the FileLocator algorithm.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) {
> String propertiesSourceUri = null;
> try
> {
> // This is the point where the search path is applied - user.dir (pwd), user.home, java.home, classpath
> propertiesSourceUri = com.arjuna.common.util.propertyservice.FileLocator.locateFile(propertyFileName, classLoader);
> }
> catch(FileNotFoundException fileNotFoundException)
> {
> // try falling back to a default file built into the .jar
> // Note the default- prefix on the name, to avoid finding it from the .jar at the previous stage
> // in cases where the .jar comes before the etc dir on the classpath.
> URL url = AbstractPropertiesFactory.class.getResource("/default-"+propertyFileName);
> if(url == null) {
> throw new RuntimeException("missing property file "+propertyFileName);
> } else {
> propertiesSourceUri = url.toString();
> }
> }
> catch (IOException e)
> {
> throw new RuntimeException("invalid property file "+propertiesSourceUri, e);
> }
> Properties properties = null;
> try {
> properties = loadFromFile(propertiesSourceUri);
> properties = applySystemProperties(properties);
> } catch(Exception e) {
> throw new RuntimeException("unable to load properties from "+propertiesSourceUri, e);
> }
> return properties;
> }
> private Properties loadFromStream(InputStream inputStream) throws IOException {
> Properties inputProperties = new Properties();
> Properties outputProperties = new Properties();
> try {
> loadFromXML(inputProperties,inputStream);
> } finally {
> inputStream.close();
> }
> Enumeration namesEnumeration = inputProperties.propertyNames();
> while(namesEnumeration.hasMoreElements()) {
> String propertyName = (String)namesEnumeration.nextElement();
> String propertyValue = inputProperties.getProperty(propertyName);
> propertyValue = propertyValue.trim();
> // perform JBossAS style property substitutions. JBTM-369
> propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
> outputProperties.setProperty(propertyName, propertyValue);
> }
> return outputProperties;
> }
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months
[JBoss JIRA] (JBTM-2189) Bootstrapping from Complex Classloader (OneJar)
by Mark Little (JIRA)
[ https://issues.jboss.org/browse/JBTM-2189?page=com.atlassian.jira.plugin.... ]
Mark Little commented on JBTM-2189:
-----------------------------------
For clarity in future if others come to this issue, can you please describe what problem you've seen and hence why you've submitted a patch. Thanks.
> Bootstrapping from Complex Classloader (OneJar)
> -----------------------------------------------
>
> Key: JBTM-2189
> URL: https://issues.jboss.org/browse/JBTM-2189
> Project: JBoss Transaction Manager
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Common
> Affects Versions: 5.0.1
> Environment: JDK 8, OneJar 0.97
> Reporter: Chris Pheby
> Assignee: Tom Jenkinson
>
> I am using Narayana within a JavaSE application. The application is compiled into a single Jar. When executing, Narayana fails to bootstrap properly.
> The first problem is within com.arjuna.common.util.ConfigurationInfo.
> Lines 111-115 aim to load the MANIFEST file from the classpath:
> String pathToManifest = basePath+"/META-INF/MANIFEST.MF";
> InputStream is = null;
> try {
> is = new URL(pathToManifest).openStream();
> I replaced this with:
> InputStream is = null;
> // BEGIN - WORKAROUND FOR ONE-JAR
> try {
> String targetPrefix = pathToThisClass.substring(0, pathToThisClass.length() - "/com/arjuna/common/util/ConfigurationInfo.class".length());
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
> if (next.toString().startsWith(targetPrefix)) {
> is = next.openStream();
> break;
> }
> }
> // END - WORKAROUND FOR ONE-JAR
> This should work for all environments.
> Changes are also required in com.arjuna.common.util.propertyservice.AbstractPropertiesFactory to attempt loading from classpath as well as file system:
> The last line of initDefaultProperties (195) needed changing to:
> defaultProperties = getPropertiesFromClasspath(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> if (defaultProperties == null) {
> defaultProperties = getPropertiesFromFile(propertyFileName, PropertiesFactoryStax.class.getClassLoader());
> }
> }
> and the following methods added / replaced:
> /**
> * Returns the config properties read from a specified relative location on the classpath.
> *
> * @param propertyFileName the file name relative to the classpath root.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromClasspath(String propertyFileName, ClassLoader classLoader) {
> Properties properties = null;
>
> try {
> Enumeration<URL> resources = ConfigurationInfo.class.getClassLoader().getResources(propertyFileName);
> while (resources.hasMoreElements()) {
> URL next = resources.nextElement();
>
> properties = loadFromStream(next.openStream());
> return properties;
> }
> } catch(Exception e) {
> return null;
> }
> return properties;
> }
>
> /**
> * Returns the config properties read from a specified location.
> *
> * @param propertyFileName the file name. If relative, this is located using the FileLocator algorithm.
> * @return the Properties loaded from the specified source.
> */
> public Properties getPropertiesFromFile(String propertyFileName, ClassLoader classLoader) {
> String propertiesSourceUri = null;
> try
> {
> // This is the point where the search path is applied - user.dir (pwd), user.home, java.home, classpath
> propertiesSourceUri = com.arjuna.common.util.propertyservice.FileLocator.locateFile(propertyFileName, classLoader);
> }
> catch(FileNotFoundException fileNotFoundException)
> {
> // try falling back to a default file built into the .jar
> // Note the default- prefix on the name, to avoid finding it from the .jar at the previous stage
> // in cases where the .jar comes before the etc dir on the classpath.
> URL url = AbstractPropertiesFactory.class.getResource("/default-"+propertyFileName);
> if(url == null) {
> throw new RuntimeException("missing property file "+propertyFileName);
> } else {
> propertiesSourceUri = url.toString();
> }
> }
> catch (IOException e)
> {
> throw new RuntimeException("invalid property file "+propertiesSourceUri, e);
> }
> Properties properties = null;
> try {
> properties = loadFromFile(propertiesSourceUri);
> properties = applySystemProperties(properties);
> } catch(Exception e) {
> throw new RuntimeException("unable to load properties from "+propertiesSourceUri, e);
> }
> return properties;
> }
> private Properties loadFromStream(InputStream inputStream) throws IOException {
> Properties inputProperties = new Properties();
> Properties outputProperties = new Properties();
> try {
> loadFromXML(inputProperties,inputStream);
> } finally {
> inputStream.close();
> }
> Enumeration namesEnumeration = inputProperties.propertyNames();
> while(namesEnumeration.hasMoreElements()) {
> String propertyName = (String)namesEnumeration.nextElement();
> String propertyValue = inputProperties.getProperty(propertyName);
> propertyValue = propertyValue.trim();
> // perform JBossAS style property substitutions. JBTM-369
> propertyValue = StringPropertyReplacer.replaceProperties(propertyValue);
> outputProperties.setProperty(propertyName, propertyValue);
> }
> return outputProperties;
> }
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
10 years, 9 months